stacks and queues

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/46

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

47 Terms

1
New cards

T or F: The first item placed onto a stack is always the last item removed from the stack.

false

2
New cards

T or F: A dynamic stack starts as an empty linked list.

true

3
New cards

T or F: The pop function in the stack template of the STL does not retrieve the value from the top of the stack; it merely removes it.

true

4
New cards

T or F: The two most common queue operations are endeque and deque.

false

5
New cards

T or F: The STL provides containers for deque and queue.

false

6
New cards

T or F: A real-world example of the queue data structure can be seen in a stack of cafeteria trays where the last tray pushed onto the stack is the first tray removed.

false

7
New cards

T or F: In a static stack class, the constructor function can dynamically allocate memory for the stack array.

true

8
New cards

T or F: Stacks and queues can be implemented as arrays or linked lists.

true

9
New cards

T or F: The programmer must declare in advance the size of a dynamic stack or queue.

false

10
New cards

T or F: A stack that is implemented as a linked list is known as a deque.

true

11
New cards

T or F: The two most common queue operations are push and pop.

false

12
New cards

T or F: When the program knows the exact contents of a list and can access any element on demand, the data structure is known as a stacked deque.

false

13
New cards

T or F: For a compiler that is older than C++11 it is necessary to put spaces between the angled brackets that appear next to each other when defining a stack.

false

14
New cards

T or F: Computer systems use stacks. For example, when a function is called, they create local variables on a stack which are removed from the stack when the function terminates.

True

15
New cards

A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

stack

16
New cards

A dynamic stack has a ________ size and is implemented as a(n) ________.

variable, linked list

17
New cards

The ________ operation allows an item to be stored on a stack.

push

18
New cards

What does the following statement indicate?
stack< int, vector > iStack;

a new stack named vector, implemented as integers

19
New cards

Two primary queue operations are

enqueue and dequeue

20
New cards

The two primary stack operations are

push and pop

21
New cards

The ________ operation allows an item to be removed from the stack.

pop

22
New cards

A stack queue can be implemented as a

circular array

23
New cards

Which of the following is a double-ended queue?
- two-headed stack
- two-tailed vector
- circular array
- deque
- None of these

deque

24
New cards

A ________ stack or queue is built around the linked list.

dynamic

25
New cards

A container that provides quick access to elements at the front and the back of the list is a

deque

26
New cards

A ________ queue is more intuitive and easier to understand than a ________ queue.

dynamic, static

27
New cards

Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

first, last

28
New cards

Static stacks have a ________ size and are implemented as ________.

fixed, arrays

29
New cards

A dynamic stack may be implemented as a(n) ________ and can expand or shrink with each push or pop operation.

linked list

30
New cards

A queue is a data structure that stores and retrieves item in the ________ manner.

first in, last out manner

31
New cards

A ________ is processed in a manner similar to customers standing in a grocery store check-out line where the first customer in line is the first to be served.

queue

32
New cards

When an element is added to a queue, it is added to the rear. When an element is removed from the queue, it is removed from the

front

33
New cards

In a dequeue operation, the element at the ________ of the queue is removed.

front

34
New cards

A dynamic queue can be implemented as a

dynamic linked list

35
New cards

Queues that are implemented as arrays are called ________ queues.

static

36
New cards

If data is transmitted faster than it can be processed, it can be held in a ________ for processing.

queue

37
New cards

A stack can be adapted to store ________ data types.

all

38
New cards

Given the following code, assume the myStack object is a stack that can hold integers and that value is an int variable.


Assume that the pop function, called on line 4, stores the number popped from the stack in the value variable. What will the statement on line 5 display?

2

39
New cards

Given the following code, assume the myStack object is a stack that can hold integers and that value is an int variable.


Assume that the pop function, called on lines 4, 5, and 6, stores the number popped from the stack in the value variable. What will the statement on line 7 display?

0

40
New cards

Given the following code, assume the myStack object is a stack that can hold integers and that value is an int variable.


Assume that the pop function, called on lines 4 and 6, stores the number popped from the stack in the value variable. What will the statement on line 7 display?

3

41
New cards

Given the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable.


Assume that the dequeue function, called on line 4, stores the number removed from the queue in the value variable. What will the statement on line 5 display?

0

42
New cards

Given the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable.


Assume that the dequeue function, called on lines 4, 5, and 6, stores the number removed from the queue in the value variable. What will the statement on line 7 display?

2

43
New cards

Given the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable.


Assume that the dequeue function, called on lines 4 and 6, stores the number removed from the queue in the value variable. What will the statement on line 7 display?

1

44
New cards

Multiple answers: The Standard Template Library offers a stack template that may be implemented as a(n)

  • vector

  • primary type

  • linked list

  • deque

  • vector

  • linked list

  • deque

45
New cards

Multiple answers: The queue data structure is commonly applied in connection with

  • managing the order of print jobs

  • communications software

  • operating systems

  • None of these

  • managing the order of print jobs

  • communications software

  • operating systems

46
New cards

Multiple answers: Data structures that can dynamically store elements and can grow and shrink in size are

  • stacks

  • arrays

  • queues

  • deques

  • stacks

  • queues

  • deques

47
New cards

Multiple answers: A practical application of the stack data type in a computer system is

  • storage of local variables

  • tracking nested loops

  • tracking nested function calls

  • None of these

  • storage of local variables

  • tracking nested loops

  • tracking nested function calls