Quiz 3 Flashcards
(define L ‘(5 (3 9 2) (6 4) 1))
(caadr L)
What is the output of the code above?
(6 4), 6, 3, or (9 2)?
3
Tail recursion allows recursive functions to be executed more efficiently by storing intermediate results. So, no runtime stack is necessary to remember arguments of previous calls in tail recursion, T/F?
True
(define L ‘(5 (3 9 2) (6 4) 1))
(cadr L)
What is the output of the code above?
1, 5, (6 4), or (3 9 2)?
(3 9 2)
Which of the following is the correct Scheme expression to calculate the greatest common divisor of 10 and 15 with a given gcd function?
(gcd 10 15), gcd(10, 15), gcd,10,15, or gcd ( 10 15)?
(gcd 10 15)
(define L ‘(5 (3 9 2) (6 4) 1))
(cadddr L)
What is the output of the code above?
4, 2, 6, or 1?
1
(define L ‘(5 (3 9 2) (6 4) 1))
(caddr L)
What is the output of the code above?
3, 6, (9 2), or (6 4)?
(6 4)
(define L ‘(5 (3 9 2) (6 4) 1))
(car L)
What is the output of the code above?
(3 9 2), (6 4), 5, or 1?
5
When you define variables in a let expression in Scheme, values of the variables can be accessed only within the let form, not outside it, T/F?
True
Which function adds a new head to an existing list?
cons, null?, car, or cdr?
cons
Which of the following is the correct Scheme expression to calculate (3 + 5) * 2
(* (+ 3 5) 2), (+ * (3 5) 2), (3 + 5 * 2), or (+ (3 5) * 2)?
(* (+ 3 5) 2)