Interview questions

Algorithm interview questions – page 23

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

  1. Write a program to evaluate the expression infix expression (

  2. How many vertices are required to obtain 1024 unique undirected graphs

  3. Find the longest increasing subsequence in an array in O(nlogn).

  4. Implement a lease and release mechanism. When the caller calls lease it returns the smallest available integer from a range. On release the number become available or leasing again. So for eg if 3 clients call lease thrice it would give 0, 1 and 2...

  5. Suggest a data structure and algo to implement T9 dictionaries. Your solution should be optimized for adding a new word.

  6. Come up with an optimal implementation for max() operation in a Stack.

  7. Given a snapshot of an ongoing chess game, which probably is a one vs many game, identify whether it is a valid game or not.

  8. Design (classes and class diagrams only) an object oriented Network Library that will facilitate.

  9. You have two arrays A and B of strings. In the array B all element are from A except one. ex: A = {"abc", "bcd", "dpr"}; B = {"abc", "mnp", "bcd", "dpr"}; You have find out the string which is extra in B in O(n) time. In the abov...

  10. Given k sorted arrays each of length n, construct a single merged and sorted array.focus on running time and space complexity

  11. You are given a list of strings. Find a way to combine and store them in such a way that it you can retrieve the original strings.

  12. Write a program in c to simulate process scheduling using queue data structure

  13. Given an array of integers... Imagine it as a pyramid as below:

  14. Find out the no. of vertices in a graph given the graph is: a) Undirected cyclic b) Directed Cyclic c) Undirected non cyclic d) Undirected non cyclic.

  15. Given all 26 characters, generate all strings of length 'n' which do not contain a given string as a substring.

  16. Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}'

  17. Given an array which contains elements from 1 to n. All numbers present once except following two exceptions: 1) one number is missing 2) one number occurs twice

  18. Suppose we can compare two arrays like: {4,2,3} > {3,5,6} {4,2,3} < {4,3,0}

  19. Function to display the directory structure in a user friendly way taking root dir as arg for a general OS. You may assume and state some basic APIs available in that OS

  20. Check Whether binary representation of number is palindrome or not example

  21. Giving a Grid in 2D array like this where each cell has a cost from 1-9

  22. Write an algorithm to create the mirror image of a binary tree

  23. Given a very big file of words, a word in each line, sort the words. Please provide the algorithm and explanation .

  24. Write a function that divides two numbers without using division operator.

  25. 5. You have two threads T1 and T2 they are reader and writer respectively. With some specification: ADDNEW.Process PROCESS.SET PROCESS.RESET ENTER CS EXIT CS LOOP EXIT LOOP WAIT# PROCESS

  26. Design a data structure to provide the mathematical operations +, - ,/ , * etc for the very very large numbers. Also, implement the + function for two such very very large numbers ...say numbers with 1 Million digits.

  27. Find all pairs in array such that a+b=x, a != b. you have to specify all space and time complexities...fairly standard problem-

  28. Given a million 3D points, how will you find the 10 closest to the origin?

  29. An efficient method to count the number of occurrences of a number in a sorted array

  30. Recursive Fibbonacci ...

Companies that ask Algorithm questions