wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Array and Linked List ADT

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.
for(int i=0; i<10; i++)
           numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
a)
1
b)
2
c)
3
d)
4
2.
What is the error in the following code fragment?
float average [20];
average[20] = 15.25;
a)
A cast is required
b)
data not initialized
c)
A two-dimensional array is required
d)
Array Out-of-bounds error
3.
________________________ are used to create a multi dimensional array.
a)
Single round brackets
b)
Single square brackets
c)
Multiple squares brackets
d)
Single angled brackets
4.
This is a:
a)
Linked list
b)
Stack
c)
2D array
d)
an array
5.
 Which of the following is a two-dimensional array?
a)
array anarray[20][20];
b)
int anarray[20][20];
c)
int array[20, 20];
d)
char array[20];
6.
Examine the following:
float values[ ][ ] =
{ {1.2, 9.0, 3.2},  
               {9.2, 0.5, 1.5, -1.2},  
      {7.3, 7.9, 4.8} } ;
what is in values[2][1]?
a)
7.3
b)
7.9
c)
9.2
d)
There is no such array element.
7.
Examine the following:
float values[ ][ ] = 
{ {1.2, 9.0, 3.2},  
               {9.2, 0.5, 1.5, -1.2},  
      {7.3, 7.9, 4.8} } ;
what is in values[3][0]?
a)
7.3
b)
7.9
c)
9.2
d)
There is no such array element.
8.
Examine the following:
int items[ ][ ] = 
{ {0,1,3,4} , {4,3,99,0,7} , {3,2} } ;
Which of the following statements replaces the 99 with 77?
a)
items[1][2] = 77;
b)
items[2][1] = 77;
c)
items[ 99 ] = 77;
d)
items[2][3] = 77;
9.

The doubly linked list would have how many fields in a node?

a)

1

b)

2

c)

3

d)

4

10.

What is the best and worst-case time complexity for searching for a value in a Linked List?

a)

O(1) and O(log n)

b)

O(1) and O(1)

c)

O(1) and O(n^2)

d)

O(1) and O(n)

11.

Below is a function, countNode, to calculate the number of nodes in a list. Fill in the blank with a proper statement.

int linkedList:: countNode (linkedList *list)

{

int count = 0;

ptr = list->head;

while (FILL IN THE BLANK)

{

count++;

ptr = ptr->next;

}

return count;

}

a)

ptr != ptr->next

b)

ptr = ptr ->next

c)

ptr != NULL

d)

ptr = NULL

12.

In doubly linked lists, traversal can be performed?

a)

a) Only in forward direction

b)

b) Only in reverse direction

c)

c) In both directions

d)

d) In circular fashion

13.

Which of the following is false about a doubly linked list?

a)

a) We can navigate in both the directions

b)

b) It requires more space than a singly linked list

c)

c) The insertion and deletion of a node take a bit longer

d)

d) Implementing a doubly linked list is easier than singly linked list

14.

In which list user can navigate in both direction?

a)

Singly Linked List

b)

Doubly Linked List

c)

Both

15.

A node in a doubly linked list has at least _____ fields

a)

4

b)

2

c)

3

d)

5

16.

The DATA field of the head node will usually contain information.

a)

True

b)

False

17.
a)

circular linked list

b)

linked list

c)

doubly circular linked list

d)

doubly linked list

18.

What type of linkedlist is represented in the image

a)

singly linkedlist

b)

doubly linkedlist

c)

circular singly linkedlist

d)

circular doubly linkedlist

19.

How many nodes will ListSearch visit when searching for 54?

a)

6

b)

7

c)

4

d)

3

20.

How many nodes will ListSearch visit when searching for 48?

a)

0

b)

6

c)

3

d)

1

21.

What value does ListSearch return if the search key is not found?

a)

5

b)

1

c)

null

d)

6

22.

Each node in a doubly-linked list contains data and _____ pointer(s).

a)

1

b)

2

c)

None

d)

3

23.

Given a doubly-linked list with nodes 20, 67 and 11, node 20 is the _____.

a)

Head

b)

Tail

c)

CurPointer

d)

Next

24.

Given a doubly-linked list with nodes 4, 7, 5, 1, node 7's previous pointer points to node _____.

a)

4

b)

5

c)

1

d)

null

25.

Given a doubly-linked list with nodes 8, 12, 7, 3, node 7's next pointer points to node _____.

a)

12

b)

7

c)

3

d)

8

26.

A variant of linked list in which last node of the list points to the first node of the list is?

a)

Singly linked list

b)

Doubly linked list

c)

Circular linked list

d)

Multiply linked list

27.

In doubly linked lists, traversal can be performed?

a)

Only in forward direction

b)

Only in reverse direction

c)

In both directions

d)

None

28.

What is value in the head -> next -> next -> data below?

a)

34

b)

12

c)

88

d)

3

29.

What is value in the temp -> next -> next-> data below?

a)

34

b)

88

c)

12

d)

3

30.

Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only.

Given the representation, which of the following operation can be implemented in O(1) time?


i) Insertion at the front of the linked list

ii) Insertion at the end of the linked list

iii) Deletion of the front node of the linked list

iv) Deletion of the last node of the linked list

a)

I and II

b)

I and III

c)

I, II and III

d)

I, II and IV