# Data structures Interview Questions

interview questions shared by candidates

## Data structures Interview Questions

Binary tree with parent pointers, given two nodes find common ancestor. |

Write a code for finding a certain element in an unsorted array assuming element definitely exists. How can we improve the efficiency? |

Write an algorithm that does an in-order traversal of a tree recursively. Now, write the same algorithm iteratively. |

How would you print last n elements of a linked list, n being small compared to size of linked list? |

Given an array of integers, all but one of which appears an even number of times, find the one integer which appears an odd number of times. |

Give me 5 different ways of finding the median (middle element) of a linked list. For the sake of simplicity, assume the list has odd number of ints. Also mention the runtime for each. Follow up: What's the fastest way you could find the median? What is the runtime? Oh.. and yes, code your answer(s) in any language of your preference. |

How would you implement a stack to achieve constant time for "push", "pop" and "find mininum" operations? |

1. Find common elements between two arrays of integers. 2. Find cycles in a graph. 3. Efficiently find duplicate elements in an array of numbers with bounded entries (for example, elements are between 0 and 99). 4. Reverse word sequence in a string inplace. 5. Efficiently find all Pythogorean triplets in a given array of integers. 6. Find all anagrams in a list of words. 7. Set operations. |

Create a Queue using two Stacks. |

3. Trees (binary and otherwise) form the basis of many common data structures. Please describe some of these data structures and when they might be used. |

**21**–

**30**of

**117**Interview Questions