Deck 6: Problem Solving With Abstract Data Types
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
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/60
Play
Full screen (f)
Deck 6: Problem Solving With Abstract Data Types
1
Which of the following strings is a palindrome?
A)"bottle"
B)"beep"
C)"coco"
D)"r"
A)"bottle"
B)"beep"
C)"coco"
D)"r"
D
2
The symbol AnBn is standard notation for the string that consists of ______.
A)an A,followed by an n,followed by a B,followed by an n
B)an equal number of A's and B's,arranged in a random order
C)n consecutive A's,followed by n consecutive B's
D)a pair of an A and a B,followed another pair of an A and a B
A)an A,followed by an n,followed by a B,followed by an n
B)an equal number of A's and B's,arranged in a random order
C)n consecutive A's,followed by n consecutive B's
D)a pair of an A and a B,followed another pair of an A and a B
C
3
Which of the following is a fully parenthesized expression?
A)x * y + z
B)(x * y)+ z
C)((x * y)+ z)
D)(x)* (y)+ (z)
A)x * y + z
B)(x * y)+ z
C)((x * y)+ z)
D)(x)* (y)+ (z)
C
4
Which of the following is a prefix expression?
A)/ a + b c
B)a b c + /
C)a * b + c
D)a / (b +c)
A)/ a + b c
B)a b c + /
C)a * b + c
D)a / (b +c)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following is an infix expression?
A)/ a + b c
B)a b c + /
C)a b / + c
D)a / (b +c)
A)/ a + b c
B)a b c + /
C)a b / + c
D)a / (b +c)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
6
If the string w is a palindrome,which of the following is true?
A)w minus its first character is a palindrome
B)w minus its last character is a palindrome
C)w minus its first and last characters is a palindrome
D)the first half of w is a palindrome
E)the second half of w is a palindrome
A)w minus its first character is a palindrome
B)w minus its last character is a palindrome
C)w minus its first and last characters is a palindrome
D)the first half of w is a palindrome
E)the second half of w is a palindrome
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
7
The symbol • means ______.
A)separate
B)concatenate
C)multiply
D)select
A)separate
B)concatenate
C)multiply
D)select
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
8
The correct grammar for the following language L: L = {w: w is of the form SnDn for some n ≥ 0}
Is ______.
A) = S | | D
B) = empty string | S | | D
C) = S D
D) = empty string | S D
Is ______.
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
9
In a grammar,the symbol x y means ______.
A)x or y
B)x followed by y
C)x or y or both
D)x multiplied by y
A)x or y
B)x followed by y
C)x or y or both
D)x multiplied by y
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
10
In the Eight Queens problem,each column can contain ______.
A)exactly one queen
B)exactly two queens
C)at most two queens
D)at most three queens
A)exactly one queen
B)exactly two queens
C)at most two queens
D)at most three queens
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
11
The statement: JavaPrograms = {strings w : w is a syntactically correct Java program}
Signifies that ______.
A)all strings are syntactically correct Java programs
B)all syntactically correct Java programs are strings
C)the JavaPrograms language consists of all the possible strings
D)a string is a language
Signifies that ______.
A)all strings are syntactically correct Java programs
B)all syntactically correct Java programs are strings
C)the JavaPrograms language consists of all the possible strings
D)a string is a language
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
12
An empty string ______.
A)has a length of 0
B)has a length of 1
C)is not a valid string
D)has a negative value for its length
A)has a length of 0
B)has a length of 1
C)is not a valid string
D)has a negative value for its length
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
13
______ is a problem-solving technique that involves guesses at a solution.
A)Recursion
B)Backtracking
C)Iteration
D)Induction
A)Recursion
B)Backtracking
C)Iteration
D)Induction
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
14
In the recursive solution to the Eight Queens problem,the problem size decreases by ______ at each recursive step.
A)one square
B)two squares
C)one column
D)two columns
A)one square
B)two squares
C)one column
D)two columns
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
15
A language is a set of strings of ______.
A)numbers
B)letters
C)alphabets
D)symbols
A)numbers
B)letters
C)alphabets
D)symbols
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following is a postfix expression?
A)/ a + b c
B)a b c + /
C)* a b c / +
D)a / (b +c)
A)/ a + b c
B)a b c + /
C)* a b c / +
D)a / (b +c)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
17
What is the value of the postfix expression: 6 7 + 8 2 - *?
A)-3
B)-10
C)48
D)78
A)-3
B)-10
C)48
D)78
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
18
The Java ______ determines whether a given string is a syntactically correct Java program.
A)applet
B)editor
C)compiler
D)programmer
A)applet
B)editor
C)compiler
D)programmer
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
19
In a grammar,the symbol x | y means ______.
A)x or y
B)x followed by y
C)x out of y
D)x divided by y
A)x or y
B)x followed by y
C)x out of y
D)x divided by y
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following strings is NOT a palindrome?
A)"madam"
B)""
C)"adam"
D)"deed"
A)"madam"
B)""
C)"adam"
D)"deed"
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following is NOT a valid postfix expression?
A)a b c - d *
B)a b - c d + -
C)a b c + /
D)a b * c + d *
A)a b c - d *
B)a b - c d + -
C)a b c + /
D)a b * c + d *
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
22
What is the value of the prefix expression: - * 3 8 + 6 5?
A)11
B)23
C)13
D)21
A)11
B)23
C)13
D)21
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
23
The expression:
(a +b)/ c
is a fully parenthesized expression.
(a +b)/ c
is a fully parenthesized expression.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following is NOT a valid prefix expression?
A)- + a b + c d
B)/ a + b c
C)* + * a b c d
D)* - a b c d
A)- + a b + c d
B)/ a + b c
C)* + * a b c d
D)* - a b c d
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
25
Infix expressions do not need precedence rules.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
26
A string of length 1 is not a palindrome.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
27
The stricter the definition of a language,the easier it is for a compiler to recognize a syntactically legal expression.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
28
The empty string is a palindrome.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
29
______ can be used to prove properties about recursive algorithms.
A)Prefix notations
B)Postfix notations
C)Induction
D)Backtracking
A)Prefix notations
B)Postfix notations
C)Induction
D)Backtracking
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
30
The Towers of Hanoi problem makes exactly ______ moves when it starts with N disks.
A)2ⁿ
B)2ⁿ - 1
C)N²
D)N³ - 1
A)2ⁿ
B)2ⁿ - 1
C)N²
D)N³ - 1
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following is true about algebraic expressions?
A)parentheses are needed in all algebraic expressions
B)infix expressions do not require precedence rules
C)postfix expressions do not require association rules
D)fully parenthesized expressions are difficult to recognize and evaluate
A)parentheses are needed in all algebraic expressions
B)infix expressions do not require precedence rules
C)postfix expressions do not require association rules
D)fully parenthesized expressions are difficult to recognize and evaluate
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following is the prefix form of the infix expression: (8 + 6)/ (16 - 4)?
A)+ 8 6 / - 16 4
B)/ 8 6 + - 16 4
C)/ + ?- 8 6 16 4
D)/ + 8 6 - 16 4
A)+ 8 6 / - 16 4
B)/ 8 6 + - 16 4
C)/ + ?- 8 6 16 4
D)/ + 8 6 - 16 4
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
33
If the string w is a palindrome,the first and last characters of w are the same.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
34
Induction can be used to prove that a recursive algorithm is correct.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
35
Parentheses are not necessary in prefix expressions.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following is the postfix form of the prefix expression: * + a b c?
A)a + b * c
B)a + b c *
C)a b + c *
D)a b * c +
A)a + b * c
B)a + b c *
C)a b + c *
D)a b * c +
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
37
The following string is a valid prefix expression:
+ * a b c d
+ * a b c d
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following is the postfix form of the infix expression: a * b - (c +d)?
A)a b c d + - *
B)a b * c d + -
C)a b c - * d +
D)a b c - d + *
A)a b c d + - *
B)a b * c d + -
C)a b c - * d +
D)a b c - d + *
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
39
According to the following statement:
JavaPrograms = {strings w : w is a syntactically correct Java program}
all strings are Java programs.
JavaPrograms = {strings w : w is a syntactically correct Java program}
all strings are Java programs.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
40
What is the value of the infix expression: 8 * (5 - 2)?
A)16
B)24
C)38
D)40
A)16
B)24
C)38
D)40
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
41
What is a fully parenthesized expression?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
42
What is backtracking?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
43
What is a recognition algorithm?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
44
What is meant by a grammar?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
45
For defining palindromes,why is it not enough to use just the empty string as a base case?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
46
Describe in your own words the language defined by this recursive definition:
< S > = @ | < W > | @ < S >
< W > = aab | aa < W > b
< S > = @ | < W > | @ < S >
< W > = aab | aa < W > b
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
47
Write a recursive definition for the set of positive odd numbers.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
48
What is the main benefit of using a grammar that is recursive?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
49
What are the two base cases in a recursive description of a palindrome?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
50
Explain how you would design a method,returning boolean,that determines if a string passed as a parameter satisfies this recursive definition.
< S > = < W > < W >
< W > = a | b | a < W > | b < W >
< S > = < W > < W >
< W > = a | b | a < W > | b < W >
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
51
What is an empty string?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
52
How can precedence and association rules be avoided in infix notation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
53
When is the base case of the Eight Queens problem reached?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
54
What is the advantage of using prefix or postfix expressions instead of infix expressions?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
55
What is a closed-form formula?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
56
What is a prefix expression?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
57
According to the following statement:
JavaPrograms = {strings w : w is a syntactically correct Java program}
when is a given string a member of the language JavaPrograms?
JavaPrograms = {strings w : w is a syntactically correct Java program}
when is a given string a member of the language JavaPrograms?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
58
What is an infix expression?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
59
What is a postfix expression?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
60
What is the procedure for proving a statement by mathematical induction?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck