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?
algorithm
add a comment |
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?
algorithm
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
add a comment |
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?
algorithm
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
algorithm
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
add a comment |
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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