Single Linked List Concepts

Single Linked List Concepts

University

10 Qs

quiz-placeholder

Similar activities

Business Finance (2)

Business Finance (2)

University

14 Qs

Partnership Quiz

Partnership Quiz

University

10 Qs

Singapore 101

Singapore 101

University

10 Qs

The World Cup Year 4

The World Cup Year 4

3rd Grade - Professional Development

10 Qs

Paediatric Ultrasound

Paediatric Ultrasound

University

14 Qs

How Well do you Know Harry Potter

How Well do you Know Harry Potter

KG - Professional Development

10 Qs

Unit 8: Maintain Business Resources

Unit 8: Maintain Business Resources

University

10 Qs

Tutorial 3: The Project Management Process Group

Tutorial 3: The Project Management Process Group

University

15 Qs

Single Linked List Concepts

Single Linked List Concepts

Assessment

Quiz

Other

University

Practice Problem

Hard

Created by

Shoba LK

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the basic structure of a node in a single linked list?

A node in a singly linked list consists of multiple data fields without any pointers.

A node in a singly linked list contains only a data field.

A node in a singly linked list has a data field and a pointer to the next node.

A node in a singly linked list has two pointers, one for the next node and one for the previous node.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write pseudocode to insert a node at the beginning of a single linked list.

function addNodeToEnd(head, newData) { newNode = new Node(newData); if (head == null) { head = newNode; } else { current = head; while (current.next != null) { current = current.next; } current.next = newNode; } return head; }

function insertAtPosition(head, newData, position) { newNode = new Node(newData); if (position == 0) { newNode.next = head; head = newNode; return head; } current = head; for (i = 0; i < position - 1 && current != null; i++) { current = current.next; } newNode.next = current.next; current.next = newNode; return head; }

function insertAtBeginning(head, newData) { newNode = new Node(newData); newNode.next = head; head = newNode; return head; }

function deleteFromBeginning(head) { if (head == null) return null; head = head.next; return head; }

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Describe the pseudocode for inserting a node at the end of a single linked list.

1. Create a new node. 2. If head is null, set head to new node. 3. Else, set current to head. 4. While current.next is not null, set current to current.next. 5. Set current.next to new node.

1. Create a new node. 2. If head is not null, set head to new node. 3. Set current to head. 4. While current.next is null, set current to current.next. 5. Set current.next to new node.

1. Create a new node. 2. Set head to null. 3. Set current to tail. 4. While current is not null, set current to current.previous. 5. Set current.previous to new node.

1. Create a new node. 2. Set head to new node. 3. Set current to head. 4. While current.next is null, set current to current.next. 5. Set current.next to null.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the pseudocode for deleting a node from a single linked list?

Set head.next = head to delete the node.

1. If head is null, return. 2. If head is the node to delete, set head = head.next. 3. Initialize current = head. 4. While current.next is not null: 5. If current.next is the node to delete: 6. Set current.next = current.next.next. 7. Return.

If head is null, set head to the node to delete.

Traverse the list and print each node's value.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain how to traverse a single linked list and write the pseudocode for it.

Print currentNode.next.value

Pseudocode: 1. Set currentNode = head 2. While currentNode is not null: a. Print currentNode.value b. Set currentNode = currentNode.next

While currentNode is null:

Set currentNode = tail

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the time complexity of traversing a single linked list?

O(1)

O(n^2)

O(n)

O(log n)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write pseudocode to search for a value in a single linked list.

function locateValue(head, target) { current = head; if (current.value == target) { return current; } return null; }

function searchList(head, target) { for (let node of head) { if (node.value == target) { return node; } } return null; }

function findInList(head, value) { while (head != null) { if (head.value != value) { head = head.next; } } return head; }

function searchLinkedList(head, target) { current = head; while (current != null) { if (current.value == target) { return current; } current = current.next; } return null; }

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?