|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C++
DETAILS
Question: Write the psuedo code for the Depth first Search.
Answer: dfs(G, v) //OUTLINE Mark v as "discovered" For each vertex w such that edge vw is in G: If w is undiscovered: dfs(G, w); that is, explore vw, visit w, explore from there as much as possible, and backtrack from w to v. Otherwise: "Check" vw without visiting w. Mark v as "finished".
|
|
|
Category |
C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7160 users |
Added on |
7/16/2015 |
Views |
70229 |
Rate it! |
|
|
Question:
Write the psuedo code for the Depth first Search.
Answer:
dfs(G, v) //OUTLINE Mark v as "discovered" For each vertex w such that edge vw is in G: If w is undiscovered: dfs(G, w); that is, explore vw, visit w, explore from there as much as possible, and backtrack from w to v. Otherwise: "Check" vw without visiting w. Mark v as "finished". Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What are the advantages and disadvantages of B-star trees over Binary trees?
|
View Answer
|
|
Write a fucntion that will reverse a string.
|
View Answer
|
|
What is the difference between Stack and Queue?
|
View Answer
|
|
What are the differences between new and malloc?
|
View Answer
|
|
What is your reaction to this line of code?
|
View Answer
|
|
When should you use multiple inheritance?
|
View Answer
|
|
What are the debugging methods you use when came across a problem?
|
View Answer
|
|
How the compilers arranges the various sections in the executable image?
|
View Answer
|
|
What are the differences between a C++ struct and C++ class?
|
View Answer
|
|
How do you know that your class needs a virtual destructor?
|
View Answer
|
|
What is the difference between new/delete and malloc/free?
|
View Answer
|
|
What happens when a function throws an exception that was not specified by an exception specification for this function?
|
View Answer
|
|
Can you think of a situation where your program would crash without reaching the breakball, which you set at the beginning of main()?
|
View Answer
|
|
What issue do auto_ptr objects address?
|
View Answer
|
|
Is there any problem with the following:
|
View Answer
|
|
Why do C++ compilers need name mangling?
|
View Answer
|
|
Is there anything you can do in C++ that you cannot do in C?
|
View Answer
|
|
What is problem with Runtime type identification?
|
View Answer
|
|
What is Pure Virtual Function? Why and when it is used ?
|
View Answer
|
|
What about Virtual Destructor?
|
View Answer
|