Data Structures Test 2 Review Queues Flashcards

1
Q

Singly Linked List

A

a structure consisting of a sequence of nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A singly linked list stores a _________ to the first node (head) and last (tail)

A

pointer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In a singly linked list, each node stores…

A

an elementa link to the next node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

template class SLinkedListNode { public: Type elem; [WHAT GOES HERE?] };

A

SLinkedListNode *next;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Singly Linked List Operation: insertFront(e):

A

inserts an element on the front of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Singly Linked List Operation: removeFront():

A

returns and removes the element at the front of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Singly Linked List Operation: insertBack(e):

A

inserts an element on the back of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Singly Linked List Operation: removeBack():

A

returns and removes the element at the end of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Stack with a Singly Linked List: The _______ element of the stack is the ______ ______ of the list

A

topfirst node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stack with a Singly Linked List: The space used is ______ and each operation of the Stack ADT takes _______ time

A

O(n)O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Stack Operation: push(e) is most like what Singly Linked List Operation?

A

insertFront(e)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Stack Operation: pop() is most like what Singly Linked List Operation?

A

removeFront()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What 2 Singly Linked List Operations do not work with Stack Operations?

A

insertBack(e)removeBack()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

With minor alteration or addition, top() could be very similar to…

A

removeFront()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

_______ and ________ would require the addition of a counter that increments each time push() is called and decrements when pop() is called

A

size() isEmpty()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Queues store…

A

arbitrary objects

17
Q

Main queue operations:

A

enqueue(e)dequeue()

18
Q

Enqueue(e): aka addQueue, aka push

A

inserts an element at the end of the queue

19
Q

Dequeue(): aka deleteQueue, aka pop

A

removes and returns the element at the front of the queue

20
Q

Auxiliary queue operations:

A

front()size()isEmpty()

21
Q

Less common queue operations

A

back()isFullQueue()

22
Q

front():

A

returns the element at the front without removing it

23
Q

size():

A

returns the number of elements stored

24
Q

isEmpty():

A

returns a Boolean value indicating if there are no elements in the queue

25
back():
returns the element at the back without removing it
26
isFullQueue():
returns if queue is full
27
In a queue, insertions are at the _____ of the queue and removals are at the ______ of the queue
endfront
28
Queue exceptions: Attempting to execute dequeue or front on an empty queue throws a(n)...
EmptyQueueException
29
template class queueADT { public: virtual bool isEmptyQueue() const = 0; }
// function to determing whether the queue is empty// post condition: returns true if the queue is empty, otherwise returns false
30
template class queueADT { public: virtual bool isFullQueue() const = 0; }
// function to determine whether the queue is full// post condition: returns true if the queue is full, otherwise returns false
31
template class queueADT { public: virtual void initializeQueue() const = 0; }
// function to initialize the queue to an empty state// post condition: the queue is empty
32
template class queueADT { public: virtual Type front() const = 0; }
// function to return the first element of the queue// precondition: the queue exists and is not empty// post condition: if the queue is empty, the program terminates; otherwise, the first element of the queue is returned
33
template class queueADT { public: virtual Type back() const = 0; }
// function to return the last element of the queue// precondition: the queue exists and is not empty// post condition: if the queue is empty, the program terminates; otherwise, the first element of the queue is returned
34
template class queueADT { public: virtual void addQueue(const Type& queueElement) = 0; }
// function to add queueElement to the queue// precondition: the queue exists and is not full// post condition: the queue is changed and queueElement is added to the queueaka pushaka enqueue
35
template class queueADT { public: virtual void deleteQueue() const = 0; }
// function to remove the first element of the queue// precondition: the queue exists and is not empty// post condition: the queue is changed and the first element is removed from the queueaka popaka dequeue
36
Main queue operation: enqueue(e) is most like what Singly Linked List Operation?
insertBack(e)
37
Main queue operation: dequeue() is most like what Singly Linked List Operation?
removeFront()
38
Main queue operation: front() would require a minor alteration or addition to LinkedList and would be very similar to...
removeFront()
39
Doubly Linked List
a structure consisting of a sequence of nodes