Algorithm Interview Questions And Answers

Algorithm Interview Questions list for experienced

  1. How to find middle element of linked list in one pass?
  2. How to find if linked list has loop ?
  3. How to find 3rd element from end in a linked list in one pass? How to find 3rd element from end in a linked list in one pass?
  4. In an integer array, there is 1 to 100 number, out of one is duplicate, how to find ?
  5. How to reverse String in Java ?
  6. What is the most efficient/elegant way to parse a flat table into a tree?
  7. How to count the number of set bits in a 32-bit integer?
  8. Is using Random and OrderBy a good shuffle algorithm?
  9. How to find the kth largest element in an unsorted array of length n in O(n)?
  10. What\'s the Hi/Lo algorithm?
  11. Ukkonen\'s suffix tree algorithm in plain English?
  12. How to code a URL shortener?
  13. How to check if a number is a power of 2?
  14. How does the Google "Did you mean?" Algorithm work?
  15. How to determine a point in a triangle?
  16. How do you rotate a two dimensional array?
  17. Circle line-segment collision detection algorithm?
  18. How to find the kth smallest element in the union of two sorted arrays?
  19. Algorithm to select a single, random combination of values?
  20. What algorithm gives suggestions in a spell checker?
  21. What\'s a good rate limiting algorithm?
  22. Algorithm to generate all possible permutations of a list?

Algorithm interview questions and answers on advance and basic Algorithm with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Algorithm also add your Questions if any you have to ask and for apply in Algorithm Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.

Top Algorithm interview questions and answers for freshers and experienced

What is Algorithm ?

Answer :

Questions : 1 :: How to find middle element of linked list in one pass?

One of the most popular question from data structures and algorithm, mostly asked on telephonic interview. Since many programmer know that, in order to find length of linked list we need to first...View answers

Questions : 2 :: How to find if linked list has loop ?

This question has bit of similarity with earlier algorithm and data structure interview question. I mean we can use two pointer approach to solve this problem. If we maintain two pointers, and we...View answers

Questions : 3 :: How to find 3rd element from end in a linked list in one pass? How to find 3rd element from end in a linked list in one pass?


This is another frequently asked linked list interview question. This question is exactly similar to finding middle element of linked list in single pass. If we apply same trick of maintaining two...View answers

Questions : 4 :: In an integer array, there is 1 to 100 number, out of one is duplicate, how to find ?

This is a rather simple data structures question, especially for this kind of. In this case you can simply add all numbers stored in array, and total sum should be equal to n(n+1)/2. Now just...View answers

Questions : 5 :: How to reverse String in Java ?

This is one of my favorite question. Since String is one of the most important type in programming, you expect lot of question related to String any data structure interview. There are many ways to...View answers

Questions : 6 :: What is the most efficient/elegant way to parse a flat table into a tree?


There are several ways to store tree-structured data in a relational database. What you show in your example uses two methods: Adjacency List (the "parent" column) and Path Enumeration (the...View answers

Questions : 7 :: How to count the number of set bits in a 32-bit integer?

This is known as the 'Hamming Weight', 'popcount' or 'sideways addition'. The 'best' algorithm really depends on which CPU you are on and what your usage pattern is. Some CPUs have a single...View answers

Questions : 8 :: Is using Random and OrderBy a good shuffle algorithm?

It's not a way of shuffling that I like, mostly on the grounds that it's O(n log n) for no good reason when it's easy to implement an O(n) shuffle. The code in the question "works" by basically...View answers

Questions : 9 :: How to find the kth largest element in an unsorted array of length n in O(n)?


This is called finding the k-th order statistic. There's a very simple randomized algorithm (called quickselect) taking O(n) average time, and a pretty complicated non-randomized algorithm taking...View answers

Questions : 10 :: What's the Hi/Lo algorithm?

The basic idea is that you have two numbers to make up a primary key- a "high" number and a "low" number. A client can basically increment the "high" sequence, knowing that it can then safely...View answers

Questions : 11 :: Ukkonen's suffix tree algorithm in plain English?

The following is an attempt to describe the Ukkonen algorithm by first showing what it does when the string is simple (i.e. does not contain any repeated characters), and then extending it to the...View answers

Questions : 12 :: How to code a URL shortener?

Theoretical background You need a Bijective Function f. This is necessary so that you can find a inverse function g('abc') = 123 for your f(123) = 'abc' function. This means: There must be no...View answers

Questions : 13 :: How to check if a number is a power of 2?

There's a simple trick for this problem: bool IsPowerOfTwo(ulong x){return(x &(x -1))==0;} For completeness, zero is not a power of two. If you want to take into account that edge case,...View answers

Questions : 14 :: How does the Google "Did you mean?" Algorithm work?

Here's the explanation directly from the source ( almost ) Search 101! at min 22:03 Worth watching! Basically and according to Douglas Merrill former CTO of Google it is like this: 1) You write...View answers

Questions : 15 :: How to determine a point in a triangle?

And here's some code to get you started: float sign (fPoint p1, fPoint p2, fPoint p3){return(p1.x - p3.x)*(p2.y - p3.y)-(p2.x - p3.x)*(p1.y - p3.y);}boolPointInTriangle(fPoint pt, fPoint v1, fPoint...View answers

Questions : 16 :: How do you rotate a two dimensional array?

Here it is in C# int[,] array =newint[4,4]{{1,2,3,4},{5,6,7,8},{9,0,1,2},{3,4,5,6}};int[,] rotated =RotateMatrix(array,4);staticint[,]RotateMatrix(int[,] matrix,int n){int[,] ret =newint[n,...View answers

Questions : 17 :: Circle line-segment collision detection algorithm?

Taking E is the starting point of the ray, L is the end point of the ray, C is the center of sphere you're testing against r is the radius of that sphere Compute: d = L - E ( Direction...View answers

Questions : 18 :: How to find the kth smallest element in the union of two sorted arrays?

To simplify a bit I'll assume that N and M are > k, so the complexity here is O(log k), which is O(log N + log M). Pseudo-code: i = k/2 j = k - i step = k/4 while step > 0 if a[i-1]...View answers

Questions : 19 :: Algorithm to select a single, random combination of values?

  Robert Floyd invented a sampling algorithm for just such situations. It's generally superior to shuffling then grabbing the first x elements. As originally written it assumes...View answers

Questions : 20 :: What algorithm gives suggestions in a spell checker?

132 down vote accepted There is good essay by Peter Norvig how to implement a spelling corrector. It's basicly a brute force approach trying candidate strings with a given edit...View answers

Questions : 21 :: What's a good rate limiting algorithm?

Here the simplest algorithm, if you want just to drop messages when they arrive too quickly (instead of queuing them, which makes sense because the queue might get arbitrarily large): rate =5.0;//...View answers

Questions : 22 :: Algorithm to generate all possible permutations of a list?

Basically, for each element from left to right, you generate all the permutations of the remaining elements. You can do this recursively, (or iteratively if you like pain) until you get to the last...View answers
More Question

Ask your interview questions on Algorithm

Write Your comment or Questions if you want the answers on Algorithm from Algorithm Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---