This will be my second post for the weekend since I will be way too busy during the upcoming week. In this post I will discuss the topics covered in the last two weeks including the divide-and-conquer algorithm.
Divide and Conquer, to me, is one of the concepts in Computer Science that I actually find useful. It helps you tackle complicated problems and makes you think more like a computer scientist.
Although I have forgotten all the details like the pseudo-code of the MergeSort and etc., I didn't find the material presented in class to be surprising or anything. In the last tutorial, though, I was caught a bit off guard when the quiz was to write a divide-an-conquer algorithm--for a very similar problem to one of the tutorial exercises, but my head was blank because I just had a tough midterm that morning. Anyway, what's the big deal? it's just a type of recursion, I just need a base case, and then divide the problem into sub-problems. Sounds easy, but the thing is the index. I let m=(b+e)/2 and there I was thinking if m would be the ceiling or the floor, and then I thought maybe it doesn't matter, but then do I verify A[m-1], A[m], or A[m+1], and would the lower list be from b to m or m-1, etc.
I barely finished the quiz in time that day; hopefully, I didn't make any mistake. I have been thought this before. A few similar problems, and I should be ready for the midterm. I doubt if I will have time to prepare for the midterm though...
No comments:
Post a Comment