CSE 240 Final

Ace your homework & exams now with Quizwiz!

What should be listed in a header file (.h file)?

- Constants that you want to share - Forward declaration of the functions that you want to share

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

- 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?

- item size - source - number of items - destination

Assume that the search function of a linked list is specified by struct Terminal* search(); What values can the search function return?

- the address of a terminal node - 0

A pointer variable can take the address of a memory location as its value. Read the given program. #include <stdio.h> main() { int m = 30, n = 40, *p, *q, **r; p = &m; *p = 60; q = &n; *q = 80; r = &p; **r = 100; printf("%d\n", m); // 1st printf statement printf("%d\n", n); // 2nd printf statement m = 30; n = 90; printf("%d\n", **r); // 3rd printf statement } 1.The output of the 1st printf statement is ___. 2. The output of the 2nd printf statement is ____. 3.The output of the 3rd printf statement is ____.

100, 80, 30

Given this snippet of code, what is the value of x after executing the last statement? int x = 10, **y* , **z; y = &x; z = &y; ***z = 1000;

1000

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;

68 bytes

What is the result of this expression (in Scheme)? (let ((x 10) (y 10)) (- (* x y) y))

90

If you would like to see accurate debugging information, which of the following program processing would you recommend? A. Interpretation B. Compilation C. Both compilation and interpretation provide the same level of debugging information. D. Some time compilation is better than interpretation, but other time interpretation is better than compilation

A. Interpretation

A data type defines the A. values and operations allowed B. life time and visibility C. location and address D. reference and pointer

A. values and operations allowed

Assume a variable is declared in a block of code within a pair of curly braces. The scope of the variable ______ A. covers the entire block, including the code before the declaration point. B. starts from its declaration point and extends to the end of the block. C. starts from its declaration point and extends to the end of the entire program. D. covers the entire program, including the code in the other blocks.

B. starts from its declaration point and extends to the end of the block

The imperative programming paradigm is popular and is a part of object-oriented computing paradigm, because it ____ (Select all answers that apply). A. supports class inheritance and code reuse. B. enforces the modularity and supports the development of large programs. C. is based on computer organization and thus is efficient to execute on hardware. D. matches the culture of doing things by following the step-wise instructions.

C, D

Java uses which of the following program processing? A. Interpretation B. Compilation C. Two Step Translation with Intermediate Code -- (Compilation + Interpretation) D. Two Step Translation without Intermediate Code

C. Two step translation with intermediate code

Which of the following orthogonality describes this example: If a block allows one statement, it should allow zero or more statements within that same block. A. Compositional Orthogonality B. Sort Orthogonality 1 C. Sort Orthogonality 2 D. Number Orthogonality

D. Number orthogonality

Which of the following types is a C++ type, but NOT a C type? A. char B. void C. double D. bool

D. bool

In C++ what function can be used to input a string with spaces? A. scanf("%s", &str); B. cin >> str; C. scanf.getline(...); D. cin.getline(...);

D. cin.getline(...);

What programming language characteristics impact the readability of the programs written in this language? Data structures Type checking Control structures Syntax design

Data structures, control structures, syntax design

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

Eager Evaluation

We use "Pass by Reference" when:

Function wants to modify the value, the value is expensive to copy and NULL is not valid

We use "Pass by Pointer" when

Function wants to modify the value, the value is expensive to copy and NULL is valid

Which of the following coding practice can lead to a higher memory efficiency (use fewer padding bytes) in defining a structure?

Keep the character type variables together.

What mechanism defines tail recursion?

The calculated answer is propagated to each layer of the recursion through the parameters

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

The class at the leaf of the tree.

When will the buffer be created?

When the file operation fopen is performed.

In the implementation of the getMax() function in the PriQueue class, we need to read and write the variables "front" and "rear", which are defined as protected members in the base class Queue. Are the functions in the derived class allowed to access the protected members in the base class?

Yes, always.

von Neummann Architecture is

a state based programming structure which loads and interprets instructions from memory into action

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

at the position to keep the entire tree as a binary search tree

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?

binary search tree

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

can be placed in a place where a value is expected

