Interview Question - Find top three horses :
You are given five race tracks and twenty five horses.Find the minimum number of races you need to organize to find the fastest three horses. Here five race tracks means that only five horses can run at a time.
Solution
The trick to approach these type of probelm is to consider the corner cases, most of the times what seems obvious is not what is true.
Lets name the five tracks as
T1 , T2, T3 , T4 , T5
and we organize five races in the beginning Let us say that we have the horses named from A - Y.
Lets organize the below races on the ...

Read More
# Interview Questions

This category contains few tricky questions asked in interviews..

## Easy way to understand quick sort

Introduction
This article touches in detail all the aspects of a quick sort algorithm. I tried to write it as simple as possible to make it an easy way to understand quick sort. This is really an interesting algorithm to learn and I have found that most of the students or professionals feel it hard to understand or re-produce in code.
Problem Statement
You are given an array A[a1,a2,a3, . . . . . . , an] having elements in a random order and we need to re-produce the array A[b1, b2, b3, . . . . , bn] where b1 < b2 < b3 < b4 < . . . < bn .
Basic idea behind quick sort
The ba...

Read More
## Code to find Permutation of Numbers

Introduction
The article is about writing a Code to find permutation of numbers, the program prints all possible permutations of a given list or array of numbers. I have this question listed on my Stackoverflow.com account as well. To know the opinions of other people on the same and to find out other ways to solve the problem, please visit the link
Also, you might be interested in the code for Combinations. Find it here
Problem Statement
Given a list of numbers, print the possible permutations. The program must also be able to print P(n,r) where N and r can be input parameters.
Before ...

Read More
## Merging two Sorted Singly Linked List

Introduction - Merging two Sorted Singly Linked List
This question is mostly asked in interviews and hence I thought of writing few possible solutions to the same. I also asked the same question on stackoverflow.com. You can visit the link here
Problem Statement
You have two singly linked lists that are already sorted, you have to merge them and return the head of the new list without creating any new extra nodes. The returned list should be sorted as well
The method signature is:
[crayon-5a18b2632a6db295611090/]
Node class is below:
[crayon-5a18b2632a6e4253681946/]
Solution
There c...

Read More