Martyn Patrick / Portfolio

Sorting & Searching Algrothrims
As a requirement our program had use atleast one searching or sorting algrothrim. We used 2 searching and 2 Sorting algrothrims:
A* and Dijkstra were our searching
Quicksort and Insertion Sort were our sorting algrothrims.
Above is a picture of the insertion sort code I produced in order to sort the inventory. I did not work on the other algrothrims so I will not show pictures of them.
Once the function is called it goes over every element of the inventory except the first. comparing that element to the first.
1st element compares to the 2nd element. If the 1st element is bigger than the second it swaps the two elements. If the 1st element is smaller than the 2nd element it remains the same and the loop moves on this continues until the list is sorted. It works by esstenallty spliting the list into sorted and unsorted segments. This is why the first element is used because it is considered automatically sorted.