0% found this document useful (0 votes)
36 views36 pages

1

Uploaded by

dhruvalsvm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views36 pages

1

Uploaded by

dhruvalsvm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

When evaluating a programming language the category Reusability describes:

ANSWER :_ This concept asks how tied down a language is to a particular platform, can code be
distributed easily and can libraries be made and shared

----------------------------

Autocode and FORTRAN are considered to be the first high-level programming languages.

ANSWER :_ True

----------------------------

There was an early focus on efficiency due to early programmable computers being themselves fairly
inefficent being limited in power and storage.

ANSWER :_ True

----------------------------

With over 500 programming languages in the world, the best way approach to learning languages is
to focus on memorizing syntax and structure. Then learn languages with simimlar syntaxes and
structures.

ANSWER :_ False

----------------------------

What is the major improvement of structured programming languages over the earlier programming
languages?

ANSWER :_ Removing Go to statement from the language.

----------------------------

What programming language characteristics impact the readability of the programs written in this
language?

ANSWER :_ Data Structures, Syntax Design, Control Structures

----------------------------

What programming paradigm does Fortran belong to?

ANSWER :_ Imperative
----------------------------

In contrast to Web 1.0, what is the key function of Web 2.0?

ANSWER :_ Web is the computing platform

----------------------------

Event-driven computing paradigm is to

ANSWER :_ define a set of events and write an event handler for each event.

----------------------------

von Neumann Architecture is

ANSWER :_ A state based programming structure which loads and interprets instructions from
memory into action

----------------------------

Event-driven computing paradigm is to

ANSWER :_ define a set of events and write an event handler for each event.

----------------------------

If your program was designed to print "Hello World" ten (10) times, but during execution, it printed
eleven (11) times. What type of error is it?

ANSWER :_ Semantics Error

----------------------------

Given this snippet of code in C,

char alpha = 'a';

int numeric = alpha + 10;

which of the following statement is correct:

ANSWER :_ Syntactically correct, but contextually incorrect.

----------------------------
For the following BNF ruleset, which are terminal symbols? (Check all that apply.)

<char> ::= a | b | c | ... | x | y | z

<identifier> ::= <char> | <char> <identifer>

ANSWER :_ y, a

----------------------------

Which commands (constructs) do NOT have a loop when expressed in syntax graphs? Select all that
apply

ANSWER :_ while (condition) do {statements;}

if-then-else

for ( <init-expr>; <test-expr>; <increment-expr> ) {<statements>}

----------------------------

If a program contains an error that divides a number by zero at the execution time. This error is a

ANSWER :_ Semantic Error

----------------------------

Given:

Very Simple Programming Language (VSPL)

<char> ::= a | b | c | ... | z | 0 | 1 | ... | 9

<operator> ::= + | - | * | / | % | < | > | == | >= | <=

<variable> ::= <char> | <char> <variable>

<expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> )


<assign> ::= <variable> = <expr>;

<statements> ::= <assign> | <assign> <statements>

The following is valid:

myvar = (x + y) * (a - c);

ANSWER :_ true

----------------------------

Given:

Very Simple Programming Language (VSPL)

<char> ::= a | b | c | ... | z | 0 | 1 | ... | 9

<operator> ::= + | - | * | / | % | < | > | == | >= | <=

<variable> ::= <char> | <char> <variable>

<expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> )

<assign> ::= <variable> = <expr>;

<statements> ::= <assign> | <assign> <statements>

The following is valid:


a = x + y; b = s * t; c = w + v;

ANSWER :_ True

----------------------------

Given:

Very Simple Programming Language (VSPL)

<char> ::= a | b | c | ... | z | 0 | 1 | ... | 9

<operator> ::= + | - | * | / | % | < | > | == | >= | <=

<variable> ::= <char> | <char> <variable>

<expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> )

<assign> ::= <variable> = <expr>;

<statements> ::= <assign> | <assign> <statements>

