LISP Questions & Answers – Recursion

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Recursion”.

1. Which is bounded to a list of all unaccounted argument values?
a) REST
b) &REST
c) RAISE
d) &RAISE
View Answer

Answer: b
Explanation: A rest parameter will be marked by &REST and it is bounded to a list of all unaccounted argument values.

2. Which allow procedures to use themselves again?
a) Recursion
b) Reuse
c) Reintiate
d) None of the mentioned
View Answer

Answer: a
Explanation: Recursion allows procedures to use themselves again and again.

3. Which eliminate the need for many auxiliaries?
a) Parameters
b) Block parameters
c) Optional parameters
d) All of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement
advertisement

4. Which can appear without an initial form?
a) Parameter
b) Block parameter
c) Optional parameter
d) Aux parameter
View Answer

Answer: d
Explanation: An aux parameter can appear without an initial form, in which case there are no surrounding parentheses.

5. What value will assigned, if there is no argument marked by a matching keyword?
a) T
b) NIL
c) False
d) Both NIL & False
View Answer

Answer: b
Explanation: If there is no argument marked by a matching keyword, the corresponding keyword parameter is bound to NIL.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. What is the output of the following statement?

span class="sy0"> * (defun higher-level-expt (m n)(if (zerop n)1 (* m(lower-level-expt m (- n 1)))))

a) Higher
b) Higher-level-expt
c) Lower
d) Lower-level-expt
View Answer

Answer: b
Explanation: This statement will print higher-level-expt because it is defined atfirst.
Output:
HIGHER-LEVEL-EXPT
advertisement

7. What is the output of the following statement?

advertisement
span class="sy0"> * (defun root (x &optional n) (if n (expt x (/ 1 n))(sprt x)))
* (root 27 3)

a) 3
b) 27
c) 3.0
d) None of the mentioned
View Answer

Answer: c
Explanation: This statement is used to find out the square root of the given value.
Output:
3.0

8. What is the output of the following statement?

span class="sy0"> * (defun punc (l) (append l '(period)))
* (punc '(this))

a) This
b) Period
c) This period
d) All of the mentioned
View Answer

Answer: c
Explanation: This statement will append the period to the end of the given statement.
Output:
(THIS PERIOD)

9. What is the output of the following statement?

span class="sy0"> * (defun raise-aux (result number-list)(if (endp number-list) result (raise-aux (expt result (first number-list)) (rest number-list))))
* (defun raise (x &rest numbers) (raise-aux x numbers))
* (raise 5 3)

a) 5
b) 3
c) 125
d) 25
View Answer

Answer: c
Explanation: This statement will print first argument raised to power second argument.
Output:
125

10. What is the output of the following statement?

span class="sy0"> *  (setf pairs '((maple shade) (apple fruit)))
* (member '(maple shade) '((maple shade) (maple shade)) :test-not #'equal)

a) Maple
b) Shade
c) Nil
d) T
View Answer

Answer: c
Explanation: This statement is used to test the given statement for its equality.
Output:
NIL

Sanfoundry Global Education & Learning Series – LISP Programming Language.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.