how to use recursive to find longest-path?











up vote
-1
down vote

favorite












I have a question like:




Write a recursive procedure for computing the longest-path lengths that does not store vertices to be processed explicitly in a data structure: so, the new procedure should not contain the variable Q




according to I recognition, I write down like that:



FindLongest(notYetJoinedSet n, alreadyJoinedSet a){
if(n is empty)
end

max= 0;
for (every member of n as i ) {
if (i>max ){
max = i
}
}

a.add(max)
FindLongest(n,a)

}


Is it any wrong or I misunderstand something?










share|improve this question
























  • This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
    – MBo
    Nov 8 at 11:42












  • it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
    – Shawn Plus
    Nov 8 at 11:59












  • So what is "the variable Q" for example? There is a lot of context missing.
    – Henry
    Nov 8 at 12:36















up vote
-1
down vote

favorite












I have a question like:




Write a recursive procedure for computing the longest-path lengths that does not store vertices to be processed explicitly in a data structure: so, the new procedure should not contain the variable Q




according to I recognition, I write down like that:



FindLongest(notYetJoinedSet n, alreadyJoinedSet a){
if(n is empty)
end

max= 0;
for (every member of n as i ) {
if (i>max ){
max = i
}
}

a.add(max)
FindLongest(n,a)

}


Is it any wrong or I misunderstand something?










share|improve this question
























  • This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
    – MBo
    Nov 8 at 11:42












  • it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
    – Shawn Plus
    Nov 8 at 11:59












  • So what is "the variable Q" for example? There is a lot of context missing.
    – Henry
    Nov 8 at 12:36













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a question like:




Write a recursive procedure for computing the longest-path lengths that does not store vertices to be processed explicitly in a data structure: so, the new procedure should not contain the variable Q




according to I recognition, I write down like that:



FindLongest(notYetJoinedSet n, alreadyJoinedSet a){
if(n is empty)
end

max= 0;
for (every member of n as i ) {
if (i>max ){
max = i
}
}

a.add(max)
FindLongest(n,a)

}


Is it any wrong or I misunderstand something?










share|improve this question















I have a question like:




Write a recursive procedure for computing the longest-path lengths that does not store vertices to be processed explicitly in a data structure: so, the new procedure should not contain the variable Q




according to I recognition, I write down like that:



FindLongest(notYetJoinedSet n, alreadyJoinedSet a){
if(n is empty)
end

max= 0;
for (every member of n as i ) {
if (i>max ){
max = i
}
}

a.add(max)
FindLongest(n,a)

}


Is it any wrong or I misunderstand something?







algorithm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 10:17

























asked Nov 8 at 10:06









Shawn Plus

379




379












  • This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
    – MBo
    Nov 8 at 11:42












  • it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
    – Shawn Plus
    Nov 8 at 11:59












  • So what is "the variable Q" for example? There is a lot of context missing.
    – Henry
    Nov 8 at 12:36


















  • This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
    – MBo
    Nov 8 at 11:42












  • it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
    – Shawn Plus
    Nov 8 at 11:59












  • So what is "the variable Q" for example? There is a lot of context missing.
    – Henry
    Nov 8 at 12:36
















This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
– MBo
Nov 8 at 11:42






This is not problem formulation, just arbitrary pieces of thoughts. Note that we cannot see problem description in your book or computer (well, not all of us ;)
– MBo
Nov 8 at 11:42














it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
– Shawn Plus
Nov 8 at 11:59






it's real, the question just like that. no context I think this's about Dijkstra algorithm but I'm not pretty sure
– Shawn Plus
Nov 8 at 11:59














So what is "the variable Q" for example? There is a lot of context missing.
– Henry
Nov 8 at 12:36




So what is "the variable Q" for example? There is a lot of context missing.
– Henry
Nov 8 at 12:36

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205449%2fhow-to-use-recursive-to-find-longest-path%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205449%2fhow-to-use-recursive-to-find-longest-path%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff