Data Structure interview questions – page 9

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

Advertisement
  1. A strict k-ary tree is a tree where each node has either 0 or k children. Assume there is no info in the nodes; we're interested only in the tree structure. A DFS search (think preorder traversal) of such a tree generates a string where each node ...

  2. How do you determine two strings are anagram. The algo should be better than (nlogn) and should consider the wide characters also.

  3. Print the last "k" elements in a singly-linked list.

  4. Write A Program to Remove Duplicates from BST remember its BST not Binary Tree...He Asked me to write neat & Clean Code fro this so try to code your best

  5. Given a linked list structure where every node represents a linked list and contains two pointers of its type: (i) pointer to next node in the main list. (ii) pointer to a linked list where this node is head.

  6. Given a string find the number of distinct substrings of the string. ex: input-> aaaa output-> 4(a, aa, aaa, aaaa) input->abcd output->10(a, b, c, d, ab, bc, cd, abc, bcd, abcd)

  7. Write a function to print first repeated substring in a string. a) with overlap (the second string might overlap with the first) b) without overlap.

  8. Reverse the string word by word e.g. "My name is pradeep" .. o/p shd be "pradeep is name My" ...intwer expecting a 1 traversal algo

  9. You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.

  10. Given a string of the form a2b3 produce the string aabbb from it

  11. Merge two linklist without using any extra space...

  12. Write A program for Decode the String Compressed Using Run Length Encoding (RLE) Algorithm

  13. Advertisement
  14. Given a string, first remove all repeated consecutive substring with length 1, then delete substring of length 2 and so on... Example : string is abcabeccced

  15. In a binary max heap containing n numbers, the smallest element can be found in time ??

  16. Given two strings a and b. Length of b is much smaller than a. Check if a contains an anagram of b

  17. Given a linked list, remove all the nodes which have a greater value on right side.

  18. How would you implement a map (not a map of like a city... just a set of keys which "map" to values") - Give two data structures you could use - What is average and worst case insert time, delete time, look up time - What are pro...

  19. How do you delete duplicate elements from an unsorted array in place(no extra space) Try to do it in time less than O(nlogn)

  20. Given two strings find the combination of strings which can be interleave i/p: if "AB" and "CD" are two strings o/p: ABCD ACBD ACDB ACBD CABD CDAB

  21. What is a circular queue? Why is it better than a normal queue? and Give some practical Examples of usage of circular queue

  22. In a ternary tree which has three childs for every node, if the number of internal nodes are N then the total number of leaf nodes are

  23. Convert a tree into its mirror without using extra memory - O(1) space .

  24. Given a input text file, write a program to print the output as follows:

  25. Find all the anagrams of a given word in the least amount of time. You are provided a dictionary which u can preprocess in any way.

  26. Advertisement
  27. AVL tree vs Red Black Tree

  28. Write a program to convert binary tree in to doubly linked list such that doubly linked list represents the spiral order of given tree using recursion, Inplace(no Extra Space except recursion memory stack)

  29. Given a linked list, write a function to reverse every k nodes (where k is an input to the function). Eg. input 1->2->3->4->5->6->7->8->NULL output for k=3 should be 3->2->1->6->5->4->8->7->NULL. </p...

  30. Merge 2 sorted linked list.

  31. A function to get the longest path in a given binary tree.

  32. Given a root and a node of a binary tree, write a function which finds all the nodes which are a &#39;k&#39; distance from the give node. (distance can be upwards and downwards)

Advertisement