NEW
Font size
WorksheetsLinked Lists in Visual Basic
Total questions: 15
Worksheet time: 7mins
What should be declared inside this Structure declaration for each node to store integers in a 1d array-based linked list?
Dim data As Integer
Dim pointer As Integer
Dim data As Integer
Dim pointer As Pointer
Dim value As Integer
Dim pointer As node
Dim data As Integer
Dim pointer As Structure
What does it mean when the linked list's start/head pointer is null?
The list is empty
The list has not been initialized
The head has been deleted
A new head has been inserted
In the 1d array-based linked list implementation, what does it mean when the freePointer is null?
The list has not bee initialised
The list is full
The list is empty
The list has overflowed
What action is being performed here on the linked list?
Adding a new node at the end of the list
Adding a new item as head/start node
Deleting the head of the list
Initializing the linked list
To insert node D between node C and Node E here, what should we do?
First set C's pointer to D, then set D's pointer to E
First set D's pointer to E, then set C's pointer to D
First set C's pointer to null and then set D's pointer to E
First set D's pointer to null and then set C's pointer to D
Given this list, what will be output by the following pseudocode?
current <- head
FOR x <- 0 TO 2
current <- current.pointer
NEXT x
OUTPUT current
I
D
E
H
What is returned by this code?
The head of the linked list
True if the list is empty, False otherwise
The number of elements in the linked list
Zero
What would this code return?
The last node in the linked list
The number of items in the linked list
The pointer of the last value in the linked list
The value stored in the last node of the linked list
This code is from the procedure to insert a new node into a linked list. What is it doing?
Updates the pointers and then stores the node in the array.
Points the new node to the index pointed to by the free pointer.
Stores the node in the array and then updates the pointers.
Sets new node index to first free index, moves free pointer to next free location, then stores the new node at the new node index.
Given a linked list stored in an array that has been initialized like this, what values would the pointers 'start' and 'freePointer' hold after these items have been inserted in this order: 7, 8, 9
start = 2
freePointer = 4
start = 0
freePointer = 4
start = 0
freePointer = 3
start = 2
freePointer = 3
Consider that the next value to be inserted into this array-based linked list is 3. After this operation, what would be the value of the pointer for the item in index 3, and what index would the start pointer hold?
pointer of item at index 3 = 0,
start = 3
pointer of item at index 3 = -1,
start = 0
pointer of item at index 3 = 4,
start = 0
pointer of item at index 3 = 2,
start = 0
This code adjusts the pointers when an item is inserted in an array-based linked list.
What is the missing code to insert the new item as the new head?
list(newNodePosition).pointer
= startPointer
startPointer = newNodePosition
list(previous).pointer
= startPointer
startPointer = newNodePosition
list(current).pointer
= startPointer
startPointer = newNodePosition
list(free).pointer
= startPointer
startPointer = current
This code deletes an item from the array-based linked list. What code is missing from lines 125 and 128?
startPointer = startPointer.pointer
previous.pointer = current.pointer
startPointer = previous
previous = list(current).pointer
list(startPointer).pointer = startPointer
list(current).pointer = list(previous).pointer
startPointer = list(startPointer).pointer
list(previous).pointer = list(current).pointer
Given this 1d array-based linked list, what would this array look like after logically deleting the node containing the value 8?
Which of these statements is NOT true?
We can use a linked list to simulate stack push/pop functions by inserting and removing at the head
We can use a linked list to simulate queue enqueue/dequeue functions by inserting at the head and removing at the tail
VB has built-in abstract stack and queue data types that are actually implemented under-the-hood as arrays
The VB Collections framework has built-in stack, queue, linked list and binary tree data types