What C/C++ constant variable can potentially be modified during the execution?

const x = 5;

Given this snippet of code, identify what is the size-m (sub-divided) problem? void deleteList(struct contact* node) { if (node != NULL) { deleteList(node->next); free(node); } else return; }

deleteList(node->next);

What is a feature of object-oriented programming?

encapsulation of states

"When piloting a helicopter - changing speed can/will change you r direction and possible vice versa" This quote demonstrates that changing speed and/or direction is Orthogonal t/f

false

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; t/f

false

Node* root; struct Node { int data; Node* left; Node* right; } Node* findIt(int item) Node** *helpFindIt(Node* current, int item) What's the recursive case of helpFindIt?

if(item > current->data) return helpFindIt(current->right, item) if(item < current->data) return helpFindIt(current->left, item)

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

infix notation

What operations will acquire memory from heap? Select all that apply.

malloc new

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

overlapped members

Given the information below, how do you insert a new node, p, to the beginning of a linked-list. Assume head is pointing to the first node in the linked-list. struct Terminal { char name[30]; char location[32]; struct Terminal* next; } **head*, *p;

p->next = head; head = p;

What functional feature does the code below best exhibit? (define start-engine (lambda () (error-detection (wheel-velocity (wheel-sensor)) (body-velocity))))

procedures are first class object

char a[] = "Hello"; char **p* = a, *q; what operations are valid syntactically?

q = &(*p); **q* = *(&a[0]);

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

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

Which command will have a loop when expressed in a syntax graph?

switch

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?

temp = head; head = head->next; free(temp);

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; t/f

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: myvar = (x + y) * (a - c); t/f

true

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

true

How many bytes is this array? double doubleList[10]

80 (array of doubles)

How many bytes is this array? int*** multDimArray[20];

80 (array of triple pointers)

This evaluation is concerned with the internal safety and consistency of the language.... type checking, exceptions, etc. a. efficiency b. reliability c. readability d. write-ability e. reusability

b. reliability

This analysis describes the structure of the language devoid of meaning a. lexical b. syntactical c. contextual d. semantics

b. syntactical

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

delete[] p;

Given this snippet of code, identify what is the stopping condition (base case) and return value? void deleteList(struct contact* node) { if (node == NULL) return; else { deleteList(node->next); free(node); } }

if (node == NULL) return;

Integers, floats, and doubles are highly versatile in memory and can be addressed to any byte. t/f

false

Orthogonality is when features of a programming language are intertwined heavily with each other. Using a feature may lead to side-effects with other features t/f

false

Pointers contain memory addresses for other variables, but there are no means to access or change the contents of those variables t/f

false

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: 99problems = (98) + (1); t/f

false

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: Alb2 = 1 + 1; t/f

false

What computing paradigm enforces stateless (no variables allowed) programming?

functional

What advantages does maintaining a tail pointer really do for us in a linked list?

gives us both an ending to look for and speeds up a few specific operations

Assume that you want to delete the entire linked list pointed to by head. Which of the following deletion operation will cause the most garbage of memory?

head = null;

The memory must be explicitly garbage-collected, if the memory comes from

heap

Dynamic memory allocation; when using "new" "malloc"

heap memory

What memory must be garbage-collected by a destructor?

heap memory created in the constructors in the same class

We need to write a destructor for a class, if

heap memory is used in the constructor of the class.

Allocated for all non-static "local" variables; goes out of scope when leaving the brackets in which it was declared

stack memory

Global and static variables are this kind of memory

static

Allocated during compilation before a program executes; goes out of scope when the program terminates

static memory

A struct, if not built correctly, could actually cause a lot fo wasted RAM t/f

true

C++ was designed to bring Object Orientation to C. In fact it was originally released with the unimaginative name "C with Classes" t/f

true

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)

"I'm a number"

Which of the followings is a valid Scheme form?

(* 9 (/ (- 4 2) 7))

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

- e-commerce - space fountain

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); What value will be printed for variable x? What value will be printed for variable y?

6 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?

68

C/C++ has 2 pointer operators, which operator will return the address of variable?

Ampersand (&)

