rit-csc / csc_exam_reviews

A collection of practice exams for exams in core curriculum CS courses at RIT.
http://csc.cs.rit.edu/resources
13 stars 1 forks source link

CS1 Final Issues from Professor Steele #24

Closed chrissprague closed 9 years ago

chrissprague commented 9 years ago

From Professor Steele (ignore the pounds which get auto-linked to issue numbers):

Hi Chris, Here's my feedback on the review exam -- generally good and I like the quicksort pic. Most items are concerning the answers.

1 line 5 is also a problem; that codes is more nearly C.

3 the answer is missing the last ')'

6b the tail recursive version should go like this:

    def series_sum( i, n, f, s=0 ):
         if …

That way you kick-start the sum when it starts.

6c I don't think I agree with the last statement in the answer, which starts

    with "The true benefit…" The tail recursion will still initiate a
    function call and its stack frame, and usually the system is counting
    stack frame not total stack consumption. That is why Python recursions
    usually fail after around 1000 calls.

8,#12 need to update to rit_object syntax

10 I think the answer is incorrect. there are 8 items with indices 0…7, and

    the midindex would be (0+7)//2 == 3, whose value is 16. the answer is
    using index 4.

12 the solution must be assuming a binary search tree, but the problem does

    not state this. the general solution would have to search both branches.

--bks

chrissprague commented 9 years ago
  1. line 5 is not a problem. it runs fine.
YawarRaza7349 commented 9 years ago

I think he meant more that no one would write a line of code like that. int is a function in Python, so wrapping it in parentheses is like wrapping any other single value in parentheses. You wouldn't write z = (x) + (y) in Python, right? c = int(0) is the better syntax for expressing that statement. c = (int)(0) also being correct seems too trivia-like for CS1 students to need to know it.

khipkin commented 9 years ago

^^^^^

chrissprague commented 9 years ago

It's been removed.