1) Insertion -> adding a new item to a collection
2)
1) RAINBOW ← ["Blue", "E", "Green", "D", "Indigo", "F", "Orange", "B", "Red", "A", "Violet",
"G", "Yellow", "C"]
2)
3) COLOR ← ARRAY OF SIZE (LENGTH(RAINBOW) / 2)
4) ORDER ← ARRAY OF SIZE (LENGTH(RAINBOW) / 2)
5)
6) FOR i ← 0 TO LENGTH(RAINBOW) - 1 STEP 2 DO
7) COLOR[i / 2] ← RAINBOW[i]
8) ORDER[i / 2] ← RAINBOW[i + 1]
9) Print /end
3)
1) FOR i ← 0 TO LENGTH(ORDER) - 2 DO
2) FOR j ← 0 TO LENGTH(ORDER) - 2 - i DO
3) IF ORDER[j] > ORDER[j + 1] THEN
4) // Swap ORDER
5) TEMP ← ORDER[j]
6) ORDER[j] ← ORDER[j + 1]
7) ORDER[j + 1] ← TEMP
8)
9) // Swap COLOR
10) TEMP ← COLOR[j]
11) COLOR[j] ← COLOR[j + 1]
12) COLOR[j + 1] ← TEMP
13) print /end
4) Compare and contrast bubble sort and algorithmic sorting
Bubble sort uses a method of repeatedly swapping the juxtaposed/adjacent elements
that are inputted into the sort system and moves them in the other of greatest to largest in order
to put the items into the specified order asked for.
Whereas algorithmic sorting performs fewer swaps without having to swap adjacent
neighboring items.
They both sort elements and are able to provide it in smallest to greatest order, however
they differ in the amount of steps the sorting process takes in order to get the job done.