Today we are going to help Rey find Luke.
Buble sort works by comparing two elements in an array and swapping them if they need to be swapped. This is repeated until all items in the array are in the correct order. We wil use this function to sort the array of Star Wars Character names. Text Explanation, Dancing Explanation, Cool Sounds
Binary Search works just like looking up a word in a dictionary or a number in a phonebook. If you are too young to have ever used each, this maybe hard for you. Binary Search assumes a sorted array (the one we just sorted in bubble sort), then check the middle of the array and sees if what we are looking for is greater than or less than the midpoint. Then it looks at that half of the array and so one until it is down to one item and hopefully that one matches the thing we are looking for. Video Explanation. This should return the index of Lukes location.
Now for practice we are gonig to do a merge sort. I am not going to lie, this one is kind of tough. Basically, it breaks down the array until it has only two indexes sorts them back together. Now it has two, two length arrays. It merges those backtogether into one sorted array and so on until it has an original sorted array. Khan Academy Walk Through, Text Description and some psudo code, Dancing Explanation
Khan Academy Walk Through. Videos: this video is very thourough, and this guy shows a way to implement it with moving pointers.