Data Structure interview questions – page 15
893 questions. Tap “Show answer” to check yourself.
-
3. Finding closest parent in a binary tree.
-
Write insert function for a binary search tree? Given constraint: 1. The insertion should be such that the tree remains balanced. 2. You can move any non-leaf/root node to be a leaf/non-root node.
-
Write a function that would: return the 5th element from the end in a singly linked list of integers, in one pass, and then provide a set of test cases against that function
-
There is an unsorted list of elements whose key values are different unique time stamps. For a given time stamp, find the 5 nearest above time stamps and 5 nearest below time stamps. What is the efficient algorithm to do this in O(n) compleity </p...
-
Find the longest palindrome in a given string ?
-
Longest Common Substring
-
Given a Binary Search Tree with many duplicates. Assume that while building the BST , the equal values are inserted in the left sub-tree. You just have the root pointer of the tree. Give an algorithm to delete the duplicate values. However t...
-
Given a complete binary search tree in form of array. Write a sort function to sort the given array in O(n)time complexity and constant memory. say the tree is
-
Reverse a string without using any temporary variable
-
Given a (Directed/Non Directed) graph and a source node and destination node . Find all the paths from a source node to the destination node. Both for directed and non-directed graph.
-
Write a code to reverse a linked list (both recursive and iterative)
-
You are given the address to the head of a single liked list and a random number generator (generates between 0-1). You have to return a node form the list randomly using the random number generator. The constraint is ...we have to tra...
- Advertisement
-
How will you implement tree in real life example.
-
Given two strings s1 and s2, s1 has some characters at the end which are same as some of s2's starting characters, so you have to concatenate the strings so that the repeated portion occurs only once.
-
Write a function that checks whether the tree is balanced or not. The balanced tree constraint is changed as ever pair of leaf nodes shouldn't have difference more than 1
-
Input : Two large singly linked lists representing numbers with most significant digit as head and least significant as last node.
-
Convert an decimal integer to binary string(10 marks)
-
Given some positive numbers output the numbers in decreasing order of frequency..in case of a tie print the number which occurs first
-
You are provided with a max heap of 'n' elements with a number 'x' and 'k'...You have to find whether 'k' elements in heap are greater than 'x' or not?? Time Complexity should be O(k)
-
Given two arrays, one is 1D array and other is 2D array. U need to find out whether 2D array contains the subset of 1D array. The elements of 1D array not neccessary present in the same row it can be either on the up or down but should be continu...
-
Code to get the max depth of binary tree - I used recursion - How would you do it without recursion?
-
Min and max nodes of a quad tree
-
You are given a maze filled with characters in which you can move either above or below or left or right. You have to search for words in this database
-
Write a fully functional C Function. Which when given a string containing numerals only. Returns a link list of those numerals. For e.g. If 1234 is given . Then return a link list such that 1-> 2-> 3-> 4 ->...
- Advertisement
-
Find the common elements of 2 given Binary Search Trees.
-
You have an array of random real numbers sorted in descending order. You want to divide the array in 2 halves such that sum of the upper half is equal to or as close as possible to sum of lower half.
-
You have to create a data structure for the following ... A MS paint like program is there and the user draws a closed curve object... ....a) Store the drawn object in ur data structure ....b) Later u have to draw this object aga...
-
Let a stack data structure supports getMax() Operation. We maintain "max" of the stack at any time. so that we can simply return this value whenever getMax() is called.
-
Find the lease common ancestor of two given nodes ( pointers ) in a tree. Before jumping to any conclusion .. its a k-ary tree. Not a BST Write the code. Test cases. And improve it too.
-
You are given a two dimensional array which has numbers.If there is a zero in any place, make all elements of that row and column as zeroes.