Searching and Sorting
Introduction to Sorting and Searching Arrays In this blog post, we will be going over simple implementations for sorting and searching lists. Learning to write fast search and sort algorithms will have an immense impact in the performance of all programs, as many real world applications deal with huge sets of data. In this post, I will not include Big-Oh notation, which I will write in a later post. Just worry about speed in a relative sense for now. Sorting using Selection Sort Let us take a look sorting an array first. You are given a random list of numbers in an array, and are told to sort them in ascending order. 9 5 7 3 2 1 8 There are 7 numbers in total in the array. Now the most basic way of approaching this problem would be to find the smallest number swap it with the front position, but in an unordered list, you have no idea of where that number will be. Therefore you must traverse the entire list to find the smallest element, besides...