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
Q

back():

A

returns the element at the back without removing it

26
Q

isFullQueue():

A

returns if queue is full

27
Q

In a queue, insertions are at the _____ of the queue and removals are at the ______ of the queue

A

endfront

28
Q

Queue exceptions: Attempting to execute dequeue or front on an empty queue throws a(n)…

A

EmptyQueueException

29
Q

template class queueADT { public: virtual bool isEmptyQueue() const = 0; }

A

// function to determing whether the queue is empty// post condition: returns true if the queue is empty, otherwise returns false

30
Q

template class queueADT { public: virtual bool isFullQueue() const = 0; }

A

// function to determine whether the queue is full// post condition: returns true if the queue is full, otherwise returns false

31
Q

template class queueADT { public: virtual void initializeQueue() const = 0; }

A

// function to initialize the queue to an empty state// post condition: the queue is empty

32
Q

template class queueADT { public: virtual Type front() const = 0; }

A

// 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
Q

template class queueADT { public: virtual Type back() const = 0; }

A

// 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
Q

template class queueADT { public: virtual void addQueue(const Type& queueElement) = 0; }

A

// 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
Q

template class queueADT { public: virtual void deleteQueue() const = 0; }

A

// 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
Q

Main queue operation: enqueue(e) is most like what Singly Linked List Operation?

A

insertBack(e)

37
Q

Main queue operation: dequeue() is most like what Singly Linked List Operation?

A

removeFront()

38
Q

Main queue operation: front() would require a minor alteration or addition to LinkedList and would be very similar to…

A

removeFront()

39
Q

Doubly Linked List

A

a structure consisting of a sequence of nodes