Google Interview Question for SDE1s


Country: United States
Interview Type: In-Person




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

map and set objects in many language where data is constantly entering and leaving

- Putta May 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can't we just use hashmap and hashset for this, it will be O(1) where BST will take O(logn)

- Guy February 09, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

Priority Queue is an application of binary search tree.

- Varun Jain May 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 votes

No. In a BST you have a total ordering (think printing in-order). That is not necessary for a priority queue. A priority queue is typically implemented as a heap.

- Anonymous May 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

@Anonynous1: So Heap does not require a total order? Priority Queue does not require a total order? What are you talking about?

- Anonymous May 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

In a BST you can determine if an element is present or not in O(Log(n)) time. You can't do that in a heap. If an element is smaller than the maximal element in the heap (the root), you don't know if that element is in the left branch or the right branch. In a priority queue you of course don't care about anything but the element of highest priority. Hence no reason for a total ordering.

- Anonymous May 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Data in a BST is completely sorted. That is not the case with a priority queue. Building a BST is O(n log n). In contrast, a priority queue using a heap can be built in O(n). Hence using a BST for a priority queue is wasteful.

- Anonymous May 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

LOL@ Anonymous. First search for what "Total order" even means (as pointed about by eugene).

And, priority queue can be implemented in terms of binary search trees. That is all Varun is saying.

Your objections are nonsense.

- Anonymous May 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

finding nearest neighbor to a point using kd trees (application of binary trees)

- Gitesh Gupta May 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Binary search trees are a fundamental data structure used to construct more abstract data structures such as sets, multisets, and associative arrays.

- SunnyD May 29, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

BST is applicable in Serialization. You can take the complete File structure, serialize in a inorder fashion and can send over the network

- prashanthreddy.mtech May 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
4
of 4 votes

a trie is not a BST

- Dumbo May 24, 2013 | 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