Anyway, it was the last MATLAB lecture of the semester, and we were finishing up with sorting methods. We’d just done recursion, so the last sorting method we were learning (after insertion and bubble sort) was the merge sort. To start our discussion of the merge sort, the professor asked us if it would be easier to straight up sort a thousand items or merge two sets of five hundred items that had already been sorted. Well, this one time in band . . .
Actually, it’s been a lot of times in band. So the pep band “folders” are stacks of half sheets of music shoved into a pocket-type holder made of construction paper and/or duct tape. Normally, people keep their music alphabetized so they can find it more easily. However, during our busier events (hockey), most people don’t have time to put their music away between sets, so after the game there’s the folder, and then there’s the giant pile of music outside the folder . . . that needs to be sorted.
At this point, you have three options: one, take each piece of music and go through your folder to find out where it goes; two, alphabetize the music outside of your folder and then combine (hint: merge) the two piles; and three, ignore the giant stack of un-alphabetized music by shoving it into your folder and regretting it the next time you have to find a piece of music. Well, if you ask me, options one and two sound a lot like the insertion and merge sorts.
Speaking from experience, if around half your folder is sitting in a heap waiting to be put back into the folder, alphabetize it first so you don’t have to flip through the a’s seven billion times. (Merge sort) Otherwise, just sort each song in the order you find it. (Insertion sort)
And that is how math (okay, computer science, which needs math) is like music.
No comments:
Post a Comment