## Binary Tree Sort in C

Binary Tree Sort uses a Binary search tree. The various steps involved in such a sort would be – Construct a binary tree with the given data (integers) such that all numbers to the left of a particular node say ‘nd’ is less than the number contained within the node and to the right, the numbers…

## Selection Sort

A Selection sorting technique uses a general algorithm which uses an ascending or descending priority queue. The idea would be to pre-process input array X[i] into the descending or ascending priority queues by the functions dpqinsert(dpq, x) or apqinsert(apq, x) respectively. Now, the next and final step would be to select data in appropriate order from…

## Quick Sort

The popular exchange sort mechanisms are Mean sort, Quick Sort and BSort and Quick sort is the most simple one. Quick sort is most applicable exchange sorting technique for practical applications since it uses relatively less time-space resources. Lets illustrate finding Order of a Quick sort algorithm in C. Lets start with the below list…

## Bubble Sort in C

Lets explain Bubble sort by illustrating tow specific examples involving steps where smaller numbers bubbles to first and when larger numbers bubbles to last. Number list to sort: 2   5   3   0   6   1 Case 1: Smaller numbers bubbles to first Step 1:    0  5  3  2  6  1 Step 2:   0  3  5  2 …

## Efficiency and Order of a Sorting Program

Efficiency Considerations The following are the efficiency considerations while planning for a sorting program / algorithm – Time required to code the program and the type of sorting technique to be selected Execution time Amount of space required by program In cases where the type of data to be sorted is known, it is easier…

## Recursive C program for Towers of Hanoi

Towers of Hanoi problem consists of 3 pegs A, B and C. Let n denote number of disks in peg A. The objective is to transfer these disks from A to C using B as auxiliary so that at a time only one disk is transferred and a larger one cannot reside on a smaller…

## Efficiency of Recursion

In general cases, a non-recursive program runs more efficiently than a recursive program since a recursive program requires more execution time to enter and exit from a function. Recursive programs flows directly from the definitions and are easy to implement while a corresponding non-recursive program may involve expensive use of stacks which are difficult to…