C++ Stacks & Queues
pointer
A ____________ is a variable whose value is the address of another variable. Like any variable or constant, you must declare a pointer before you can work with it.
class
A ___________________ is a templete in accordance to which objets are created.
abstract data type
An item specified in terms of operations is called an ?
A stack can be adapted to store ________ data types.
all
How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n + 1); } }
an infinite number of times
pointer variable
int = *p declares a_________________________
A dynamic stack may be implemented as a(n) ________, and expand or shrink with each push or pop operation.
linked list
The QuickSort algorithm is used to sort ________.
lists stored in arrays or linear linked lists
The queue data structure is commonly applied in connection with:
managing the order of print jobs, communications software, operating systems
If you try to add a new item to a full stack, the resulting condition is called a(n) ____. Group of answer choices override overflow overload underflow
overflow
The ________ operation allows an item to be removed from a stack.
pop
A(n)_____ is a list of homogeneous elements in which the addition and deletion of elements occurs only at one end.
stack
Data structures that can dynamically store elements and can grow and shrink in size are:
stacks, queues, deques
Queues that are implemented as arrays are called ________ queues.
static
A practical application of the stack data type in a computer system is:
storage of local variables tracking nested loops tracking nested function calls
The postfix expression 14 2 5 + = will generate an error, because ______.
there will be too many elements in the stack when the equal sign is encountered
The _____ element of the stack is the last element added to the stack.
top
The addition and deletion of elements of a stack occurs only at the ______ of the stack.
top
The QuickSort algorithm works on the basis of
two sublists and a pivot
The general form of a pointer variable declaration is −
type *var-name; int *ip; // pointer to an integer double *dp; // pointer to a double float *fp; // pointer to a float char *ch // pointer to character
store address of var in pointer variableint
var = 20; // actual variable declaration. int *ip; // pointer variable ip = &var; - Does what ? _________________________________________
A dynamic stack has a ________ size, and is implemented as a(n) ________.
variable, linked list
The Standard Template Library offers a stack template that may be implemented as a:
vector, deque, linked list
object
An _____________ is an instance of a class, an entity created using a class definition.
A stack is a(n) _______ data structure.
LIFO
data encapsulation
The combining of data and related operations is called __________________
A static queue can be implemented as a ________.
circular array
This is a container that provides quick access to elements at the front and the back of the list.
deque
This is a double-ended queue.
deque
A ________ stack or queue is built around the linked-list.
dynamic
A dynamic queue can be implemented as a ________.
dynamic linked list
________ queues are more intuitive and easier to understand than ________ queues.
dynamic, static
Two primary queue operations are:
enqueue and dequeue
A queue is a data structure that stores and retrieves items in this manner.
first in, first out
Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.
first, last
Static stacks have a ________ size, and are implemented as ________.
fixed, arrays
In a dequeue operation, the element at the ________ of the queue is removed.
front
When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the ________.
front
What is the output of the following code? stackType<int> stack; int x, y; x = 4; x = 2; stack.push(6); 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;
x = 9
When a stack is implemented as an array, the array is empty if the value of a stackTop is ______.
zero
The following statement stack< int, vector <int> > iStack; indicates:
a new stack of integers, implemented as a vector
A pointer variable
a variable whose content is a memory address
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: cout << value << endl; Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable. What will the statement in line 5 display?
0
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.pop(value); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?
0
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.enqueue(3); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?
1
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.dequeue(value); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in line 4, 5 and 6 stores the number removed from the queue in the value variable. What will the statement in line 7 display?
2
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: cout << value << endl; Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable. What will the statement in line 5 display?
2
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.push(3); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in line 4, 5 and 6, stores the number popped from the stack in the value variable. What will the statement in line 5 display?
3
The postfix expressions 5 6 + 4 * 10 5 / - = evaluates to ________.
42
The QuickSort algorithm was developed in 1960 by ________.
C.A.R. Hoare
If you try to add a new item to a full stack, the resulting conditions is called an outflow.
False
In the linked implementation of stacks, the memory to store the stack elements is allocated statically.
False
The bottom element of the stack is the last element added to the stack.
False
The expression a + b is the same in both infix notation and postfix notation.
False
functions
Functions defined in a class are called ____________
data value of a pointer
The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address.
The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.
True
What does & do
___________ denotes a reference instead of a pointer to an object
The ________ operation allows an item to be stored on a stack.
push
A stack has two primary operations:
push, pop
A ________ is processed in a manner similar to customers standing in a grocery check-out line—the first customer in line is the first served.
queue
If data is transmitted faster than it can be processed, it can be held in a ________ for processing.
queue
A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.
stack