Data Structure interview questions – page 20
893 questions. Tap “Show answer” to check yourself.
-
Consider a representation to store a binary tree in a file in which the whole tree is represented within two brackets in the following format. First print the root in brackets, and then within those brackets print the left subtree in its own brack...
-
How to insert and delete a node in a sorted linked list?
-
You have been given a Two Dimensional Array and One Dimensional Array.. You have to return true if 2D array consists of given 1D Array 2D array Consists of 1D array means all the elements of 1d are present contiguously in left side, right side...
-
Given a binary tree and node print all the ancestors of that node. ex. -------1 ---4--------5 2----3---7-----8
-
Print level order traversal of a tree. The last level should be printed first then next .. and so on.
-
Given two linked lists, write a function to check if the two lists are identical or not.
-
There is a doubly linked list with next pointer and arbitrary pointer( points to an arbitrary node in list). You have to make a copy of the linked list and return. In the end original list shouldn't be modified. Best time O(n).
-
Reverse a linked list, with and without recursion.
-
Given 2 trees T1(very big) ,T2(small), check if T2 is a subtree of T1 i.e exact structure and node key values of T2 should appear as a subtree in T1.
-
Given a BST, a number s and a group of numbers g, check whether all the elements of g occur in the same path,all elements sum upto s without including root and the leaf
-
Consider the given structure:
-
A 2D array is such that each row in it is in ascending order and each column is in ascending order. How will you search for an element in this array? (O(n) is enough)
- Advertisement
-
You have a linked list of unknown length n. there is an element which is repeated more than n/2 number of times. find that element... you should use constant extra space and can make only one pass over the list.....
-
Write a C code to merge 2 binary search trees and do the same to merge linked lists. How is the previous different when in comparison to the later on.(Go over the problems)
-
Given string input1, input2, remove wherever the occurrence of input2 in input1. e.g: input1: skjthshetheshetesm input2: she input1 will become "skjththetesm" Give the test cases.
-
Given a string in hex, convert it into int. Write test cases for the same.
-
What is the difference between following two statements?
-
Insert an element in a linked list at the end , given the start pointer.
-
Implementation and test cases for compare(string str1, string str2)
-
Define a data structure , using extra memory/space , such that :
-
You have a file in which each line contains some words. The file has millions of words in it two words are assumed to be same if they consist of same characters and same no of time. eg- abc ,acb, cab. Now write a program to remove all the duplicat...
-
Given a complete binary search tree in a array. Write a sort function to sort the array in O(n) time-complexity and at constant memory.
-
Given a binary search tree, find two nodes whose sum is K
-
How to store costs for these considering combinations in most efficient manner:
- Advertisement
-
Given 2 string A ,B. write a code to find all character of A exists in B or not?
-
Program to find width of a binary tree.
-
Given an array of positive real numbers, find out the longest consecutive sub-array such that the product of the numbers in the sub-array is maximized.
-
You have been given pointers of 2 nodes A and B inside a Binary Search Tree. If the nodes A's and B's common ancestor is P,then--
-
Suppose you are passing a string to a Formatter function. Get the formatted news feed output string such that
-
Given a single linked list of integers, write a function to find the 2nd largest element from the list in linear time without extra space. Test for all the test cases.