Deck 5: Algorithms
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/46
Play
Full screen (f)
Deck 5: Algorithms
1
Which of the following is not a type of statement found in a typical high-level imperative programming language?
A) Imperative statement
B) Exclamatory statement
C) Declarative statement
D) Comment statement
A) Imperative statement
B) Exclamatory statement
C) Declarative statement
D) Comment statement
B
2
Which of the following is not associated with object-oriented programming?
A) Inheritance
B) Resolution
C) Encapsulation
D) Polymorphism
A) Inheritance
B) Resolution
C) Encapsulation
D) Polymorphism
B
3
Which of the following is not a control statement?
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
C
4
Which of the following is not a possible value of the expression 4 + 6 /2 - 1
A) 4
B) 5
C) 6
D) 10
A) 4
B) 5
C) 6
D) 10
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following is not constructed by a typical compiler?
A) Source code
B) Symbol table
C) Parse tree
D) Object program
A) Source code
B) Symbol table
C) Parse tree
D) Object program
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following is not a control statement?
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following is not associated with the concept of data type?
A) Coercion
B) Boolean
C) Operator precedence
D) Strongly typed language
A) Coercion
B) Boolean
C) Operator precedence
D) Strongly typed language
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is ignored by a compiler?
A) Control statements
B) Declarations of constants
C) Procedure headers
D) Comment statements
A) Control statements
B) Declarations of constants
C) Procedure headers
D) Comment statements
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is an example of a language that is based on the functional paradigm?
A) LISP
B) PROLOG
C) C
D) C++
A) LISP
B) PROLOG
C) C
D) C++
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
10
Most machine languages are based on the
A) Imperative paradigm
B) Declarative paradigm
C) Functional paradigm
D) Object-oriented paradigm
A) Imperative paradigm
B) Declarative paradigm
C) Functional paradigm
D) Object-oriented paradigm
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements is not a resolvent of the following clauses? 

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
12
Positions within arrays are identified by means of numbers called
A) Indices
B) Parameters
C) Instance variables
D) Constants
A) Indices
B) Parameters
C) Instance variables
D) Constants
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is a means of nullifying conflicts among data types?
A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is a means of defining similar yet different classes in an object-oriented program?
A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following is the scope of a variable?
A) The number of characters in the variable's name
B) The portion of the program in which the variable can be accessed
C) The type associated with the variable
D) The structure associated with the variable
A) The number of characters in the variable's name
B) The portion of the program in which the variable can be accessed
C) The type associated with the variable
D) The structure associated with the variable
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following is not a parse tree of an expression based on the following grammar? 
A)
B)
C)




A)
B)
C)



Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following does not require a Boolean structure?
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
A) If-then-else statement
B) While loop statement
C) Assignment statement
D) For loop statement
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following is an example of a language that is based on the object-oriented paradigm?
A) LISP
B) PROLOG
C) C
D) C++
A) LISP
B) PROLOG
C) C
D) C++
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is not a step in the process of translating a program?
A) Executing the program
B) Parsing the program
C) Lexical analysis
D) Code generation
A) Executing the program
B) Parsing the program
C) Lexical analysis
D) Code generation
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is not a way of referring to a value in a program?
A) Variable
B) Literal
C) Constant
D) Type
A) Variable
B) Literal
C) Constant
D) Type
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
21
Explain the distinction between the imperative and declarative programming paradigms.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
22
In the context of the object-oriented paradigm, ____________ are templates from which
____________ are constructed. We say that the latter is an instance of the former.
____________ are constructed. We say that the latter is an instance of the former.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
23
Explain why the generation approach to classifying programming languages fails to capture the full scope of today's languages.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
24
What general rule should be added to the Prolog program below so that Prolog can conclude that ice cream is better than spinach?
better(icecream, peanutbutter).
better(peanutbutter, spinach).
___________________________________________________________
better(icecream, peanutbutter).
better(peanutbutter, spinach).
___________________________________________________________
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
25
What does it mean to say that a programming language is machine independent?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
26
List four data types that occur as primitive types in many high-level programming languages.
____________________ ____________________
____________________ ____________________
____________________ ____________________
____________________ ____________________
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
27
Based on the Prolog program below, what goal should be used to find the siblings of sue?
_________________________________________

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
28
To say that a grammar is ambiguous means that ___________________________________________
_____________________________________________________________________ .
_____________________________________________________________________ .
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
29
List two disadvantages of both machine languages and assembly languages that are overcome by high-level programming languages.
_____________________________________
_____________________________________
_____________________________________
_____________________________________
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
30
Rewrite the following instructions using a single if-then-else statement. 

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following can Prolog conclude from the following program? parent(jill, sue).
Parent(jill, sally).
Parent(john, sue).
Parent(john, sally).
Sibling(X, Y) :- parent(Z, X), parent(Z, Y).
A) parent(jill, john)
B) sister(sue, sally)
C) sibling(sue, sally)
D) sibling(jill, sue)
Parent(jill, sally).
Parent(john, sue).
Parent(john, sally).
Sibling(X, Y) :- parent(Z, X), parent(Z, Y).
A) parent(jill, john)
B) sister(sue, sally)
C) sibling(sue, sally)
D) sibling(jill, sue)
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
32
A data structure in which all elements have the same type is called ___________________, whereas a ________________ may have elements of different types.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
33
What clause would produce the resolvent
P OR R OR S
when resolved with the clause
P OR Q
__________________
P OR R OR S
when resolved with the clause
P OR Q
__________________
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
34
In addition to the procedure's name, what other information is contained in a typical procedure header?
____________________________________
____________________________________
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
35
Based on the sketch of a class definition below, which methods can be invoked from outside an instance of the class?
_________________________________________________________

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
36
Why is the straightforward "goto" statement no longer popular in high-level programming languages?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
37
In contrast to _______________ languages such as English and Spanish, programming languages are
considered _______________ languages and are rigorously defined by their grammars.
considered _______________ languages and are rigorously defined by their grammars.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
38
In the context of the object-oriented paradigm, a __________________ is an imperative program unit that describes how an object should react to a particular stimulus.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
39
Explain the distinction between translating a program (in a high-level language) and interpreting the program.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
40
Explain the distinction between a formal parameter and an actual parameter.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
41
Explain the distinction between a procedure and a function.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
42
Based on the grammar below, draw a parse tree showing that the string "drip drip drip" is a Leak. 

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
43
Explain why key words in a programming language are often reserved words.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
44
Show that the grammar below is ambiguous by drawing two distinct parse trees for the string "drip drip drip." 

Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
45
Explain the distinction between global and local variables.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
46
In the context of the object-oriented paradigm, what is a constructor?
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck