Graceofgod said:
I have done a trial in which you had to write a bubble sort and a binary selection.
Sorry, binary selection? Either you have no idea what you just stated, or you meant "binary search", binary selection is an "If" statement.
You need to know the basic algorithm behind the sorts,
Bubble works by comparing the value of the current index to (current index + 1) and swaps them if array[currentindex] is bigger.
Selection finds the highest(or lowest) and performs the swap function again.
Insertion works through the array and places the value at the expected location in the array.
Only insertion needs an example, [2,7,4,3,5,1]
> 2 is considered sorted
> First pass: 7 is in its correct position
> Second: 4 should be inbetween 2 and 7.
> Third: 3 should be inbetween 2 and 4
etc.
First pass: [2,7,4,3,5,1]
Second pass: [2,4,7,3,5,1]
Third pass: [2,3,4,7,5,1]
Fourth pass: [2,3,4,5,7,1]
Fifth pass: [1,2,3,4,5,7]
Once you know the basic algorithm, writing it in pseudocode is hilariously easy, remember you can take massive shortcuts using pseudocode, where statements like "Shift array from Array1] up one spot." "Array[1] = UnsortedNumber" are considered accurate.