Data Structure interview questions – page 17

893 questions. Tap “Show answer” to check yourself.

Advertisement
  1. Given a binary tree and a number N, check is there any path exists in the tree such sum of the nodes in the path equals to N.

  2. Design a system to manage clock room ( used at railway station). Like what data structure, how ? I gave O(1) time solution + small space complexity.

  3. You are given N documents(possibly in millions) with words in them. design datastructures such that the following scenarios take optimal time:

  4. No of leaf and non leaf nodes in a binary tree tree of depth k..

  5. Write code to print all the possible combinations of the words in a string? Example:

  6. Suggest data structures you would use for snake & ladder game?

  7. What's the max look up time for a binary tree?

  8. An n-ary tree has n nodes in each internal nodes. Find the no of leaf nodes in such a tree with N nodes?

  9. Level by level connect nodes a tree.

  10. Convert Doubly Linked list In to simple Binary Tree

  11. Two singly linked, sorted (by ascending order) lists l1, l2. Write a recursive function that returns the intersection of these two lists. For the resulting list you have to use elements of the two lists only and no extra memory. All extra nodes sh...

  12. Convert a given binary search tree to circular linked list.

  13. Advertisement
  14. Find the substring of length 3 which is present in the reverse order from the string. Ex: if the string is abcdcba (cba is the reverse of abc) so we should return cba. And was asked to improve upon the complexity.

  15. Given a binary tree, find a path which sum to a given target. the path can start from node, go to the left subtree and also to the right subtree...

  16. How would you reverse a doubly-linked list?

  17. Given an array with positive and negative integers and an integer k, find the subarray(consecutive) whose sum is k. This is different from subset sum problem.

  18. How to find last unique character in a given string? Unique character means non-repeated number. Give an optimized way.

  19. Given a binary tree. Find the max sub-tree (having max no of nodes) that form BST in this binary tree.

  20. Write a function that deletes consecutive identical character sets of size 1, 2, 3. For example if aabbabc is given as input after first iteration, it should be ababc and after that it should become abc. if aabbcabc is given it should give abcabc ...

  21. Function to delete a node in a circular linked list. Your code should handle all the cases.

  22. You are given two unsorted linked lists, get their union. Eg. a) 1->9->9->5->7->8->9->7 b) 44->33->1->9->55

  23. Implement class Stack using a linked list

  24. The inorder representation of a tree 41523 and preorder is 211513, draw it.

  25. Why linklist is preffered over Array ?

  26. Advertisement
  27. Boolean tree problem?

  28. Write a function that takes two strings as parameters and returns true if they anagram of each other.

  29. Convert tree to a multi linked list structure like below.

  30. Max and avg. height of binary tree?

  31. Given any integer . u have to write the hexadecimal form of the number in string without using sprintf()

  32. We want to implement the functions allocstring, freestring, concatestring, and stringlength. We need to optimize the functions in this order : stringlength, allocstring, freestring, concatestring, with stringlength requiring the most optimizations...

Advertisement