Data Structure interview questions – page 16
893 questions. Tap “Show answer” to check yourself.
-
Given a Binary Search Tree, write a function that returns the kth smallest element without using any static/global variable. You cant pass the value k to any function also.
-
You are given a tree with the root and three nodes X, Y and Z. Write a function that returns true if Y lies in a path from X to Z, otherwise returns false.
-
Find the level of a tree at which there are max no of nodes!!!
-
Given a binary tree, programmatically you need to prove it is a binary search tree.
-
You are given a pointer to a node of a min heap. The value of this node changes. Write a function that fixes the min heap.
-
You hve 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.....
-
Given an integer array A[], what preprocessing you need to do so that when given i and j such that i <= j, you can tell in O(1) time the number of elements in the array having values between and including i and j.
-
Do inorder walk through binary tree. Store its path in an array as follows: .......For ith move, ............a) If move is left, put a 0 in an array[ i] ............b) If move is right, put a 1 in an array[ i]
-
Assume that a full binary search tree is represented in an array with the heap like structure, (ie) A[i]'s left child is stored in A[2i) and the right child is in A(2i + 1]. Given an index 'i' return the index of the inorder successor of the eleme...
-
The numbers are represented in linked-list with each node representing a digit of the number as follows: 123 == 1 2 3 NULL, 999 == 9 9 9 NULL
-
Given an IP address as input, validate the IP address.
-
Here is the prototype of a function
- Advertisement
-
Construct tree from the given ancestor matrix, optimize your solution.
-
Structure of a node in a binary tree is
-
In a Binary Tree, you have two pointers in the parent for left and right child. You have to change the given binary tree such that you have pointer for first child and next sibling from a node.
-
How t find siblings in a Binary Search Tree?
-
Given a binary tree, find the sum of all horizontal levels of the tree, storing the values in a suitable data structure.
-
Write a recursive function to find a Given string is palindrome or not?
-
What will the following code snippet do, when is it passed the root of a binary tree ?
-
Each node in a given list has an additional link called random that can point to any node (can also be null). we need to make a clone of the list without using any additional space (need to allocate memory only for new nodes 1', 2', 3',...). Comp...
-
Given an array of n number, one number is repeated n/2 times. Find the number.
-
Write a class for finding next element in preorder traversal of a binary tree.
-
Given a linked list of the form, 1->2->3->4->5->6, convert it into the form 2->1->4->3->6->5. Note that the nodes need to be altered and not the data contained in them
-
Write a recursive function to convert a BST into sorted doubly linked list.
- Advertisement
-
What is the complexity of an algorithm to check whether a binary tree is symmetric or not. No need to check the data only the structure needs to be verified.
-
Write a program to print single digit and double digit numbers in words. Do not use switch statement.
-
Given Pre-Order of a Binary Tree. Construct the Binary Tree Using that order.?
-
Here is the prototype of a function StringC(char *str,int strlen);
-
You have all the English words with you. you would like to manage a dictionary so that you can look up when ever you have doubt. Which data structure would you like to use and why?
-
Find the second max number in a binary search tree