Data structures Interview Questions | Glassdoor

Data structures Interview Questions

2,291

interview questions shared by candidates

Data structures Interview Questions

Sort: RelevancePopular Date

Find the second largest element in a Binary Search Tree

16 Answers

find the right most element. If this is a right node with no children, return its parent. if this is not, return the largest element of its left child.

One addition is the situation where the tree has no right branch (root is largest). In this special case, it does not have a parent. So it's better to keep track of parent and current pointers, if different, the original method by the candidate works well, if the same (which means the root situation), find the largest of its left branch.

if (root == null || (!root.hasRightChild() ) { return null;} else return findSecondGreatest(root, root.getValue()); value findSecondGreatest(Node curr, value oldValue) { if(curr.hasRightChild()) { return (findSecondGreatest( curr.getRightChild(), curr.value)); } else return oldValue; }

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Write an algorithm to determine if 2 linked lists intersect

15 Answers

Given a string find the first non-repeated character.

13 Answers

Traverse nodes in a binary tree

11 Answers

Print a singly-linked list backwards, in constant space and linear time.

10 Answers

Two people are each stuck on their own island, connected by a ferryman with a lockable box. Each person has their own lock and key, but can't send the key along with the box. One person wants to send the other a diamond, but it must be placed into the box and locked or it will be stolen by the ferryman. How do you send the diamond without the ferryman stealing it?

10 Answers

1. Take an integer input and output the number of 1's in it's binary representation. 2. Implement a mergesort. 3. Explain your level of understanding of data structures (trees, etc.) 4. What makes java different than other languages?

9 Answers

You are given an array with n positive integers where all values in the array are repeated except for one. Return the one that is not repeated.

13 Answers

Implement a function to validate whether a given binary tree is a BST (i.e. write an isBST() function).

9 Answers

If 70% of Facebook users on iOS use Instagram, but only 35% of Facebook users on Android use Instagram, how would you investigate the discrepancy?

9 Answers
110 of 2,291 Interview Questions