CECS 342 Final

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

30 Terms

1
New cards

What can be said about the following statement?

"The scope of a variable is limited to the clause in which it appears."

a) the statement is theoretically true, but the implementation of prolog does not enforce this concept.

b) the statement is false - prolog variables do not have "scope" in the traditional computer language sense.

c) that is false. Prolog makes use of global variables so the clauses can pass information to each other

d) that statement is true.

d) that statement is true.

2
New cards

Prolog and other logic languages are based on...

a) boolean binary

b) predicate calculus

c) logistical nightmares

d) formal logic

b) predicate calculus

3
New cards

What can be said about the following prolog statement:grandparent(G, C) :- parent(G,P), parent(P, C).

a) it is a rule

b) it is a fact

c) it is a query

d) it is a goal

a) it is a rule

4
New cards

What can be said about this prolog statement:parent(steve, landon).

a) it is hard to raise kids these days

b) it is a fact

c) it is a goal

d) it is a rule

b) it is a fact

5
New cards

What term is used to describe how the prolog interpreter works in order to prove a goal?

a) depth-first recursion

b) backward chaining

c) random tagging

d) forward linking

b) backward chaining

6
New cards

The body of a Horn Clause...

a) is a list of terms.

b) is not transmittable

c) is a single term.

d) The correct answer is not shown.

a) is a list of terms.

7
New cards

Is this function tail recursive?

int fibo(int n, int n1=1, int n2=1)

{

if (n == 0) return n2;

if (n == 1) return n1 + n2;

return fibo(n-1, n2, n1+n2);

}

a) True

b) False

a) True

8
New cards

The head of a Horn Clause...

a) The correct answer is not listed.

b) is a list of terms

c) is inverted when called

d) is a single term

d) is a single term

9
New cards

Is this function tail recursive?

int fibo(int n, int n1=1, int n2=1)

{

if (n == 0) return n2;

if (n == 1) return n1 + n2;

int result = fibo(n-1, n2, n1+n2);

return result

}

a) True

b) False

b) False

10
New cards

What is true about Horn Clauses?

a) They have a head and a body

b) It's Santa Clauses brother

c) They are hard to implement

d) They are tail-recursive

a) They have a head and a body

11
New cards

Who developed that Lambda Calculus?

a) Professor Lambda

b) Master Gold

c) Doctor Church

d) Allen Turing

c) Doctor Church

12
New cards

The Lisp programming language was developed in the 1930's.

a) True

b) False

b) False

13
New cards

What is displayed on the terminal when this Lisp program is executed:

(setq nums(list 1 2 3 4 5))

(car nums)

(car nums)

(car nums)

(write(car nums))

a) list

b) 1

c) The correct answer is not shown

d) 4

b) 1

14
New cards

What is printed on the terminal when this Lisp statement is executed?

(format t "The answer is ~d:" ((lambda ( x) (*x x))5 ))

a) The answer is 5

b) The correct answer is not shown

c) The answer is 25

d) The answer is 10

c) The answer is 25

15
New cards

What is the result of this Lisp statement?

(write (caddr (cdr (list 1 2 3 4 5 6 7))))

a) 7

b) 3

c) 5

d) 4

d) 4

16
New cards

What is true about lambda expressions in Lisp language?

a) The cannot return a value

b) All of these answers are correct

c) They do not have a name

d) They can only accept one variable as input

c) They do not have a name

17
New cards

Which of the following is NOT a functional language:

a) Fortran

b) Lisp

c) Scheme

d) Haskell

a) Fortran

18
New cards

What is the output of this Lisp statement:

(write (+ (* 2 3) 4 (-7 2)))

a) It will produce an error

b) 11

c) 15

d) The correct answer is not shown

c) 15

19
New cards

Functional languages do not allow recursion.

a) True

b) False

b) False

20
New cards

What is the answer written to the output terminal for this LISP statement?

(write (3 + 5 * 2 - 4)

a) 10

b) 12

c) 9

d) The correct answer is not shown.

d) The correct answer is not shown.

21
New cards

How does Rust handle memory management?

a) Manual memory allocation and deallocation

b) Automatic reference counting

c) Ownership system with borrowing and lifetimes

d) Automatic garbage collection

c) Ownership system with borrowing and lifetimes

22
New cards

What does the "mut" keyword signify in Rust?

a) It specifies the type of a variable

b) It indicates that a variable is mutable

c) It denotes a macro invocation

d) It indicates that a variable is immutable

b) It indicates that a variable is mutable

23
New cards

What is Rust's "Cargo?"

a) A data serialization format

b) A package manager and built system

c) A type inference system

d) A rust code editor

b) A package manager and built system

24
New cards

Suppose I have an array that represents a binary tree. The root of the tree is in index 1 of the array. The last element of the array that has a value is index 53. How many levels does the tree have?

a) 6

b) There is not enough information to answer this question.

c) 7

d) 5

a) 6

Explanation: Since a tree is 2^n-1, therefore 2^1-1 =1. That's why it's level 6. He said he went by 2^n-1 until it is larger than 53. And n is the level of the tree.

25
New cards

What is the Rust equivalent of a C/C++ pointer?

a) Value

b) Heap

c) Reference

d) Stack

c) Reference

26
New cards

Which of the following is NOT a valid Rust variable binding pattern?

a) let (x, y) = (1, 2);

b) let mut x = 42;

c) let x: i32 = "42";

d) let x = 42;

c) let x: i32 = "42";

27
New cards

Which of the following is NOT a rust loop construct?

a) loop

b) while

c) for

d) do while

d) do while

28
New cards

Which of the following is NOT a valid Rust reference type?

a) &mut T

b) * const T

c) &T

d) * mut T

b) *const T

29
New cards

What is a Rust "lifetime"?

a) The amount of memory a program uses

b) The duration for which a variable is valid

c) The time it takes for a program to compile

d) The frequency with which a garbage collection occurs

b) The duration for which a variable is valid

30
New cards

What is the purpose of the "const" keyword in Rust?*

a) To disable the borrow checker for a block of code

b) To define a constant value that cannot be modified

c) To define a mutable variable

d) To define a function that is executed at compile time

b) To define a constant value that cannot be modified