What is difference between Bubble sort, selection & insertion sort?
Can anyone allaborate without C code?
What is difference between Bubble sort, selection & insertion sort?
Can anyone allaborate without C code?
My best code is written with the delete key.
If you want an understanding of algorithms "without code", imagine the situation as a game. Someone hands you a stack of random cards and the objective is to arrange the cards in order. But you have certain rules. All the cards are face-down. You can only uncover a certain number of cards at a time, remembering a card uses some of your memory, and each time you move or exchange cards, you have to use one move. Sorting algorithms (or in fact any algorithm) could be seen as strategies to finish the game. Hopefully one would hope that the strategy is one which uses as few moves as possible or by using the least amount of memory as possible.
The algorithms you named are all strategies to solve the sorting problem. Try to find a good description of the algorithm as "pseudocode" and then read and understand how it works without regarding to a programming language. The differences usually come down to a difference in time complexity (how "fast" it is) or space complexity (how much memory it uses).
Check some small videos I used to watch when first meeting these algorithms!
If you want to see some code of bubblesort, you can check here.
(Notice that there you will find three implementations of bubblesort, so if you haven't understand the naive implementation, then you might want to click this link after you do understand it).
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson