This free book is an excellent tutorial book for beginners. It is a collection of notes and sample codes written by the author while he was learning sorting algorithms. Sorting makes it possible to search a particular data element in a collection quickly by applying the binary search technique.
Everyone knows what is the binary search technique? We are using it every time when we look up a word in a dictionary.
How much time we can save by using the binary search technique? Let’s do a rough calculation. Assume that we have a sorted dictionary and an un-sorted dictionary with the same collection of words printed on about 1000 pages.
Looking up a word in the un-sorted dictionary, the best case is that you found the word on the first page; the worst case is that you looked through all 1000 the pages, and found the word on the last page. So roughly the average time you spend is checking 500 pages.
Looking up a word in the sorted dictionary, the best case is that you found the word on the center page, which is the first page you will be checking based on the binary search technique; the worst case is that you found the word on the final page after you have divided the dictionary 10 times. So roughly the average time you spend is checking 5 pages.
The answer is obvious. We are saving about 99% of our time by using the sorted dictionary!
Table of Contents
- Sorting API in Java
- Insertion Sort
- Selection Sort
- Bubble Sort
- Merge Sort
- Heap Sort
- Shell Sort
Download Free PDF / Read Online
Link: Read online.