Data Structure interview questions – page 8
893 questions. Tap “Show answer” to check yourself.
-
Given an array-based heap on n elements and a real number x, efficiently determine whether the kth smallest element in the heap is greater than or equal to x. Your algorithm should be O(k) in the worst-case, independent of the size of the heap. </...
-
Let E:dir1dir2....dir3page.html be the file required. Here .. tells us that we should move one directory to the back.So the final output should be E:dir3page.html. So write code for this covering all end conditions and d...
-
Given a stream of numbers, design a data structure to store the numbers in the stream along with their no. of occurrences
-
A) Design a data structure to store an arbitrarily large number b) How will you use it to store two such number and add them. c) Write down the class (code) for the data structure.
-
Given two sorted arrays A and B. i)Find the intersection of these arrays A and B. ii)If array A is small and array B is too large, then how would you do it?
-
Convert sorted doubly link list ->BST
-
Implement queue using stacks
-
Given a 2D square matrix where all columns and rows are sorted in increasing order. Write an efficient method to count negative numbers
-
Write a code for copying a given linked list, containing two pointers next and random ( random can point to any node).
-
Suppose you want to implement an ADT on a set of integers S with the following operations: insert (k ) - Places k into S extract min(S ) - Removes the smallest element from S extract max(S ) - Removes the largest elem...
-
Algo/data structure for memory manager.
-
Given an integer array. e.g. 1,2,3,4,5 Compute array containing elements 120,60,40,30,24 (2*3*4*5,1*3*4*5, 1*2*4*5, 1*2*3*5, 1*2*3*4) So I gave simple solution using division operator. He said that what if there is a 0 as a...
- Advertisement
-
U r given an integer array of size n, filled with numbers 1 to n randomly. Each number occurs exactly once. Two of them are replaced by 0(zero). Find out those numbers in O(n) time.
-
What data structure would you use to store distances between all the planets in a galaxy. (So there could be like a billion planets)
-
Given an array 1 to N, how many permutations of it will be Min Heap of of N! possible permutations
-
You are given an unordered sequence of n integers with many duplications, such that the number of distinct integers in the sequence is O(log n). Design a sorting algorithm and its necessary data structure(s), which can sort the sequence using at m...
-
Given n points of structure
-
Design a data structure that supports integer of unlimited size.Assume that you have unlimited memory. Implement functions to support addition and subtraction.
-
Given a linked list of 1->6->3->9->7->54, and a number 'n'. You need to insert 0 after every nth element in the list. For example if n = 2, then output: 1->6->0->3->9->0->7->54->0.
-
Pointer to head node of a linked list is given, reverse the first two nodes of the list.
-
Given an array of integers, for each index i, you have to swap the value at i with the first value smaller than A[ i ] that comes after index i
-
Given a double linked list and the node values range from 1 to 3.It may contain any number of nodes ,sort the list.
-
Given two linked list. We have to find that whether the data in one is reverse that of data in other. No extra space is to be used and traverse the lists only once
-
Write code for a method that takes two arrays s arguments and returns true if one array is subarray of the other array, otherwise returns false.
- Advertisement
-
Given two strings, program to find if one string is cyclic form of the other.
-
In a given array int num[10] ={1,-5,6,7,9,9,20,25,31,45} it is a sorted array. write a function void findsum(int [],int x) int [] is array and x is number. function should print all possible pair of elements in array that can make a sum equal to x...
-
Given a binary search tree. Write a function which takes any given node from the binary tree and a number. Function has to return the next higher number of the given number from the binary search tree.
-
Given a string str1, find if another string str2 is circularly shifted version of str1. i.e if str1 is "abcd" then str2 can be "abcd", "bcda", "cdab", "dabc"
-
A special type of tree is given, where all leaf are marked with L and others are marked with N. every node can have 0 or at most 2 nodes. Trees preorder traversal is given give a algorithm to build tree from this traversal.
-
A data structure is required for storing a set of integers such that each of the following operations can be done in (log n) time, where n is the number of elements in the set.