Interview questions

Algorithm interview questions – page 9

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

  1. Given numbers a1, a2, a3, a4, ...,an and operators +, *, -. Parentheses are available. Can an appropriate combination of the variables and operators result into K. Report such a combination or infeasibility.

  2. Reverse n-Ary Tree and Return List of Leaf Nodes as Output

  3. Name one sorting algo that performs worse than o(n^2) (in best or avg, worst

  4. Write Expression Evaluator (2*3 ^ 7 etc),

  5. Given An unsorted Array of non-negative integers

  6. Given an XML of the form -

  7. Write an algorithm finding the no.of one bits from 1 to n,for given any n value. complexity should be good example: 1=1 2=10 3=11 4=100 5=101 6=110 . . if n=3 then ur answer is 4<br...

  8. Write Efficient Program to Implement the Radix Sort whats Complexity of algo , minimize it..why its not used so freq., t5ell the some scenarios where this sort play important roles e.g application

  9. What is Dijkstra algorithm? Write the Pseudo code for it? If there are V vertices and E edge,what is the average and worst case complexity to react from one node to another node in case of directed graph?

  10. How Generic Swap of two elements can be implemented? that supports all type line int char float double etc..

  11. F(1) = 1. F(2n) = F(n) and F(2n+1) = F(n) + F(n+1). Develop recursive program.

  12. You are given n no. of lines in form of Ax + By = C, basically you are given A[i], b[i] and C[i] for line "i". Lines are given in a way such that 0 <= x[i] <= 1 and y[i] < y[i+1] for same X. Also, one point (x,y) is given too...

  13. Given a dictionary find out if given word can be made by two words in dictionary. For eg. given "newspaper" you have to find if it can be made by two words. (news and paper in this case)

  14. Given an array of n integers. each integer is in the range of 0 to m-1. and m > n.

  15. Given an array in which elements are unsorted. Write an algorithm that gives two indices n1,n2 such that if you sort just the elements of the array from n1 to n2, then the whole array will be sorted.

  16. Write complete working code (only the function) to check whether the given char sequence is valid.

  17. How to find the top search requests in Google, assuming that you could use 10000 computer in parallel?

  18. Write node structure of B & B+Tree Tree asked about application & clean code for structure for both Tree

  19. 1<=i,j,k<=300. Find (i,j,k) pairs such that their sum is divisible by 3. (2,2,1) and (2,1,2) are counted as different.

  20. You are given some 1000000 numbers in the range of 1 to 1000000000 not in any sorted order.The given numbers are random. You need to eliminate the duplicates in the given set of numbers. Consider for optimized solution

  21. Given a number, convert it to minimal sum of squares.

  22. What is a daemon and what are the steps to be followed for creating a daemon

  23. Is there any algorithm to find distance between each pair of point among n points whose time complexity is better than O(n^2) i.e. C(n,2).

  24. You are given an array of size n of positive and negative numbers. Also given another number k. U have to find whether the sum of any two of the numbers from the array is equal to k in O(n) time.

  25. Given an array of positive and negative numbers, find 3 numbers whose sum is 0. The array contains atleast 3 numbers.

  26. How do you build address bar in say gmail. i.e. if you press 'r' then you get all emails starting from 'r', and if you press 'ra' then you will get emails starting from 'ra'.

  27. Discuss traveling salesman problem

  28. Write a diff function (highlight the 'diff' between two strings)

  29. We have a webite with 5 Webpages {A,B,C,D,E}. Whenever a user accesses the website, the application logs an entry in the access_log file. For example: user user1@amazon.com accesses Page A at Time T0, Page B at Time T10 and Page C at time T1...

  30. Given a set of n integers and an integer x. Check whether k integers add up to X in the given set. The complexity should be O(n^(k-1) * logn)

Companies that ask Algorithm questions