wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Linked Lists in Visual Basic

Total questions: 15

Worksheet time: 7mins

Name
Class
Date
1.

What should be declared inside this Structure declaration for each node to store integers in a 1d array-based linked list?

a)

Dim data As Integer

Dim pointer As Integer

b)

Dim data As Integer

Dim pointer As Pointer

c)

Dim value As Integer

Dim pointer As node

d)

Dim data As Integer

Dim pointer As Structure

2.

What does it mean when the linked list's start/head pointer is null?

a)

The list is empty

b)

The list has not been initialized

c)

The head has been deleted

d)

A new head has been inserted

3.

In the 1d array-based linked list implementation, what does it mean when the freePointer is null?

a)

The list has not bee initialised

b)

The list is full

c)

The list is empty

d)

The list has overflowed

4.

What action is being performed here on the linked list?

a)

Adding a new node at the end of the list

b)

Adding a new item as head/start node

c)

Deleting the head of the list

d)

Initializing the linked list

5.

To insert node D between node C and Node E here, what should we do?

a)

First set C's pointer to D, then set D's pointer to E

b)

First set D's pointer to E, then set C's pointer to D

c)

First set C's pointer to null and then set D's pointer to E

d)

First set D's pointer to null and then set C's pointer to D

6.

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

a)

I

b)

D

c)

E

d)

H

7.

What is returned by this code?

a)

The head of the linked list

b)

True if the list is empty, False otherwise

c)

The number of elements in the linked list

d)

Zero

8.

What would this code return?

a)

The last node in the linked list

b)

The number of items in the linked list

c)

The pointer of the last value in the linked list

d)

The value stored in the last node of the linked list

9.

This code is from the procedure to insert a new node into a linked list. What is it doing?

a)

Updates the pointers and then stores the node in the array.

b)

Points the new node to the index pointed to by the free pointer.

c)

Stores the node in the array and then updates the pointers.

d)

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.

10.

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

a)

start = 2

freePointer = 4

b)

start = 0

freePointer = 4

c)

start = 0

freePointer = 3

d)

start = 2

freePointer = 3

11.

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?

a)

pointer of item at index 3 = 0,

start = 3

b)

pointer of item at index 3 = -1,

start = 0

c)

pointer of item at index 3 = 4,

start = 0

d)

pointer of item at index 3 = 2,

start = 0

12.

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?

a)

list(newNodePosition).pointer

= startPointer

startPointer = newNodePosition

b)

list(previous).pointer

= startPointer

startPointer = newNodePosition

c)

list(current).pointer

= startPointer

startPointer = newNodePosition

d)

list(free).pointer

= startPointer

startPointer = current

13.

This code deletes an item from the array-based linked list. What code is missing from lines 125 and 128?

a)

startPointer = startPointer.pointer

previous.pointer = current.pointer

b)

startPointer = previous

previous = list(current).pointer

c)

list(startPointer).pointer = startPointer

list(current).pointer = list(previous).pointer

d)

startPointer = list(startPointer).pointer

list(previous).pointer = list(current).pointer

14.

Given this 1d array-based linked list, what would this array look like after logically deleting the node containing the value 8?

a)
b)
c)
d)
15.

Which of these statements is NOT true?

a)

We can use a linked list to simulate stack push/pop functions by inserting and removing at the head

b)

We can use a linked list to simulate queue enqueue/dequeue functions by inserting at the head and removing at the tail

c)

VB has built-in abstract stack and queue data types that are actually implemented under-the-hood as arrays

d)

The VB Collections framework has built-in stack, queue, linked list and binary tree data types