Data Structure interview questions – page 6
893 questions. Tap “Show answer” to check yourself.
-
Implement the "underlying data strucutre" for bounded buffer such that. 1a) Push, pop should be O(1). Write code for push, pop 1b) How will you detect [underlying data structure] IsFull, IsEmpty without maintaining bool data member. [d...
-
1 > Sort the doubly linked list with out swaping the values
-
Given an array of integers (can be both +ve or -ve), find the three integers which multiply to give the largest product.
-
How could a linked list and a hash table be combined to allow someone to run through the list from item to item while still maintaining the ability to access an individual element in O(1) time?
-
Print a 2D matrix in spiral form
-
There are n consecutive shops. two mafias plan to rob the shops. Each shop has cash in their locker. there is one restriction that they cannot rob any consecutive shop. write a program that will maximize their profit. cash in the shops were given ...
-
Given one n size array which is filled with only two no. You have to find out which no. occurs more. Do it using minimum number of comparisons.
-
In the given linked list, odd numbered nodes are in increasing order and even numbered nodes are in decreasing order. How it can be sorted in increasing order?
-
How to detect cycle in a directed graph?
-
There is an array containing R, G, B. Write a program to get all the R's, G's & B's together. For example: i/p: RGBBBGGRRGB;;;;;o/p:RRRBBBBGGGG....it was a simple one....but frnds u need to go for just 1 pass & use least space to earn poin...
-
Given a stream of numbers, suggest a data structure to store all distinct numbers and their counts.
-
Round 2: 1. Removing duplicates in an array
- Advertisement
-
Given an array of size n, find all the possible sub set of the array of size k(all the subsets must be of size k).
-
Given 3 sorted arrays (in ascending order). Let the arrays be A(of n1 length), B(of n2 length), C(of n3 length). Let x be an element of A, y of B, z of C. The distance between x, y and z is defined as the max(|x-y|,|y-z|,|z-x|). Find the tuple w...
-
Find longest interval We are given with two arrays A and B..each of size N...elements of array contains either 1 or 0... we have to find such an interval (p,q)(inclusive) such that the sum of all the elements of A (between this interva...
-
Efficiently find the number of reptitions of a given number x in a sorted array arr[].
-
You are given with three sorted arrays (in ascending order), you are required to find a triplet ( one element from each array) such that distance is minimum.
-
Check for duplicates in an unsorted array in O(n) without using any extra space
-
Array A[i...j] is given. you have to find out maximum j-i such that A[i]<A[j] in O(n) time.
-
GIven an array , find the length of largest sub-sequence such that if the minimum value in this sub-sequence in Min and maximum value is Max then the elements of this sub-sequence should be Min,Min+1,Min+2,..,Max ( in any order )
-
There are 'n' sorted linked list with avg. 'k' length, write an efficient function which return the head pointer of a single list which is the combination of all 'n' list and in sorted order.(Avoid using extra space)
-
Given an integer array. { 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)
-
Design a data structure that can be used instead of an array and avoids the "high-cost" (i.e. O(n)) of initializing the array. the data structure ought to holds n items and supports the following operations in O(1) time: * Init Initializ...
-
What data structure you will use if you want to go to first record from the last and vice versa?
- Advertisement
-
How to print nodes of a Linked List that has loop?
-
Given a number, find 2 numbers in a matrix whose sum gives the number given in ......one pass of the array.
-
Given an array of 'n' numbers - find all the triplets that satisfy the condition "a + b = c"
-
There is an array of some no only 0-9. You have to divide it into two array such that sum of elements in each array is same.
-
If the result of 3+2*4/2 is 10, what is the operator precedence? a) *, /, + b) /, *, + c) +, *, / d) Left to right e) both (c) and (d) above
-
Given an list of integers, write a method to output the list of integers which occured odd number of times in the input array.