First a haiku :
Sorting a heap of cards,
words issued from Heap,
yet none penetrated too deep
I'm quiet disappointed that no one has thought yet to leave me any comments about my poetry. (Hint Leave a comment.)
This week we're learning yet more sorting algorithms. I think the purpose of learning so many different algorithms is so that we get a flavour of the myriad different methods there are to approach a computer science problem.
In any case, two of the algorithms we learned were normal iterative ones, and this week we started on quick sort which is a divide and conquer type. As recursion is becoming more and more natural to me, understanding the recursive nature of the divide and conquer algorithm is not so difficulty.
Essentially, there are three steps:
1) Break the problem into smaller ones
2) Solves the smaller ones recursively
3) Combine up the results from 2 in a proper fashion.
E.g:
Say I have [4, 2, 3, 1]
I'll split it [4, 2] & [3, 1]
Solve each part recursively so [2, 4] & [1, 3]
Now combine [2, 4, 1, 3]
But in our combine step we need to be careful and put the right thing in the right place, so put 4 and 2 in their right places [1, 2, 3, 4]
Ta-da sorted!
Anyways, that's all folks.
Adieu,
Seigal
Your poetry is very creative.
ReplyDeleteThank you very much! :)
Delete