Week 5
Hiiiii everyone, welcome back to my blog!!!!! One week has gone by super quick and I was very busy with all kind of school work. And yes, first assignment in CSC148 is due next week.................. my partner and I has already finished the first few parts but when it has come to the 5th part, which we're supposed to implement the codes for Tour.py, we're stuck and currently pretty much have no idea what's going on. I'll discuss that later.
SOOOO remember that I mentioned that I skipped a lecture last week? This week I have tried my best to attend the lectures that turned out I was only late for one lecture. Big improvement isn't it? I'll try to attend all my lectures on time next week and I'll report to you guys how i'll do.
Although I've been to all the lectures this week, I found that I didn't really learn much from lecture. I'm not saying that the prof did not teach well. Instead, he taught a lot of things on recursion and also explained to us what is the Tower of Hanoi. I didn't learn much because I wasn't able to understand much during the lecture. I have to admit that I'm quite slow at understanding recursion. For example:
"""Print moves to get n cheeses from source to destination, possibly using intermediate"""
if n > 1: # fill this in!
move_cheeses(n - 1, source, destination, intermediate)
move_cheeses(1, source, intermediate, destination)
move_cheeses(n - 1, intermediate, source, destination)
else: # just 1 cheese --- fill this in now!
return ??????
we were asked to complete the return statement but it took me sooooo long to figure out how the recursion will run and I wasn't able to complete it during class. I did figure it out after class when I sat down in the library and started tracing it so I guess it's not that bad.
I found that this week's lab was super helpful for me and I learned A LOT from it. We were asked to trace a couple of codes that were using recursion. After my lab partner and I finished tracing them, I felt like I suddenly have a way deeper understanding in recursion, especially knowing how to find the base case. As my TA has said, "there's no better way to understand a program than tracing it on paper". This is totally true. I'll never be able to understand recursion without tracing different codes on paper and looking through them step by step.
Back to assignment 1, at part 5, we were supposed to use recursion to solve the Tower of Hanoi with the least possible moves. Our codes should be able to apply no matter how many stools or cheese there are. For example, our program should be able to solve 4 stools and 5 cheeses in 13 moves but it failed. Currently we have no idea what's going with our program. Maybe there's something wrong with our recursion, we really don't know. I'll bring more updates to you guys next week.
So that's it for now. see you guys soon!
No comments:
Post a Comment