978-1337102087 Chapter 18

subject Type Homework Help
subject Pages 9
subject Words 843
subject Authors D. S. Malik

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 1
1. The bottom element of the stack is the last element added to the stack.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
1211
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
2. In the array representation of a stack, if a value called stackTop indicates the number of elements in the stack, then
stackTop-1 points to the top item of the stack.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
1216
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
3. If you try to add a new item to a full stack, the resulting condition is called an outflow.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
1220
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
4. In the linked implementation of stacks, the memory to store the stack elements is allocated statically.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
1234
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 3
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
1246
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
9. A queue is a First In First Out data structure.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
1259
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
10. A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.
a.
stack
b.
queue
c.
array
d.
linked list
ANSWER:
a
POINTS:
1
REFERENCES:
1210
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
11. The addition and deletion of elements of a stack occurs only at the ____ of the stack.
a.
head
b.
bottom
c.
top
d.
middle
ANSWER:
c
POINTS:
1
REFERENCES:
1210
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
12. The ____ element of the stack is the last element added to the stack.
page-pf4
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 4
a.
top
b.
bottom
c.
head
d.
tail
ANSWER:
a
POINTS:
1
REFERENCES:
1211
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
13. A stack is a(n) ____ data structure.
a.
FIFO
b.
FILO
c.
LIFO
d.
LILO
ANSWER:
c
POINTS:
1
REFERENCES:
1211
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
14. You can perform the add operation, called ____, to add an element onto the stack.
a.
pop
b.
push
c.
enqueue
d.
dequeue
ANSWER:
b
POINTS:
1
REFERENCES:
1211
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
15. You can perform the operation ____ to remove the top element from the stack.
a.
dequeue
b.
top
c.
pop
d.
push
ANSWER:
c
POINTS:
1
REFERENCES:
1211
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
page-pf5
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 5
16. A stack can be implemented as either a(n) ____ or a linked structure.
a.
map
b.
struct
c.
queue
d.
array
ANSWER:
d
POINTS:
1
REFERENCES:
1213
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
17. When a stack is implemented as an array, the array is empty if the value of stackTop is ____.
a.
zero
b.
one
c.
nonzero
d.
equal to the size of the array
ANSWER:
a
POINTS:
1
REFERENCES:
1216
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
18. If you try to add a new item to a full stack, the resulting condition is called a(n) ____.
a.
override
b.
overflow
c.
overload
d.
underflow
ANSWER:
b
POINTS:
1
REFERENCES:
1220
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
19. Popping an element from an empty stack is called ____.
a.
overflow
b.
underflow
c.
exception
d.
overloading
ANSWER:
b
POINTS:
1
REFERENCES:
1222
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
page-pf6
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 6
20. What is the output of the following code?
stackType<int> stack;
int x, y;
x = 5;
y = 3;
stack.push(4);
stack.push(x);
stack.push(x + 1);
y = stack.top();
stack.pop();
stack.push(x + y);
x = stack.top();
stack.pop();
cout << "x = " << x << endl;
cout << "y = " << y << endl;
a.
x = 5
y = 6
b.
x = 4
y = 3
c.
x = 5
y = 3
d.
x = 11
y = 6
ANSWER:
d
POINTS:
1
REFERENCES:
1227
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
21. The following expression (a - b) * (c + d) is equivalent to which of the following postfix expressions?
a.
a b c d - + *
b.
a b - c d + *
c.
a b - + c d *
d.
- + * a b c d
ANSWER:
b
POINTS:
1
REFERENCES:
1246
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
22. The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____.
a.
10
b.
30
c.
42
d.
44
ANSWER:
c
page-pf7
Name:
Class:
Date:
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
b.
it does not have enough operands
c.
it has too many operators
d.
there will be too many elements in the stack when the equal sign is encountered
ANSWER:
d
POINTS:
1
REFERENCES:
1247
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
27. A queue is a data structure in which the elements are ____.
a.
added to the rear and deleted from the front
b.
added to and deleted from the rear
c.
added to and deleted from the front
d.
added and deleted in the middle
ANSWER:
a
POINTS:
1
REFERENCES:
1259
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
28. Which of the following is listed in the chapter as a basic operation performed on a queue?
a.
push
b.
pop
c.
front
d.
top
ANSWER:
c
POINTS:
1
REFERENCES:
1260
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
12/20/2016 12:24 PM
29. What is the output of the following code?
queueType<int> queue;
int x, y;
x = 2;
y = 3;
queue.addQueue(x);
queue.addQueue(y);
page-pf9
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 9
x = queue.front();
queue.deleteQueue();
queue.addQueue(x + 2);
queue.addQueue(x);
queue.addQueue(y - 3);
y = queue.front();
queue.deleteQueue();
cout << "x = " << x << endl;
cout << "y = " << y << endl;
a.
x = 2
y = 4
b.
x = 4
y = 3
c.
x = 2
y = 3
d.
x = 3
y = 2
ANSWER:
c
POINTS:
1
REFERENCES:
1275-1276
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:44 PM
DATE MODIFIED:
10/5/2016 1:44 PM
30. What is the output of the following code?
queueType<int> queue;
int x, y;
x = 2;
y = 6;
queue.addQueue(x);
queue.addQueue(y);
x = queue.front();
queue.deleteQueue();
queue.addQueue(x + 2);
queue.addQueue(x);
queue.addQueue(y - 3);
while (!queue.isEmptyQueue())
{
cout << queue.front() << " ";
queue.deleteQueue();
}
cout << endl
a.
6 2 3 3
b.
6 2 4 2
c.
6 3 3 3
d.
6 4 2 3
ANSWER:
d
POINTS:
1
REFERENCES:
1275-1276
page-pfa
Name:
Class:
Date:
page-pfb
Name:
Class:
Date:
page-pfc
Name:
Class:
Date:

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.