Algorithm - Interview Questions and Answers for 'Overstock' | Search Java Interview Question - javasearch.buggybread.com

Search Interview Questions

3193 questions in repository.
There are more than 200 unanswered questions.
Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

Overstock.com

Algorithm - Interview Questions and Answers for 'Overstock' - 2 question(s) found - Order By Newest

Q1. Write an Algorithm for Graph Traversal ? The Graph has a loop.Algorithm2016-11-30 15:42:32
Ans. Please not that all such questions can be easily answered through recursion.

Simple recursive implementation could be

traverse(root);

void traverse(Element element){
if(element.hasNext()){
traverse(element.next());
} else {
System.out.println(element);
}
}

but this algo / code lead to endless loop if there is a loop in graph traversal.

So you can keep a collection to keep track of which elements have laready been traversed

static List<Elements> listOfAlreadyTraversedElements = new ArrayList<Elements>();

main(){
traverse(root);
}

void traverse(Element element){
if(element.hasNext()){
traverse(element.next());
} else {
System.out.println(element);
}
}

Help us improve. Please let us know the company, where you were asked this question :

graph traversal algorithm  graph traversal algorithm using recursion     Overstock.com      intermediate

Related Questions

Can you provide some implementation of a Dictionary having large number of words ?
What is the difference between Graph's Breadth first and Depth First algorithm ?
In a Linked list with sorted numbers, insert a new numbers while maintaining the sort order.
What are the pre-requisite for the collection to perform Binary Search ?
Write a program for LinkedList, with method to append node and traversing the list ?
Which sorting algorithm is used by Collections.sort() in Java ?
How to determine if the linked list has a cycle in it ?
Explain various Searching and Sorting Algorithms ?
Write an algorithm / java program for Heap Sort ?

Q2. Write a Program to print all nodes of the data structure ?Algorithm2019-01-29 13:24:26

Help us improve. Please let us know the company, where you were asked this question :

data structure  algorithm     Overstock.com

Related Questions

If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?
What is the difference between ArrayList and LinkedList ?
Can you provide some implementation of a Dictionary having large number of words ?
In a Linked list with sorted numbers, insert a new numbers while maintaining the sort order.
Write a program for LinkedList, with method to append node and traversing the list ?
What is the difference between Data Type and Data Structure ?
Do you see Class as a Data Type or Data Structure ?
How to determine if the linked list has a cycle in it ?
Which Data Structure should be used for Load Balancer ?
Which data structure would you recommend for ordered and sorted data?

Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Delivered by FeedBurner

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.