Google On-Site L3 | Bangalore
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-12-21Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: Bangalore
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
I was asked a tree traversal + top K elements question disguised in a story. Essentially, traverse the tree to find "eligible" nodes, based on some condition, and then, return the top 10 "eligible" nodes based on their size.
I wrote a BFS algorithm for tree traversal + quick select to retrieve top K elements.
When asked about time complexity, I said that it would be O(nodes) for the BFS, and O(eligible nodes) for quick select.
He did not seem convinced that my time complexity analysis for quick select was correct, he seemed a little confused. He asked me if I was sure it was linear, and I said I was.
Thinking about it now, I'm worried. Could this affect my chances? Should I have used a heap instead, since it was more straight-forward, albeit less efficient?
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: Bangalore
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
I was asked a tree traversal + top K elements question disguised in a story. Essentially, traverse the tree to find "eligible" nodes, based on some condition, and then, return the top 10 "eligible" nodes based on their size.
I wrote a BFS algorithm for tree traversal + quick select to retrieve top K elements.
When asked about time complexity, I said that it would be O(nodes) for the BFS, and O(eligible nodes) for quick select.
He did not seem convinced that my time complexity analysis for quick select was correct, he seemed a little confused. He asked me if I was sure it was linear, and I said I was.
Thinking about it now, I'm worried. Could this affect my chances? Should I have used a heap instead, since it was more straight-forward, albeit less efficient?