During compilation, linker is used for ____________. A. resolving conflicts within your program. B. translating Assembly program to binary code. C. resolving external references (bring in code from other libraries). D. translating a High Level-Language program to assembly code/machine code.

C. Resolving external references (bring in code from other libraries)

If your program was designed to print "Hello World" ten times, but during execution it printed eleven times, what type of error is this?

Semantics error

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

They have different visibility.

What will assign the address of the variable int myInt to the pointer int* myPtr?

int* myPtr = &myInt;

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; } Which variables obtain their memory from the stack?

j k m

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

leaves a character in the file buffer.

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

list

A let-form in Scheme defines a set of

local names

letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is ZYA85 valid?

no

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

removing Goto statements from the language

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

return the memory held by x to the free memory pool.

Convert the following expression into prefix-p notation (Scheme statement): 10 + (5 - 3) + 2 / 4

(+ 10 (- 5 3) (/ 2 4))

What will allow me to give the value of 10 to the memory int* myPtr points to?

*myPtr = 10;

Which of the following statements are correct if a language is strongly typed. Select all that apply. A. Each name in a program has a single type associated with it B. Type errors are always reported C. Type is not known at compilation time D. All of the above

A, B

Given a declaration: char a[] = "Hello World"; What is the size (in bytes) of the array a[]? A. 12 B. 10 C. 44 D. 11

A. 12 (remember the '/0' bc we're initializing it as a string)

Given the following code, what is the expected value for z? #define func(x, y) (x > y) ? y++ : x++ int main() { int x = 10; int y = 9; int z = func(x, y); } A. 9 B. 10 C. 11 D. 12

A. 9

Given this snippet of code in C, char alpha = 'a'; int numeric = alpha + 10; which of the following statements is correct: A. syntactically correct, but contextually incorrect B. syntactically incorrect, but contextually correct C. syntactically correct, and contextually correct D. Syntactically incorrect, and contextually incorrect.

A. Syntactically correct, but contextually incorrect

Which implementation of a function has potentially the best performance in terms of execution speed? A. macro B. interpretation C. normal function D. inline function

A. macro

Where is the main ( ) function located in a C or C++ program? A. outside any class B. in all classes C. in any one class D. in the Main class

A. outside any class

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

Asterisk (*)

Given this snippet of code, determine which of the following options will change the text in array to "Hello Doe" after execution. (Check all that applies.) char array[] = "Hello Joe"; char *x; A. x = array; *(x + 6) = 'D'; B. x = &array[0]; x = x + 6; *x = 'D';

B.

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]; A. a = "hi"; B. a[0] = 'h'; C. a[] = {'h', 'i'}; D. a = "h";

B. a[0] = 'h'

Which of the following C declarations (contextual level) will cause a compilation error? A. int c[] = {'a', 'b', '\0'}; B. int d[]; C. int a[] = {12, 24}; D. int b[2];

B. int d[ ];

A final method in Java defines A. a normal function. B. a macro. C. an in-line function. D. a constant.

C. an in-line function

We use "Pass by Value" when:

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

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?

It prints: carbike

Can the identifier "base_variable" be created from the following BNF ruleset? <char> ::= a | b | c | ... | s | ... | x | y | z <identifier> ::= <char> | <char> <identifer>

No - there is an underscore in the identifier name that cannot be generated

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.

Resusability

What cannot be checked by an imperative or object-oriented compiler

Semantics

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

Use recursion

What's are the benefits of Tail Recursion?

Well written compilers can take advantage of it to limit RAM usage and perform other optimizations.

The search algorithm will be more efficient if a binary search tree is

a balanced binary tree

Given: letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is the following sequence valid? abcSWX246

no

letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is CSE240 valid?

no

