Data Structure interview questions – page 7

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

Advertisement
  1. Given an array with some repeating numbers, sort the array according to number of occurrences of characters.

  2. Write a function that takes an array of five integers, each of which is between 1 and 10, and returns the number of combination of those integers that sum to 15.... For example, calling the function with the array [1, 2, 3, 4, 5] should return 1, ...

  3. Space complexity of quick sort?

  4. Given two arrays A & B of length l, containing non negative integers, such that the sum of integers in A is the same as sum of integers in B.( The numbers need not be the same in both the arrays.)

  5. Suggest a data structure for finding median of a set. The data structure should also support efficient insertion and deletion.

  6. We have a database of books and the persons buying it. When a person buys a book, we have to suggest him the books bought by other owners of this book. If there r more than 5 books, return only top 5. Design data structure for this

  7. Maximum Sum of Sub Array in an Array.

  8. You are given an array with 'n' elements. Each element is in the range of 1 to n^2. Sort the array in O(n)..space complexity upto O(n) is fine in this problem.

  9. Code to find the maximum sum contiguous subarray in an array. Array cam have negative numbers also.

  10. You have given an array having alternative positive and negative number . you have to find out the longest subsequece having maximum sum.in the complexity o(n).

  11. Given an array of elements and a value, see that the sum of two elements of an array are equal to the value with minimum loop

  12. There is a parking lot with n slots.. and n-1 cars with 1 free slot. given an initial arrangement of cars how will u arrive at a desired arrangement E.g say n = 5 .initial..{free, 1, 3, 4, 2} ..required ..{1, free, 2, 4, 3}.. the numbe...

  13. Advertisement
  14. Given a link list of integers delete all nodes which have value smaller than the value of any following nodes for example:-

  15. Spiral printing of a matrix

  16. You are developing a component that requries parsing a lot of XML tags. You have abstracted the responsibility of finding the handler to a class named XMLElement Dictionary. Your will be invoking GetHandlerTag method of this class to find the corr...

  17. Implement Stack using Queues.................and Queues using stack

  18. Implement a stack using a queue.

  19. Given an array and find two numbers in the array having difference equal to given number. you are given that the array is sorted

  20. There is an Array with 0's 1's and 2's in some form.. in one pass arrange the array with ....0's in the first part of the array, then 1's and then 2's

  21. Given two sorted array and in the second array u have as many extra space as no of elements in first array. you have to sort the second array which will contain all the element from first array also. Do it in O(n) time complexity without using any...

  22. A code of bubble sort was given .. all the numbers r in ascending order initially ..the code was such that numbers would be in descending order. how many swapping possible?

  23. A mail server exposes an interface as mentioned below. When given a day in the calendar a user, it gets the meetings mentioned as slots in calendar with start and end time for each meeting.

  24. Write efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

  25. You are given an array of n+2 elements.. All elements of the array occur once between 1 and n except two numbers which occur twice.. Find the two repeating numbers in O(n)

  26. Advertisement
  27. Given an array such that the array will be sorted if we sort the elements between two indicies i an j. Find i and j for such an array such that abs(i-j) is minimum.

  28. There is a binary tree. You will need to find out if at any node it behaves as binary search tree if broken at that node in O(N) time complexity

  29. There is an integer array consisting positive numbers only. Find maximum possible sum of elements such that there are no 2 consecutive elements present in the sum.

  30. Insert a no. in sorted circular Linked List. The new no. must be inserted in sorted fashion.

  31. Let A and B be two arrays, each of size n. A and B contain numbers in sorted order. Give an O(log n) algorithm to find the median of the combined set of 2n numbers.

  32. You are given a Linklist, you have to rotate it in order 3.

Advertisement