The following is valid:

a = b + c + d;

ANSWER :_ false

----------------------------

If you like to see accurate debugging information, which of the following program processing would
you recommend?

ANSWER :_ Interpretation

----------------------------

If your application is composed of multiple modules (programs), which of the following program
processing would you recommend?

ANSWER :_ Compilation

----------------------------

What is the main reason of applying two-step translation of high level programming language?

ANSWER :_ One compiler for all machines


----------------------------

What is "func" in this example?

#include <stdio.h>

#define func(x, y) (x > y) ? y : x

int main()

int x = 10;

int y = 9;

int z = func(x, y);

ANSWER :_ A macro

----------------------------

Assume a function requires 20 lines of machine code and will be called 10 times in the main
program. You can choose to implement it using a function definition or a macro definition.
Compared with the function definition, macro definition will lead the compiler to generate, for the
entire program, ______

ANSWER :_ a longer machine code but with shorter execution time.

----------------------------

Given the following code, what is the expected value for z?

#include <stdio.h>

#define func(x, y) (x > y) ? y : x

int main()

{
int x = 10;

int y = 9;

int z = func(++x, y++);

ANSWER :_ 10

----------------------------

Explicit type conversion is commonly refer to as __________ .

ANSWER :_ Casting

----------------------------

Which of the following orthogonality describe this example:

If a block allows one statement, it should allow zero or more statments within that same block.

ANSWER :_ Number Orthogonality

----------------------------

In the C-Style input function scanf("%d", &i); What does the character "&" mean?

ANSWER :_ scanf takes the address of an variable as its parameter.

----------------------------

Where is the main() function located in a C or C++ program?

ANSWER :_ ? main class

----------------------------

In C++, what function can be used to input a string with spaces?

ANSWER :_ cin.getline(...);

----------------------------

What is NOT the purpose (functionality) of the forward declaration (prototype)?


ANSWER :_

----------------------------

A data type defines the

ANSWER :_ values and operations allowed

----------------------------

Assume a varible is declared in a block of code within a pair of curly braces. The scope of the variable

ANSWER :_ starts from its declaration point and extends to the end of the block.

----------------------------

Given a C declaration: char a[] = "Hello World"; What can be used as the initial address of array a[]?
Select all correct answers.

ANSWER :_ *a[0]

&a[0] (check with professor)

----------------------------

Given a declaration: char a[] = "Hello World"; What is the size (in bytes) of the array a[]?

ANSWER :_ 12 bytes

----------------------------

Which of the following C assignment statements (assign a value to a variable at the semantic level)
will NOT cause a compilation error?

Assume the array has been declared as: char a[5];

ANSWER :_ a[0] = 'h';

----------------------------

Which of the following statements will assign the address of the variable int myInt to the pointer
int* myPtr?

ANSWER :_ int* myPtr = &myInt;

----------------------------
Given the following:

int num1 = 5; //addressed at 1877112

int num2 = 15; //addressed at 1877300

int num3 = 20; //addressed at 1877192

double d1 = 1.05; //addressed at 1374376

double d2 = 2.25; //addressed at 1374360

double d3 = 3.14; //addressed at 1374344

After these statements:

int* ptr1 = &num3

ptr1 = ptr1 + 5;

What will be the address contained in ptr1?

ANSWER :_ 1877212

----------------------------

Which of the following statements will allow me to give the value of 10 to the memory int* myPtr
points to?

ANSWER :_ *myPtr = 10;

----------------------------

int num1 = 5; //addressed at 1767612

int num2 = 10; //addressed at 1767600

int num3 = 15; //addressed at 1767588

char ch1 = 'a'; //addressed at 3734375


char ch2 = 'b'; //addressed at 3734363

char ch3 = 'c'; //addressed at 3734351

char* chPtr = &ch3;

int* iPtr = &num3;

*iPtr = num3 *(times) 8;

'*chPtr' = '*iPtr;'

What will the following statement output?

cout << ch3;

ANSWER :_ 'x'

----------------------------

(True or False) Multiple pointers can reference the same objects.

ANSWER :_ True

----------------------------

C/C++ has 2 pointer operators, which operator represents the name of the address? (Commonly
refer as l-value.)

ANSWER :_ Asterisk (*)

----------------------------

Given this snippet of code, what is the value of x after executing the last statement?

int x = 10, *y;


y = &x;

y = y + 1;

*y = 100;

ANSWER :_ 10

----------------------------

Given this snippet of code, what is the value of x after executing the last statement?

int x = 10, *y;

y = &x;

*y = 100;

ANSWER :_ 100

----------------------------

Given this snippet of code, what is the value of z after executing the last statement?

int x = 10, *y, **z;

z = &y;

y = &x;

*y = 100;

ANSWER :_ None of the above (Memory Address)

----------------------------

A pointer variable can take the address of a memory location as its value. Read the given program.
#include <stdio.h>

main() {

int a = 20, b = 30, *p, *q, **r;

p = &a;

*p = 50;

q = &b;

*q = 70;

r = &p;

**r = 90;

printf("%d\n", a); // 1st printf statement

printf("%d\n", b); // 2nd printf statement

a = 20;

b = 80;

printf("%d\n", **r); // 3rd printf statement

Answer the following three questions.

1.The output of the 1st printf statement is [first].

2. The output of the 2nd printf statement is [second].

3.The output of the 3rd printf statement is [third].

ANSWER :_ 1.The output of the 1st printf statement is Correct 90.

2. The output of the 2nd printf statement is Correct 70.


3.The output of the 3rd printf statement is Correct 20.

----------------------------

We use "Pass by Constant Reference" when:

ANSWER :_ Function does not want to modify the value, the value is expensive to copy and NULL is
not valid

----------------------------

We use "Pass by Value" when:

ANSWER :_ Function does not want to modify the parameter and the value is easy to copy

----------------------------

We use "Pass by Constant Pointer" when:

ANSWER :_ Function does not want to modify the value, the value is expensive to copy and NULL is
valid

----------------------------

Given the following code

char a[2][4] = { { 'c', 'a', 'r', 'b' }, { 'i', 'k', 'e', '\0' } }; char *p = &a[0][0]; while (*p != '\0') { printf("%c",
*p); p++; }

What will happen?

ANSWER :_ It prints: carbike

----------------------------

Given the following code

char a[2][3] = { { 'c', 'a', 't'}, { 'd', 'o', 'g'} };

int i, j;

for (i = 0; i<2 ; i++) {

for (j = 0; j<3; j++)

printf("%c", a[i][j]);
}

ANSWER :_ catdog

----------------------------

Given the following definition and declarations:

#define size1 10

const int size2 = 20;

char a1[size1];

char a2[size2];

which line of code can cause a compilation error?

ANSWER :_ char a2[size2];

----------------------------

typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days;

days x = Mon, y = Sat;

while (x != y) { x++; }

y++;

printf("x = %d, y = %d", x, y);

1. What value will be printed for variable x? [x].

2. What value will be printed for variable y? [y]

ANSWER :_ x = 6, y = 7

----------------------------

Consider the following snippet of code in a 32-bit computer.

struct contact {

char name[30];

int phone;
char email[30];

} x;

What is the size of variable x in bytes?

ANSWER :_ 68

----------------------------

When is padding required for a structure type variable?

ANSWER :_ When the structure contains a word-type variable, such as integer, float, and pointer,
and the total number of bytes is not a multiple of four.

----------------------------

The size (number of bytes) of a structure-type variable can be changed by the following factors.
Select all that apply.

ANSWER :_ changing the computer from a 32-bit to a 64-bit processor.

changing the orders of the members in the structure.

adding a member into the structure.

----------------------------

What parameters are required when performing file operations fread and fwrite?

ANSWER :_ Destination

Item Size

Number of Items

Source

----------------------------

When will the buffer be created?

ANSWER :_ When the file operation fopen is performed.

----------------------------
The reason that we need to call fflush() or cin.ignore() is because the previous

ANSWER :_ input leaves a character in the file buffer.

----------------------------

Assume that the search function of a linked list is specified by

struct Terminal* search();

What values can the search function return? Select all correct answers.

ANSWER :_ The address of a teminal node

----------------------------

Assume pointer variable p points to node x, and node x's next pointer points to node y. What does
free(p) opeartion mean?

ANSWER :_ return the memory held by x to the free memory pool.

----------------------------

Assume this is a 32-bit environment, what is the size of x? (HINT: Don't forget about padding.)

struct Terminal {

char name[30];

char location[32];

struct Terminal* next;

} x;

ANSWER :_ 68 bytes

----------------------------

Given the information below, how will you access the name for a terminal node pointed to by x?

struct Terminal {
char name[30];

char location[32];

struct Terminal* next;

} *x;

ANSWER :_ x->name;

----------------------------

Given the information below, which of the following snippet of codes will print every terminal in the
linked-list without any side-effects of changing the state. Assume head is the only reference to the
linked-list and there are more than one terminal in the list.

struct Terminal {

char name[30];

char location[32];

struct Terminal* next;

} *head, *x;

ANSWER :_ x = head;

while(x != NULL) {

printf("%s - %s", x->name, x->location);

x = x->next;

----------------------------

Given the information below, which of the following snippet of codes will insert a new node in the
second place in the linked-list. Assume the linked-list contains already at least one node.

struct Terminal {

char name[30];

char location[32];

struct Terminal* next;


} *head, *p, *q;

ANSWER :_ p = (struct contact *) malloc(sizeof(struct contact));

...

p->next = head->next;

head->next = p;

----------------------------

How do you properly delete the first node of a linked list pointed to by head, assuming that the
linked list is not empty and temp is another pointer of the same type?

ANSWER :_ temp = head;

head = head->next;

free(temp);

----------------------------

A critical step in writing a recursive function is to assume that the

ANSWER :_ size-m problem has been solved by the underlying recursive mechanism, where m < n.

----------------------------

Given this snippet of code, identify what is the stopping condition and return value?

void deleteList(struct contact* node) {

if (node == NULL) return;

else {
deleteList(node->next);

free(node);

ANSWER :_ deleteList(node->next);

----------------------------

merge-short is typically implemented using

ANSWER :_ a function with two recursive calls.

----------------------------

In the hanoi towers function, what part of the code represent step 4: Constructiopn of size-n
problem from size-(n-1) problems?

ANSWER :_ hanoitowers(n-1, S, D, M);

hanoitowers(1, S, M, D);

hanoitowers(n-1, M, S, D);

----------------------------

If you want to change the insertion sort function with a size-(n-1) problem, as discussed in the
lecture, to a merge sort function, where do you need to make changes?

ANSWER :_ CorrectC.

In the definition of size-m problem

CorrectD.
In the code code that constructs the solution of size-n problem from the size-m problem.

----------------------------

When inserting a data into a binary search tree, the data should be inserted

ANSWER :_ at the position to keep the entire tree as a binary search tree.

----------------------------

The complexity of searching an arbitrary binary search tree is the order of

ANSWER :_ O(n)

----------------------------

Consider an array, a linked list, and a binary search tree. Which data structure requires fewest
comparisons in average to search an element stored in the data structure?

ANSWER :_ binary search tree

----------------------------

How do we include a user-defined library, say myMathLib.h, into a program that uses this library?

ANSWER :_ #include "myMathLib.h"

----------------------------

What is the key difference between a static variable and a global variable?

ANSWER :_ They have different visibility.

----------------------------

If a function calls another function, the local variables in these two functions use the memory from

ANSWER :_ different stack frames.

----------------------------

Given the snippet of code:

int x = 5;

int bar(int j) {
int *k = 0, m = 5;

k = &m;

return (j+m);

void main(void) {

static int i =0;

i++;

i = bar(i) + x;

ANSWER :_ CorrectB.

CorrectC.

CorrectD.

----------------------------

What is the best way of deleting a linked list of object in C++?

ANSWER :_ Use a loop to delete every object in the linked list

----------------------------

What memory must be garbage-collected by a destructor?

ANSWER :_ heap memory created in the constructors in the same class

----------------------------

What is the best way of deleting an array created by "p = new StructType[size];" in C++
ANSWER :_ delete[] p;

----------------------------

What is the best of deleting all the nodes in a binary tree pointed to by the root pointer?

ANSWER :_ Traverse the tree and delete each node individually.

----------------------------

Consider a path from the root to a leaf of a class tree based on the inheritance. Which class has the
most class members?

ANSWER :_ The class at the leaf of the tree.

----------------------------

The semantics of multiple inheritance becomes complex and error prone, if the base classes have

ANSWER :_ overlapped members.

----------------------------

If A is the base class and B is a class derived from A, then

ANSWER :_ class B has all the members of class A.

----------------------------

If you want to create a linked list of Container nodes, which can contain Publication node, Book
node, Thesis node, and Report node, what type of pointer should be declared in the Container to
point to all these nodes?

ANSWER :_ A pointer to Publication node

----------------------------

If you declare a pointer to the object of the parent class and use the pointer to access the object of a
child class, you can access

ANSWER :_ the members that exist in the parent class.

----------------------------

Given the following class definition and the variable declaration: How to initialize id
class employee

char *name;

long id;

class manager {

employee empl;

char* rank;

}x

ANSWER :_ x.empl.id = 12345;

----------------------------

Assume that Publication is the root class of an inheritance tree. You want to form a linked list of
different publications in the inheritance tree, including Book, Report, Newspaper, etc. What is the
best way to create a linked list using PublListNode and Publication classes?

ANSWER :_ The PublListNode class contains the Publication class.

----------------------------

It does not cause memory (storage) overhead to create multiple

ANSWER :_ names (alias) for a variable.

----------------------------

What type casting mechanism should be used if you want to cast an integer value to a double value?

ANSWER :_ static_cast

----------------------------

Given the following snippet of C++ code:

string name = "Hello";

ofstream myFile;

myFile.open(myFile);

myFile << name;


myFile.close();

What does it do?

ANSWER :_ It saves the word Hello into a file in the file system.

----------------------------

Which operators can be overloaded? Select all that apply

ANSWER :_ Correct

Correct

++

Correct

>>

----------------------------

A throw statement is associated with a specific exception handler through the

ANSWER :_ the data type implied by the throw value.

----------------------------

What keyword is used for defining an exception handler?

ANSWER :_ catch

----------------------------

In Scheme, the form (symbol-length? 'James) will return:

ANSWER :_ error message


----------------------------

In addition to functional programming, what other ideas are originated by John McCarthy?

ANSWER :_ space fountain

e-commerce

----------------------------

The statement "a function is a first-class object" means that a function

ANSWER :_ can be placed in a place where a value is expected.

----------------------------

Which of the followings is a valid Scheme form?

ANSWER :_ (* 9 (/ (- 4 2) 7))

----------------------------

Functional programming languages do NOT allow to define

ANSWER :_ variables whose value can be modified.

----------------------------

What data structure is used in Scheme for representing extremely large integers?

ANSWER :_ list

----------------------------

What is the return value of the code below?

(define lst '(3 5 2 9))

(min (min (car lst) (cadr lst)) (min (caddr lst) (cadddr lst)))

ANSWER :_ 2
----------------------------

Given this procedure, what is the return result?

(define (guess value)

(cond ((number? value) "I'm a number")

((char? value) "I'm a character")

((integer? value) "I'm a integer")))

(guess 10)

ANSWER :_ Correct

"I'm a number"

----------------------------

Given this procedure, what is the return result?

(define (guess value)

(cond ((number? value) "I'm a number")

((char? value) "I'm a character")

((integer? value) "I'm a integer"))

ANSWER :_ "I'm a number"

----------------------------

Functional programming language is more friendly to parallel computing, because it supports

ANSWER :_ Eager Evaluation

----------------------------

One of the major differences between the imperative and functional programming languages is that
the functional programming languages do NOT
ANSWER :_ have side-effect.

----------------------------

What notation requires parentheses in order to correctly define the order of computation?

ANSWER :_ infix notation

----------------------------

Convert the following expression into prefix-p notation (Scheme statement):

10 + (5 - 3) + 2 / 4

ANSWER :_ (+ 10 (- 5 3) (/ 2 4))

----------------------------

Given an expression: x1 + x2 + x3 + x4

Which language allows to evaluate the expression in this order: (1) x1 plus x2; (2) x3 plus x4; (3) sum
of ( x1 + x2 ) plus sum of ( x3 + x4 );

ANSWER :_ Scheme

----------------------------

How does Scheme implement the function such as: for (i = 1; i< 100, i++) {sum = sum + i;}

ANSWER :_ Use recursion

----------------------------

What functional feature does the code below best exhibit?

(define start-engine (lambda ()

(error-detection (wheel-velocity (wheel-sensor)) (body-velocity))))

ANSWER :_ procedures are first class object.

----------------------------
What statements contain non-functional features of Scheme? Select all that apply.

ANSWER :_ (begin (write x) x)

Correct

(display x)

----------------------------

For functional programming languages, the scope of a local name

ANSWER :_ is in the body part of the declaration or definition.

----------------------------

Given the Scheme code, answer the following two questions.

((lambda (x)

((lambda (x y)

(+ x y))

5 (* 7 x)))

3)

(1) The value to be passed to the parameter y is [y].

(2) The final output of the piece of code is [output].

ANSWER :_ 1) The value to be passed to the parameter y is Correct 21.

(2) The final output of the piece of code is Correct 26.

----------------------------

The Scheme form (char? #\5) will return

ANSWER :_ true (#t)


----------------------------

Given the Scheme code below, answer the following questions related the Fantastic Four abstract
approach.

(define dtob(lambda(N) ; line 1

(if (= 0)(list0) ; line 2

(append (dtob (quotient N 2)) ; line 3

(list (remainder N 2)))))) ; line 4

(1) What line of code defines the stopping condition and the return value? Choose [Size1]

(2) What line of code contains the size-M problem, where M < N? Choose [SizeM]

(3) What lines of code define the step that construct the solution to size-N problem? Choose
[SizeM_N

ANSWER :_ (1) What line of code defines the stopping condition and the return value? Choose
Correct Line 2

(2) What line of code contains the size-M problem, where M < N? Choose Correct Line 3

(3) What lines of code define the step that construct the solution to size-N problem? Choose Correct
Lines 3 & 4

----------------------------

What statement is accurate and correct?

ANSWER :_ There is only one Scheme list that is not a pair.

----------------------------

Which of the following is equivalent to the expression below?

(car (cdr '(1 2 3 4 5))


ANSWER :_ (cadr '(1 2 3 4 5))

----------------------------

What statements contain non-functional features of Scheme? Select all that apply.

ANSWER :_ Correct

(begin (write x) x)

Correct

(display x)

----------------------------

For functional programming languages, the scope of a local name

ANSWER :_ CorrectB.

is in the body part of the declaration or definition.

----------------------------

Given the Scheme code, answer the following two questions.

((lambda (x)

((lambda (x y)

(+ x y))

5 (* 7 x)))

3)

(1) The value to be passed to the parameter y is [y].

(2) The final output of the piece of code is [output].

ANSWER :_ (1) The value to be passed to the parameter y is Correct 21.


(2) The final output of the piece of code is Correct 26.

----------------------------

Given the Scheme code as follows. What is the output?

(define not-gate (lambda(x) (if (= x 0) 1 0)))

(define onescomplement (lambda (a-list) (map not-gate a-list)))

(onescomplement '(0 1 0 2 0 3))

ANSWER :_ CorrectA.

(1 0 1 0 1 0)

----------------------------

Given this procedure, what is the expected result?

(map (lambda (x) (+ x x 2)) '(1 2 3 4 5 6))

ANSWER :_ Correct

(4 6 8 10 12 14)

----------------------------

Compare the follow two Scheme forms:

(append '(1 2) '(4 5)) and (cons '(1 2) '(4 5)).

ANSWER :_ (cons '(1 2) '(4 5)) returns '((1 2) 4 5).

----------------------------

Which predicate logic matches most closely with this statement?

"Bill listens to music or news."


ANSWER :_ listensto(bill, music); listensto(bill, news).

----------------------------

A prolog program may contain: (Select all that apply.)

ANSWER :_ facts.

rules.

questions.

----------------------------

A goal succeeds, if there are facts (rules) that match or unify the goal. What are required in order for
a goal clause and a fact to unify? Select all that apply.

ANSWER :_ they have the same number of arguments.

their predicates are the same.

their corresponding arguments match.

----------------------------

A fact starts with a relationship followed by a list of arguments. The arguments of a fact

ANSWER :_ can have a structure similar to that of a fact.

----------------------------

The scope of a Prolog variable is

ANSWER :_ within a single fact, rule, or query.

----------------------------
What notation does Prolog use for expressing arithmetic operations?

ANSWER :_ CorrectB.

infix notation

----------------------------

Given these facts:

is_dessert(cookie).

is_dessert(ice_cream).

is_dessert(pie).

is_dessert(cheesecake).

is_fruit(strawberry).

is_fruit(apple).

is_fruit(peach).

contains(cookie, chocolate_chips).

contains(ice cream, cookie).

contains(ice cream, strawberry).

contains(ice cream, peach).

contains(pie, apple).

contains(pie, peach).

contains(pie, strawberry).

contains(cheesecake, strawberry).

Which of the following rule can help summarize all desserts that contains fruits:

ANSWER :_ Correct

fruit_dessert(X) :- is_dessert(X), is_fruit(Y), contains(X, Y).

----------------------------

Given this procedure, what is the expected result?


(map (lambda (x) (+ x x 2)) '(1 2 3 4 5 (6 7)))

ANSWER :_ Correct

Error Message

----------------------------

A higher order function is a function that takes the

ANSWER :_ CorrectC.

operator of a function as an argument.

----------------------------

In the following query language statement, which function acts as the filter function?

var myQuery = from b in Books where b.price < 80 orderby b.title select b;

ANSWER :_ C.

where

----------------------------

Which predicate logic matches most closely with this statement? Bill listens to music and the news

ANSWER :_ CorrectC.

listensto(bill, music); listensto(bill, news).

----------------------------

A goal succeeds, if there are facts (rules) that match or unify the goal. What are required in order for
a goal clause and a fact to unify? Select all that apply.

ANSWER :_ Correct
their corresponding arguments match.

Correct

their predicates are the same.

Correct

they have the same number of arguments.

----------------------------

A prolog program may contain: (Select all that apply.)

ANSWER :_ Correct

facts.

Correct

rules.

Correct

questions.

----------------------------

A fact starts with a relationship followed by a list of arguments. The arguments of a fact

ANSWER :_ CorrectA.

can have a structure similar to that of a fact.

----------------------------

The scope of a Prolog variable is


ANSWER :_ within a single fact, rule, or query.

----------------------------

You might also like