Quiz 10

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Stacks and queues are typically implemented internally as an array or a linked list.

True

How would you access elements of an aggregated object (such as a collection) sequentially without exposing the underlying structure of the object?

Using an iterator The main intent of an iterator is to access the elements of an aggregate object sequentially without exposing its underlying representation.

Suppose, there is a 5-element queue Q (from front to back: 1, 2, 3, 4, 5, 6), and an empty stack S. If you remove the elements one-by-one from the queue Q and insert them into the stack S, then remove them one-by-one from the stack S and re-insert them into the queue Q. Then, finally how the queue will looks like (from back to front)?

1, 2, 3, 4, 5, 6 **NOT** 6, 5, 4, 3, 2, 1

Consider the situation where no other data structure like arrays, linked list is available to you. Then how many stacks are needed to implement a queue.

2

A stack is a data structure where we add elements on the top and remove the element, which has been added first.

False

Two of the basic operations of a queue are Push and Dequeue.

False Two of the basic operations of a queue is Enqueue and Dequeue

The stack provides 3 major operations: push (add an element at the top of the stack), pop (take the last added element from the top of the stack) and peek (get the element from the top of the stack without removing it).

True

The "queue" data structure is created to model queues, for example a queue of waiting for printing documents. Such queues are very convenient and are naturally modeled via the structure "queue". In queues we can add elements only on the back and retrieve elements only at the front.

True Yes. We can add the element into queue at front and remove the element from queue at back.

Stack is a restrictive data type in a sense that we cannot

remove from the bottom

Which one of the following is an application of Queue Data Structure?

When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes When a resource is shared among multiple consumers Load Balancing **All of the above


Ensembles d'études connexes

Accounting Information Systems (Bus 120B) Chapter 10 Study Guide

View Set

1. HISTORIA DE LA MEDICINA PARA MEDICOS DEL SIGLO XXI

View Set

Lesson 12: Trauma Overview, Ch. 24 - EMT.

View Set