https://github.com/nawed2611/sorting-and-searching-in-c
Practising different types of Sorting and Searching Techniques in C language
https://github.com/nawed2611/sorting-and-searching-in-c
c cplusplus sorting
Last synced: 2 months ago
JSON representation
Practising different types of Sorting and Searching Techniques in C language
- Host: GitHub
- URL: https://github.com/nawed2611/sorting-and-searching-in-c
- Owner: nawed2611
- Created: 2021-09-13T15:27:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-12T14:43:55.000Z (over 4 years ago)
- Last Synced: 2025-06-20T03:02:04.308Z (about 1 year ago)
- Topics: c, cplusplus, sorting
- Language: C
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Sorting and Searching in C
Practicing different types of Sorting Techniques in C language.
A must read excerpt from Cormen's Algorithms Book-
"For a concrete example, let us pit a faster computer (computer A) running insertion sort against a slower computer (computer B) running merge sort. They each
must sort an array of 10 million numbers. (Although 10 million numbers might seem like a lot, if the numbers are eight-byte integers, then the input occupies
about 80 megabytes, which fits in the memory of even an inexpensive laptop computer many times over.) Suppose that computer A executes 10 billion instructions
per second (faster than any single sequential computer at the time of this writing) and computer B executes only 10 million instructions per second, so that computer A is 1000 times faster than computer B in raw computing power. To make the difference even more dramatic, suppose that the world’s craftiest programmer
codes insertion sort in machine language for computer A, and the resulting code requires 2n2 instructions to sort n numbers. Suppose further that just an average
programmer implements merge sort, using a high-level language with an inefficient compiler, with the resulting code taking 50n lg n instructions.
`To sort 10 million numbers, computer A takes`
`(2.(10)^7)/2 instructions / (10^10 instructions/second) = 20,000 seconds (more than 5.5 hours)`
`While computer B takes`
`50.(10^7).(lg 10^7) instructions / (107 instructions/second) = 1163 seconds (less than 20 minutes)`
By using an algorithm whose running time grows more slowly, even with a poor
compiler, computer B runs more than 17 times faster than computer A! The advantage of merge sort is even more pronounced when we sort 100 million numbers:
where insertion sort takes more than 23 days, merge sort takes under four hours.
In general, as the problem size increases, so does the relative advantage of merge
sort.
Have a look here on how different algorithms work and their time complexities:
[](https://www.youtube.com/watch?v=ZZuD6iUe3Pc)