Which of the following expression will return false (#f)?

(number? #\7)

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

*myPtr = 10;

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. - their predicates are the same. - their arity must be different. - they have the same number of arguments. - their corresponding arguments match.

- their predicates are the same. - they have the same number of arguments. - their corresponding arguments match.

What's the size of this struct? struct record4 { int a; int c; float e; char b; char d; };

16

If I have a double pointer named dPtr and I add 2 to it dPtr = dPtr + 2; how many bytes does the address move?

16 (8 * 2)

If I have a struct that contains - 3 int - 2 doubles - char[65] - int* - double[10] What would be the smallest struct size in bytes a programmer could make by arranging the variables correctly?

184

Given this expression, what is the expected result? (car (cdr '(1 2 3 4 5))

2

What's the size of this struct? struct record3 { int a; char b; int c ; char d; float e; };

20

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 __________ (2) The final output of the piece of code is __________

21 26

What is the size of this struct? struct record1 { double x; char p[10]; char c; int a; };

24

What is the size of this struct? struct record1 { char p[10]; double x; char c; int a; };

32

Given the following struct typedef struct { char p[10]; double x; char c; int a; } record1; What is the size of this struct?

32 bytes

A pointer is how many bytes?

4

If I have a character pointer named charPtr and I add 4 to it (charPtr = charPtr + 4;) how many bytes does the address move?

4 (4 * 1)

A double is how many bytes?

8

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)) A. (1 0 1 0 1 0) B. (0 1 0 1 0 1) C. (1 0 0 0 0 0) D. Error message

A. (1 0 1 0 1 0)

Compare the follow two Scheme forms: (append '(1 2) '(4 5)) and (cons '(1 2) '(4 5)). A. (cons '(1 2) '(4 5)) returns '((1 2) 4 5). B. Both return "Error". C. (append '(1 2) '(4 5)) returns '((1 2) 4 5). D. Both return: '(1 2 4 5).

A. (cons '(1 2) '(4 5)) returns '((1 2) 4 5).

A fact starts with a relationship followed by a list of arguments. The arguments of a fact A. can have a structure similar to that of a rule. B. can have a structure similar to that of a fact. C. must be variables. D. must be simple values.

B. can have a structure similar to that of a fact.

We apply an anonymous variable in the definition of a rule if we A. want to make the variable a private variable. B. do not want to obtain a return value to the variable. C. want to obtain a return value to the variable. D. want to make the variable a public variable.

B. do not want to obtain a return value to the variable.

What notation does Prolog use for expressing arithmetic operations? A. prefix notation B. infix notation C. postfix notation D. BNF notation

B. infix notation

A Prolog variable represents a A. memory location. B. place holder. C. constant. D. question.

B. place holder.

The key idea of logic programming paradigm is to solve a problem by describing A. the problem in a set of mathematic formulas. B. what the problem is. C. how to solve the problem in steps. D. where the problem comes from.

B. what the problem is.

Given this procedure, what is the expected result? (map (lambda (x) (+ x x 2)) '(1 2 3 4 5 6)) A. (1 2 3 4 5 6) B. (4 6 8 10 12) C. (4 6 8 10 12 14) D. Error Message

C. (4 6 8 10 12 14)

Given the following Scheme definition: (define reduce (lambda (op base x) (if (null? x) base (op (car x) (reduce op base (cdr x)) ))) ) What parameter passing mechanism is used for the parameter op in this code? A. Call-by-address B. Call-by-reference C. Call-by-name D. Call-by-value

C. Call-by-name

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 rules can identify the list of desserts that contains apple? A. apple_dessert(X) :- is_dessert(X), is_fruit(X). B. apple_dessert(X) :- is_dessert(X); contains(X, apple). C. apple_dessert(X) :- is_dessert(X), contains(X, apple). D. apple_dessert(X) :- is_dessert(X), contains(X, _).

C. apple_dessert(X) :- is_dessert(X), contains(X, apple).

Which predicate logic matches most closely with this statement? "Bill likes chocolate and cookies." A. likes(bill, chocolate, cookies, icecream). B. bill(likes, chocolate), bill(likes, cookies). C. likes(bill, chocolate), likes(bill, cookies). D. likes(bill, chocolate); likes(bill, cookies).

C. likes(bill, chocolate), likes(bill, cookies).

What is a good rule of thumb for sizing a Struct in C/C++ assuming that the Struct is optimally set up?

Count all the bytes of the data in the struct. Find the nearest power of 2, 4 or 8 based on the largest Data Type in your struct. If the total number of bytes is larger than that power, then the struct will be the next power in size.

Given this procedure, what is the expected result? (map (lambda (x) (+ x x 2)) '(1 2 3 4 5 (6 7))) A. (1 2 3 4 5 6) B. (2 4 6 8 10 12) C. (4 6 8 10 12 14) D. Error Message

D. Error Message

Filter is a higher-order function that A. reduces a list of elements to a single element. B. can check the equality of all types of data. C. allows a variable number of arguments. D. applies a predicate to all elements of a list.

D. applies a predicate to all elements of a list.

The scope of a Prolog variable is A. within the factbase. B. from its declaration to the end of the file. C. within the factbase and rulebase in the file. D. within a single fact, rule, or query.

D. within a single fact, rule, or query.

Which part of RAM must be explicitly garbage collected by the C/C++ programmer?

Heap

What is the tradeoff in Linked Lists?

The linked list has no exploitable memory structure, so many of its operations are slow (usually O(n) time) but it's always as big as we need it to be

What statement is accurate and correct? All Scheme lists are pairs There is only one Scheme list that is not a pair There is only one Scheme pair that is not a list All Scheme pairs are lists

There is only one Scheme list that is not a pair. (empty list)

This type of error is created when a programming statement is formed correctly, but it is not built from the correct components (such as datatype mismatches, etc) a. lexical b. syntactical c. contextual d. semantics

c. contextual

This evaluation is concerned with the simplicity and understandability of the language.... features, constructs, orthogonality, etc. a. efficiency b. reliability c. readability d. write-ability e. reusability

c. readability

Which programming paradigm primarily focuses on the "how" of programming and the step-by-step execution of algorithms? a. object-oriented b. service-oriented c. functional d. imperative/procedural

d. imperative/procedural

This type of error usually occurs during run-time when correctly formed statements do exactly what the programmer typed but not what the programmer wanted a. lexical b. syntactical c. contextual d. semantics

d. sematics

A struct is simply object-orientation for C and has all of the features of OOP in C t/f

false

What condition should we always check when doing any insert (but especially an arbitrary insert ) into a linked list?

is this first or second item into an empty/nearly empty linked list

(define dtob (lambda (N); line 1 (if (= N 0) (list 0); 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? (2) What line of code contains the size-M problem, where M < N? (3) What lines of code define the step that construct the solution to size-N problem?

line2, line 3, lines 3 & 4

In most of out linked list algorithms we have to be wary of the order we assign and reassign pointers, this is because if we don't maintain the fidelity of the list we will cause memory leaks. t/f

true

Stacks and queues are merely super-specialize derivatives of a linked list, but they are valuable for their specific behaviors. t/f

true

Structs are one of the reasons to use pass-by-reference parameters in your functions t/f

true

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; t/f

true

When a struct is dynamically allocated to a pointer we use the -> operator to access members of the struct t/f

true

While pointers have a specific job, they are still variables having a location in memory and a name and a size. t/f

true

Given this snippet of code, identify what is the size-n (whole) problem? void deleteList(struct contact* node) { if (node != NULL) { deleteList(node->next); free(node); } else return; }

void deleteList(struct contact* node)

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;

x->name

letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is abc135 valid?

yes

letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is bWX13 valid?

yes

letter ::= a | b | c | d | e LETTER ::= V | W | X | Y | Z number ::= 1 | 3 | 5 | 7 | 9 letters ::= <letter> | <letter><letters> LETTERS ::= <LETTER> | <LETTER><LETTERS> numbers ::= <number> <number> | <number> <numbers> sequence ::= <letters> (LETTERS) <numbers> | <LETTERS> (letters) <numbers> Is eY11 valid?

yes


Related study sets

25: Fluid, Electrolyte, and Acid-Base Balance Questions Full

View Set

Chapter 28 Child, Older Adult, and Intimate Partner Abuse

View Set

AP Biology Free Response Questions

View Set

Writing and Endorsing a Check and Deposit Slip

View Set

FUNDAMENTALS OF SURVEYING - LECTURE

View Set