Good news is, sample solutions for the labs were posted, so the confusion I had about lab 7 regarding implementing the functions, solved.
That's probably a problem.
I have difficulty implementing functions myself, but when I see sample code, I understand it.
In other words, I can't come up with some of the code myself.
I was freaking out for the most part of week 9 because of that reason.
However, I think the midterm went alright for the most part.
Unfortunately, I totally have trouble reading the instructions.
The very first question was asking about a Binary Search Tree but I completely missed that and just drew a regular Tree. A tree that wasn't binary.
So lost a couple of marks there.
But I absolutely know what I did wrong there.
Then there was a question on LinkedLists and I wasn't very sure how to implement it either.
I don't remember the question clearly, but I remember struggling to decide whether to look at the size of the list, or whether to use a while loop.
I don't remember the question clearly, but I remember struggling to decide whether to look at the size of the list, or whether to use a while loop.
Again, hopefully, sample solutions to the test will be posted soon so that I can see what's going on.
Will elaborate on Term Test #2 after sample solutions are posted.
This week in lectures, we talked about which value python takes when given something like:
This week in lectures, we talked about which value python takes when given something like:
It will always look at the value given under the if __name__ == '__main__': statement.
i.e., since in the function h(1), the value of N would be 1, not 5, as the first line says. M, however, will keep it's value as 2.
Then looking at h(1), N == 1.
So f(g(N)) first looks at g(N), which would return 2 * 1, which gives 2.
So next, it looks at f(2), which gives 2 * g(2 + 1). g(3) returns a value of 6.
Therefore, f(2) returns a value of 12.
f(g(N)) returns a value of 12, which is what h(1) evaluates to.
h(1) would return 12.
p.s. Strike still not over.
No help on labs!! Eeeeeeek.

No comments:
Post a Comment