Yahoo Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

use a TRIE.. http://en.wikipedia.org/wiki/Trie

- hgk October 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I went through Trie data structure where trie can be used to sort keys. Below are the steps from Wiki.

Sorting
Lexicographic sorting of a set of keys can be accomplished with a simple trie-based algorithm as follows:
1 Insert all keys in a trie.
2 Output all keys in the trie by means of pre-order traversal, which results in output that is in lexicographically increasing order. Pre-order traversal is a kind of breadth-first traversal. In-order traversal is another kind of depth-first traversal that is more appropriate for outputting the values that are in a binary search tree rather than a trie.

I could not understand the second step. (Use the example trie given on wiki page). How can one do pre-order traveresal with a tree that is not binary. In example if i simply visit every root (pre-order traversal) i would end up getting to, tea, ted which is not sorted. Since tea must come before to. Can some1 explain with an example how to sort using trie

- Singleton July 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That example is missing the order that ideally should have been followed. You see for each node in a trie we have 26 possible pointers[26=size of alphabet]; And the need to have some ordering. Once ordering is followed, you would get sorted data.

- Pavan Dittakavi August 18, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More