Data Structure interview questions – page 6

893 questions. Tap “Show answer” to check yourself.

Advertisement
  1. 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...

  2. 1 > Sort the doubly linked list with out swaping the values

  3. Given an array of integers (can be both +ve or -ve), find the three integers which multiply to give the largest product.

  4. 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?

  5. Print a 2D matrix in spiral form

  6. 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 ...

  7. 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.

  8. 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?

  9. How to detect cycle in a directed graph?

  10. 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...

  11. Given a stream of numbers, suggest a data structure to store all distinct numbers and their counts.

  12. Round 2: 1. Removing duplicates in an array

  13. Advertisement
  14. 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).

  15. 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...

  16. 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...

  17. Efficiently find the number of reptitions of a given number x in a sorted array arr[].

  18. 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.

  19. Check for duplicates in an unsorted array in O(n) without using any extra space

  20. Array A[i...j] is given. you have to find out maximum j-i such that A[i]<A[j] in O(n) time.

  21. 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 )

  22. There are &#39;n&#39; sorted linked list with avg. &#39;k&#39; length, write an efficient function which return the head pointer of a single list which is the combination of all &#39;n&#39; list and in sorted order.(Avoid using extra space)

  23. 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)

  24. 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...

  25. What data structure you will use if you want to go to first record from the last and vice versa?

  26. Advertisement
  27. How to print nodes of a Linked List that has loop?

  28. Given a number, find 2 numbers in a matrix whose sum gives the number given in ......one pass of the array.

  29. Given an array of &#39;n&#39; numbers - find all the triplets that satisfy the condition "a + b = c"

  30. 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.

  31. 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

  32. Given an list of integers, write a method to output the list of integers which occured odd number of times in the input array.

Advertisement