C++ Programming banner
Fourth EditionD.S. Malik
Chapters:

Chapter 19

Self-Test

INSTRUCTIONS: Answer each question below. Click the 'Grade Test' button to receive a graded study guide. You will not get a grade until all questions are answered.

  1. In a linked queue, if the queue is empty, calling the function ____ will terminate the program.
    1. A:  front
    2. B:  isEmpty
    3. C:  isFull
    4. D:  initializeQueue
  2. The ____ of the queue is accessed whenever an element is deleted from the queue.
    1. A: back
    2. B: front
    3. C: middle
    4. D: None of the above
  3. The ____ operation retrieves the top element of the stack, but leaves the stack unchanged.
    1. A:  get
    2. B:  retrieve
    3. C:  top
    4. D:  pop
  4. The isEmptyStack function ____.
    1. A: initializes a stack to an empty state
    2. B: sets the size of a stack
    3. C: determines whether an item can be removed from a stack
    4. D: determines whether an item can be added to a stack
  5. When a stack class is derived from unorderedLinkedList , all of the following stack functions make a call to the base class EXCEPT ____.
    1. A:  top
    2. B:  push
    3. C:  pop
    4. D:  initializeStack
  6. The ____ constructor is called when a stack object is passes as a (value) parameter to a function.
    1. A: default
    2. B: copy
    3. C: initial
    4. D: overloaded
  7. If you try to remove an item from an empty stack, the resulting condition is called a(n) ____.
    1. A: underflow
    2. B: simulation error
    3. C: circular condition
    4. D: overflow
  8. It is best to use a(n) ____ to print a list backwards.
    1. A: linked implementation of a queue
    2. B: array-based implementation of a stack
    3. C: linked implementation of a stack
    4. D: array-based implementation of a queue
  9. In the serverListType class presented in this chapter, the value of ____ indicates that all the servers are busy.
    1. A:  -1
    2. B:  0
    3. C:  NULL
    4. D:  false
  10. An object that provides a service in a queuing system is called a _____.
    1. A: customer
    2. B: server
    3. C: transaction
    4. D: simulator
  11. In a linked queue, the definition of the destructor is similar to the definition of the ____ function.
    1. A:  deleteQueue
    2. B: copy constructor
    3. C: constructor
    4. D:  initializeQueue
  12. In the queuing system simulation presented in this chapter, the list of servers is stored in a(n) ____.
    1. A: dynamic array
    2. B: linked list
    3. C: linked queue
    4. D: array-based queue
  13. When popping elements off a linked stack, the stackTop pointer is ____.
    1. A: assigned the address of the popped element
    2. B: unchanged
    3. C: assigned the value -1 if the stack becomes empty
    4. D: assigned the address of its link
  14. A linked implementation of a queue is similar to a(n) ____.
    1. A: array-based implementation of a list
    2. B: array-based implementation of a stack
    3. C: linked list implementation created in a backward manner
    4. D: linked list implementation created in a forward manner
  15. The ____ operation of a stack adds a new element to the top of the stack.
    1. A:  push
    2. B:  insert
    3. C:  pop
    4. D:  top
  16. In a linked representation of a stack, the stack is considered to be full ____.
    1. A: when stackTop = NULL
    2. B: when stackTop = maxStackSize
    3. C: only if the computer runs out of memory
    4. D: if the stack is uninitialized
  17. In an array-based implementation of a queue, queueRear is initialized to ____.
    1. A:  maxQueueSize
    2. B:  maxQueueSize - 1
    3. C:  queueFront
    4. D:  maxQueueSize + 1
  18. A stack is a list of ____ elements.
    1. A: primitive
    2. B: immutable
    3. C: heterogeneous
    4. D: homogeneous
  19. Which of the following is the general loop condition to process the information of a stack?
    1. A:  while (stackTop == current)
    2. B:  while (stackTop != -1)
    3. C:  while (stack.isFull())
    4. D:  while (!stack.isEmptyStack())
  20. The initializeStack stack function ____.
    1. A: is called by the constructor
    2. B: sets the size of the stack
    3. C: calls the constructor
    4. D: initializes the stack to an empty state