Data Structure interview questions – page 10

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

Advertisement
  1. How to Implement stack using priority queue?

  2. Design the data structures for an online book reader system ?

  3. Do a BFS in given binary tree do find whether the given element in the tree or not.

  4. How would you store 1 million phone numbers?

  5. Lets say you have 1 string of length N and M small strings of length L. How do you efficiently find the occurence of each small string in the big string ?

  6. Write a C program to convert a BST (Bin search tree) into DLL (Doubly Linked List) of increasing nodes values. The constraint is to write a recursive program, no other solution will be accepted.

  7. Merge two BSTs into a single BST. Do it in place.

  8. How to allocate memory to a string at run time and read character by character?

  9. Find the distance of a node from the root in a binary tree.Print error message if node doesn't exist. Extend the problem to distance of any node to any other node that is below it.

  10. Given an array that contains 0, 1 and 2 only, sort it.

  11. I/P: Binary tree. O/P: Single Linked List where each node is the sum of the nodes in the same level of the binary tree.

  12. Write Merge Sort

  13. Advertisement
  14. There is a web server containing several files every time a user logs in open a file and a entry is made for that file in the log file. log file contains file name that has been opened and time of opening the file, in a day thousands of users log...

  15. Write a program to find depth of binary search tree without using recursion.

  16. Swap adjacent nodes of given linked list using one pointer

  17. Given a single linked list, there is a possibility of pointer corruption, modify the data structure to ensure that the data is not lost.

  18. There is a binary tree(Not a BST) in which you are given three nodes x,y,z. Write a function which finds whether y lies in the path b/w x and z.

  19. Doublets is a word puzzle game invented by Lewis Carroll where the objective is to turn one dictionary word into another by changing one letter at a time. At each step, one letter may be changed, and the resulting word must be a valid dictionary w...

  20. You are given an unsorted array of integers. You have to find out the first sub array whose elements when added sum up to zero. eg:- int Array[] = {1,2,-4,-3, 6 ,-3.....}Here sub array is -3,6,-3 bcos adding all these sum to zero. A sub array can...

  21. Given preorder traversal of a Binary Search Tree. From the given options you have to select which one can possibly be the inorder traversal of the tree.

  22. Written-Qn-2) Write complete working code (only the function) to traverse a binary tree in ZigZag order.

  23. How to confirm that whether or not a given string in form of pZq , where p is a string and q is reverse of p and Z is a single character in O(n).Remember ,You may only fetch the next character of the given string.

  24. Inserting an element into a sorted linked list.

  25. You are given a binary tree where each node consists of a left pointer, a right pointer, and a sibling pointer. The left and right pointers are initially populated and the tree is a normal binary tree. He wanted a function to populate the sibling ...

  26. Advertisement
  27. Write code to find first non repeating character in given string

  28. Construct tree from given inorder and preorder traversals

  29. Find if one string is a rotation of another eg str1="abcdef" str2="defabc" return true

  30. Take input from console and print it in reverse way..... need to write test cases for this

  31. Your are given two strings A and B. Output true if all the character in string A are present in String B. The solution should be optimal in time and space. For egs.. A="ppppppppppaaaaaaaaaa" B="pa" Output = true

  32. Input is n strings.

Advertisement