In: Computer Science
1.What will the result of this form be? (cadr ‘(1 2 3 4 5 6))
a. '(1 2 3 4 5 6)
b. 2
c. '(2 3 4 5 6)
d. 1
.
2.How does Prolog try to resolve our Queries?
a.The programmer specifies the algorithmic approach, performance is all in the hands of how clever the programmer writes their algorithms.
b.The language applies some AI to our query and precludes obviously false information.
c.Row by agonizing row. There is nothing particularly clever about the solve, it just brute forces its way through the data looking for resolutions.
1.answer: b. 2
explanation:
;To make it simple to understand let's get it from scratch
;semicolons ; represents comments
;cadr is a combination of car&cdr i.e car(cdr(list))
;car and cdr are list operations
;cdr takes out the first element from the list and returns rest elements
;as a new list
;so cdr(1 2 3 4 5 6) is (2 3 4 5 6)
;car(list) always retrieves the first element from list
;as said earlier cadr is combination so
;car here is being implement on above list
;car(2 3 4 5 6) return first element i.e 2
;so answer is 2
(cadr '(1 2 3 4 5 6))

2. answer: c.Row by agonizing row. There is nothing particularly clever about the solve, it just brute forces its way through the data looking for resolutions.
explanation:
Option A:The programmer specifies the algorithmic
approach, performance is all in the hands of how clever the
programmer writes their algorithms.
The unique feature in prolog automatically finds the facts and
rules to solve a query so there is not much involvement of
programmer's algorithm approach to solve the query in prolog.So
this option is incorrect
Option B:The language applies some AI to our query and
precludes obviously false information.
In fact Prolog is the oldest programming language,Back then there
was no AI to use on query.So in this perspective we can cross over
this option. Incorrect
Option C:Row by agonizing row. There is nothing particularly clever about the solve, it just brute forces its way through the data looking for resolutions.
We cannot say it's a brute force way,But prolog automatically
choose facts and rules to resolve a query row by row in a
list.
so this option is correct
**************************************************************************
Please give an upvote,as it matters to me a lot :)
Got any doubts? Feel free to shoot them in the comment
section
**************************************************************************