A class is defined to represent each list item, known as a ____ - ANSWER:list node
A linked list has what key advantage over a sequential storage approach like an array or ArrayList? -
ANSWER:An item can be inserted somewhere in the middle
What's the purpose of a list's head node? - ANSWER:Provides a reference to the first item's node in the
list, if it exists.
A stack is often implemented using a linked list, with the list's head node being the stack's _____ -
ANSWER:top
Assume the stack is implemented using a linked list. An empty stack is indicated by a list head pointer
value of _____ - ANSWER:null
True or False: StackPop points a local variable to the list's head node. - ANSWER:True
Assume the queue is implemented using a linked list. If the head pointer is null, the queue____ -
ANSWER:is empty
For the operation QueuePop(queue), what is the second parameter passed to ListRemove after? -
ANSWER:0
For the operation QueuePop(queue), poppedItem contains a pointer to the _____. - ANSWER:list head
Queues and ____ are similar in that they are data structures that are designed for a temporarily holding
data. - ANSWER:Stacks
While you can us an array to create a queue, it turns out that ____ are much more suitable. -
ANSWER:Linear Nodes
Linked nodes have this advantage over arrays for implementing collections: - ANSWER:no capacity issues
Because a linear node holds a reference to a generic object, we call it a: - ANSWER:container
Which of the following is/are required to build up a linear node class? - ANSWER:- Getter/Setter for next
node
- Default Constructor
- Getter/Setter for element
- Constructor with element or parameters
- Getter/Setter for previous node (Double linked node only)
- Implementation of generics
There are two types of liner nodes: - ANSWER:singly-linked and doubly-linked
, Assume you have a linked list data structure with f nodes. It is a singly-linked list that supports generics,
so it can hold any type of object. How many reference are in this data structure, including references
that are null? - ANSWER:2f+1
Assume you have a stack implemented with single-linked nodes, that looks like this:
282 -> 789 -> 93 -> 261 -> 89
'top' is a reference variable that points to the node containing 282, and 'count' is an internal int that
holds the count of nodes (currently 5).
If you want to do push operation with the value 275, what is the pseudocode to achieve this? -
ANSWER:1. create single linked node called temp
2. set temp's element pointer to 275
3. set temp's next pointer to be the same as top
4. set top to point at temp
5. increment count
True or False: The top variable keeps track of the number of elements in a LinkedStack implementation -
ANSWER:False
What is the benefit of implementing a stack with a linked linear node structure, as opposed to an array?
- ANSWER:You won't run out of capacity like with an array, and have to create and copy a whole new
structure.
Assume you have a stack, called myStack, implemented with single-linked nodes, that looks like this:
m -> k -> e -> y
'top' is a reference variable that points to the node containing m, and 'count' is an internal int that holds
the count of nodes (currently 4).
The following code is ran:
Character firstPop =
myStack.pop();