250+ TOP MCQs on Pattern Matching and Answers

LISP Multiple Choice Questions on “Pattern Matching”.

1. Which procedure is used as key element in a backward chaining algorithm?
a) Matching
b) Unification matching
c) Verification
d) None of the mentioned

Answer: b
Clarification: The unification matching procedure is a key element in a backward chaining.

2. What is the way of expressing an ordinary expression in terms of bits?
a) Datum
b) Data
c) Manipulation
d) Verification

Answer: a
Clarification: The process of expressing an ordinary expression in terms of bits is called datum.

3. What is the name of elements present in patterns?
a) Variables
b) Patterns
c) Pattern variables
d) Pattern elements

Answer: c
Clarification: Patterns can contain elements called pattern variables.

4. Which keeps variable binding on an association list?
a) Match
b) Compare
c) Equal
d) None of the mentioned

Answer: a
Clarification: Match keeps variable binding on an association list.

5. Which is used to compare patterns and datums element by element?
a) Procedure
b) Compare
c) Equal
d) Matching

Answer: d
Clarification: To compare patterns and datums element by element matching is used.

6. What is the output of the given statement?

span class="sy0"> * (setf pattern-variable-expression '(? x))
* (setf datum 'apple)
* (setf bindings '((y red)))
* (second pattern-variable-expression)

a) X
b) Red
c) Apple
d) None of the mentioned

Answer: a
Clarification: The result will be x because the second element is referred in pattern.
Output:
X

7. What is the output of the given statement?

span class="sy0"> * (setf pattern-variable-expression '(? x))
* (setf datum 'apple)
* (setf bindings '((y red)))
* (list (second pattern-variable-expression) datum)

a) x
b) Y
c) Apple
d) Both x & Apple

  250+ TOP MCQs on Difference Between Setq and Setf and Answers

Answer: d
Clarification: The elements from the given list is listed using the given statement.
Output:
(X APPLE)

8. What is the output of the given statement?

span class="sy0"> * (cons (list (second pattern-variable-expression) datum) bindings)

a) (X apple)
b) (Y orange)
c) (X apple) (Y orange)
d) None of the mentioned

Answer: c
Clarification: This statement will list all the elements in datum and bindings.
Output:
((X APPLE) (Y RED))

9. What is the output of the given statement?

span class="sy0"> * (defun add-binding (pattern-variable-expression datum bindings) 
  (if (eq '_ (extract-variable pattern-variable-expression)) bindings (cons 
  (make-binding (extract-variable pattern-variable-expression) datum) bindings)))
* (add-binding '(? _) 'apple '((y red)))

a) X
b) Y
c) (X apple)
d) (Y red)

Answer: d
Clarification: This statement is used for adding a binding in the pattern.
Output:
((Y RED))

10. What is the output of the given statement?

span class="sy0"> * (defun find-binding (pattern-variable-expression binding)
  (unless (eq '_(extract-variable pattern-variable-expression))
  (assoc (extract-variable pattern-variable-expression) binding)))
* (find-binding '(? _) '((x apple) (y red)))

a) X
b) Apple
c) T
d) Nil

Answer: d
Clarification: This statement is used to find a binding in the given pattern.
Output:
NIL

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top