BTE320 Chapter 17

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following is listed in the chapter as a basic operation performed on a queue? a. push b. pop c. isEmptyQueue d. top

c. isEmptyQueue

You can perform the operation ____ to remove the top element from the stack. a. dequeue b. top c. pop d. push

c. pop

A technique in which one system models the behavior of another system is called ____. a. imitation b. recursion c. simulation d. stimulation

c. simulation

The addition and deletion of elements of a stack occurs only at the ____ of the stack. a. head b. bottom c. top d. middle

c. top

What is the output of the following code? queueType<int> queue; int x, y; x = 2; y = 3; queue.addQueue(x); queue.addQueue(y); 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

c. x = 2 y = 3

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

d. 6 4 2 3

A stack can be implemented as either a(n) ____ or a linked structure. a. map b. struct c. queue d. array

d. array

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

d. there will be too many elements in the stack when the equal sign is encountered

In a(n) ____________________ simulation, the clock is implemented as a counter, and the passage of, say, one minute can be implemented by incrementing the counter by 1.

ANSWER: time driven time-driven

When describing a queuing system, we use the term ____________________ to refer to the time it takes to serve a customer.

ANSWER: transaction time

In a queuing system, every customer has a customer number, arrival time, ____________________ time, transaction time, and departure time.

ANSWER: waiting

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

True

The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared. a. True b. False

True

The infix expression (a + b) * (c - d / e) + f is equivalent to the postfix expression ab + cde /-* f + a. True b. False

True

The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____. a. 10 b. 30 c. 42 d. 44

c. 42

A stack is a(n) ____ data structure. a. FIFO b. FILO c. LIFO d. LILO

c. LIFO

To describe a queuing system, we use the term ____ for the object receiving the service. a. receiver b. server c. customer d. provider

c. customer

A queue is a First In First Out data structure. a. True b. False

True

The ____________________ constructor is called when a stack object is passed as a (value) parameter to a function.

ANSWER: copy

In ____________________ notation, operators are written after the operands.

ANSWER: postfix

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

ANSWER: 0 zero

____________________ techniques are used when it is too expensive or dangerous to experiment with real systems.

ANSWER: Simulation simulation

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

ANSWER: bottom

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

ANSWER: random

If you try to add a new item to a full stack, the resulting condition is called an outflow. a. True b. False

False

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

False

Postfix notation requires the use of parentheses to enforce operator precedence. a. True b. False

False

The bottom element of the stack is the last element added to the stack. a. True b. False

False

The expression a + b is the same in both infix notation and postfix notation. a. True b. False

False

Popping an element from an empty stack is called ____. a. overflow b. underflow c. exception d. overloading

b. underflow

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

a. added to the rear and deleted from the front

The postfix expression 3 5 + 2 ; 6 - = will generate an error, because it ____. a. contains an illegal operator b. does not have enough operands c. has too many operands d. has too many operators

a. contains an illegal operator

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

a. stack

The ____ element of the stack is the last element added to the stack. a. top b. bottom c. head d. tail

a. top

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

a. zero

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____. a. 4 b. 14 c. 24 d. 26

b. 14

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

b. a b - c d + *

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

b. one

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

b. overflow

You can perform the add operation, called ____, to add an element onto the stack. a. pop b. push c. enqueue d. dequeue

b. push

To describe a queuing system, we use the term ____ for the object that provides the service. a. client b. server c. customer d. provider

b. server

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

d. x = 11 y = 6

What is the output of the following code? stackType<int> stack; int x, y; x = 4; y = 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; a. x = 4 b. x = 5 c. x = 6 d. x = 9

d. x = 9


Kaugnay na mga set ng pag-aaral

AP STATS Chapter 1 : Stats starts here

View Set

Endocrine disorders, ICP, SCI/tumors, aneurysms

View Set

Chapter 16: Nursing Management During the Postpartum Period (Prep U)

View Set

Chapter 19 Connective Tissue Disorders

View Set