Data Structures Test 2 Review Queues Flashcards
Singly Linked List
a structure consisting of a sequence of nodes
A singly linked list stores a _________ to the first node (head) and last (tail)
pointer
In a singly linked list, each node stores…
an elementa link to the next node
template class SLinkedListNode { public: Type elem; [WHAT GOES HERE?] };
SLinkedListNode *next;
Singly Linked List Operation: insertFront(e):
inserts an element on the front of the list
Singly Linked List Operation: removeFront():
returns and removes the element at the front of the list
Singly Linked List Operation: insertBack(e):
inserts an element on the back of the list
Singly Linked List Operation: removeBack():
returns and removes the element at the end of the list
Stack with a Singly Linked List: The _______ element of the stack is the ______ ______ of the list
topfirst node
Stack with a Singly Linked List: The space used is ______ and each operation of the Stack ADT takes _______ time
O(n)O(1)
Stack Operation: push(e) is most like what Singly Linked List Operation?
insertFront(e)
Stack Operation: pop() is most like what Singly Linked List Operation?
removeFront()
What 2 Singly Linked List Operations do not work with Stack Operations?
insertBack(e)removeBack()
With minor alteration or addition, top() could be very similar to…
removeFront()
_______ and ________ would require the addition of a counter that increments each time push() is called and decrements when pop() is called
size() isEmpty()