Filters
Question type

Study Flashcards

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

Correct Answer

verifed

verified

In the array representation of a stack, the stack is initialized simply by setting stackTop to ____________________.

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

In ____________________ notation, operators are written after the operands.

Correct Answer

verifed

verified

A queue is a First In First Out data structure.

Correct Answer

verifed

verified

The elements at the ____________________ of the stack have been in the stack the longest.

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

Postfix notation requires the use of parentheses to enforce operator precedence.

Correct Answer

verifed

verified

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.


A) 4
B) 14
C) 24
D) 26

Correct Answer

verifed

verified

In the linked implementation of stacks, the memory to store the stack elements is allocated statically.

Correct Answer

verifed

verified

In evaluating a postfix expression, when an equal sign (=) is encountered, how many elements must the stack contain so that no error is generated?


A) none
B) one
C) two
D) three

Correct Answer

verifed

verified

A stack is a(n) ____ data structure.


A) FIFO
B) FILO
C) LIFO
D) LILO

Correct Answer

verifed

verified

An array is a(n) ____________________ access data structure.

Correct Answer

verifed

verified

The postfix expression 14 2 5 + = will generate an error, because ____.


A) it contains an illegal operator
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

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

In the array representation of a stack, an unlimited number of elements can be pushed onto the stack.

Correct Answer

verifed

verified

The ____ element of the stack is the last element added to the stack.


A) top
B) bottom
C) head
D) tail

Correct Answer

verifed

verified

In a queuing system, we use a(n) ____________________ variable to set the status of the server.

Correct Answer

verifed

verified

A(n) ____________________ system consists of servers and queues of objects waiting to be served.

Correct Answer

verifed

verified

You can perform the add operation, called ____, to add an element onto the stack.


A) pop
B) push
C) enqueue
D) dequeue

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer