Unit 3: Introduction to Linked Lists - Practice Quiz

INT322 — Computing System And Technologies 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is a linked list?

Definition of linked list Easy
A. A collection of nodes connected by links
B. A group of instructions executed repeatedly
C. A fixed set of adjacent memory locations
D. A collection of values stored in a table

2 What does a node in a singly linked list usually contain?

Implementation of singly linked list Easy
A. Data and a link to the next node
B. Only a link to the previous node
C. Data and links to two previous nodes
D. Only data with no link to another node

3 What does the head of a singly linked list refer to?

Implementation of singly linked list Easy
A. The number of nodes in the list
B. The middle node in the list
C. The final node in the list
D. The first node in the list

4 Where does traversal of a singly linked list normally begin?

Singly linked list traversal Easy
A. At the middle node
B. At a random node
C. At the final node
D. At the head node

5 Which value usually marks the end of a singly linked list?

Singly linked list traversal Easy
A. A link equal to zero data
B. A link equal to the size
C. A link equal to null
D. A link equal to the head

6 When inserting a new node at the beginning of a singly linked list, what should the head reference afterward?

Singly linked list insertion Easy
A. The former final node
B. The newly inserted node
C. The former second node
D. The null value

7 To insert a node after a given node, which link must be updated?

Singly linked list insertion Easy
A. The head node's data value
B. The final node's data value
C. The list's traversal counter
D. The given node's next link

8 What happens to the head when the first node of a singly linked list is deleted?

Singly linked list deletion Easy
A. It points to the final node
B. It points to the second node
C. It stores the deleted node's data
D. It keeps pointing to the deleted node

9 When does linked list underflow occur?

Linked list underflow and overflow conditions Easy
A. When traversing a list twice
B. When inserting into an empty list
C. When deleting from an empty list
D. When linking the final node

10 When can linked list overflow occur?

Linked list underflow and overflow conditions Easy
A. When a node stores a duplicate value
B. When the first node contains a null link
C. When traversal reaches the final node
D. When no memory is available for a new node

11 Which description best matches a tree data structure?

Introduction to trees Easy
A. A structure organized as a hierarchy
B. A structure without connections between elements
C. A structure arranged as a simple table
D. A structure containing only one value

12 What is the topmost node of a tree called?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Easy
A. Leaf
B. Child
C. Sibling
D. Root

13 What is a tree node with no children called?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Easy
A. A sibling node
B. A parent node
C. A root node
D. A leaf node

14 What are two nodes with the same parent called?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Easy
A. Roots
B. Subtrees
C. Edges
D. Siblings

15 What is an edge in a tree?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Easy
A. A value stored inside a node
B. A connection between two nodes
C. A count of nodes in the tree
D. A collection of all leaf nodes

16 What is the maximum number of children that a node in a binary tree can have?

Conceptual understanding of binary trees Easy
A. Four
B. Two
C. Three
D. One

17 In a binary search tree, where are values smaller than a node usually placed?

Conceptual understanding of binary search trees Easy
A. In its left subtree
B. At any leaf position
C. At the root only
D. In its right subtree

18 Which order is used in preorder traversal?

Preorder traversal Easy
A. Right, root, left
B. Root, left, right
C. Left, right, root
D. Left, root, right

19 Which order is used in inorder traversal?

Inorder traversal Easy
A. Root, left, right
B. Left, root, right
C. Left, right, root
D. Root, right, left

20 Which order is used in postorder traversal?

Postorder traversal Easy
A. Root, left, right
B. Right, root, left
C. Left, root, right
D. Left, right, root

21 A program frequently inserts records after a known record. Why may a linked list be more suitable than an array?

Definition of linked list Medium
A. Records are automatically maintained in sorted order.
B. Insertion can be performed by changing links without shifting later records.
C. All records occupy one contiguous memory block allocated at creation time.
D. Every record can be accessed directly using its numeric index.

22 Which structure correctly represents a node in a singly linked list of integers?

Implementation of singly linked list Medium
A. A pointer to the first node and an integer index
B. An integer data field and pointers to both neighboring nodes
C. An integer data field and a pointer to the next node
D. Two integer data fields and no pointer field

23 For the list 8 → 3 → 6 → null, what is printed by a traversal that starts at head and prints each node before advancing to next?

Singly linked list traversal Medium
A. 3 6 8
B. 8 3 6
C. 8 6 3
D. 6 3 8

24 In a nonempty singly linked list, the loop while (current.next != null) current = current.next; terminates with current pointing to which node?

Singly linked list traversal Medium
A. The last node
B. The head node
C. The null reference
D. The middle node

25 Which sequence correctly inserts newNode at the beginning of a singly linked list?

Singly linked list insertion Medium
A. head.next = newNode; newNode = head;
B. newNode.next = null; head.next = newNode;
C. head = newNode.next; newNode.next = null;
D. newNode.next = head; head = newNode;

26 Suppose p points to a node in a singly linked list. Which statements correctly insert newNode immediately after p without losing the remaining list?

Singly linked list insertion Medium
A. newNode.next = p.next; p.next = newNode;
B. newNode.next = p; p.next = newNode;
C. p.next = newNode; newNode.next = p.next;
D. p = newNode; newNode.next = p.next;

27 Which operation correctly deletes the first node of a nonempty singly linked list while allowing its memory to be released?

Singly linked list deletion Medium
A. temp = head; head = head.next; free(temp);
B. head = null; free(head); temp = head.next;
C. free(head.next); head.next = null; temp = head;
D. temp = head.next; free(temp); head = temp;

28 If q = p.next and q is not null, which statements delete q from the list?

Singly linked list deletion Medium
A. q.next = null; free(p.next);
B. p.next = q.next; free(q);
C. q.next = p; free(p);
D. p = q.next; free(q);

29 A deletion is requested when head is null. Which condition has occurred?

Linked list underflow and overflow conditions Medium
A. Pointer duplication
B. Traversal completion
C. Linked list overflow
D. Linked list underflow

30 When does linked list overflow normally occur in a dynamically allocated implementation?

Linked list underflow and overflow conditions Medium
A. When memory allocation for a new node fails
B. When traversal reaches the null link at the end
C. When the list reaches a fixed length chosen by the programmer even though additional memory remains available
D. When the head points to the first valid node

31 A valid tree contains nodes. How many edges does it contain?

Introduction to trees Medium
A.
B.
C.
D.

32 In a tree, root R has children A, B, and C; node A has children D and E. Which statement is correct?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Medium
A. B is a child of A, and the degree of A is 3.
B. D is the parent of A, and the degree of A is 1.
C. D and E are siblings, and the degree of R is 3.
D. A and D are siblings, and the degree of R is 2.

33 Using edges as the measure, a deepest leaf is reached from the root through three edges. What are the depth of that leaf and the height of the tree?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Medium
A. Depth 2 and height 3
B. Depth 3 and height 4
C. Depth 4 and height 4
D. Depth 3 and height 3

34 If node X and all nodes descended from X are considered together, what do they form?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Medium
A. A set of siblings of X
B. A path ending at X
C. A subtree rooted at X
D. An edge incident on X

35 If the root is at level , what is the maximum number of nodes at level of a binary tree?

Conceptual understanding of binary trees Medium
A.
B.
C.
D.

36 Which statement must be true for every binary tree?

Conceptual understanding of binary trees Medium
A. Every left child is smaller than its parent.
B. Each node has at most two children.
C. Each internal node has exactly two children and every level is completely filled before another level is created.
D. All leaves occur at the same level.

37 The keys 50, 30, 70, 20, 40, 60 are inserted into an empty binary search tree in that order. Where will key 65 be inserted?

Conceptual understanding of binary search trees Medium
A. As the right child of 70
B. As the left child of 60
C. As the right child of 60
D. As the left child of 70

38 A binary search tree has root 40; its right child is 60, whose left child is 50. Which comparison path is followed when searching for 50?

Conceptual understanding of binary search trees Medium
A. 40 → 60 → null
B. 40 → 50 → 60
C. 40 → 60 → 50
D. 60 → 40 → 50

39 A binary tree has root A; A has children B and C; B has children D and E; and C has right child F. What is its preorder traversal?

Preorder traversal Medium
A. A, C, F, B, D, E
B. A, B, D, E, C, F
C. D, E, B, F, C, A
D. D, B, E, A, C, F

40 A binary tree has root A; A has children B and C; B has children D and E; and C has right child F. What is its inorder traversal?

Inorder traversal Medium
A. A, B, D, E, C, F
B. D, B, A, E, C, F
C. D, E, B, F, C, A
D. D, B, E, A, C, F

41 A singly linked list is represented by head = 900, with nodes (900: A, 300), (300: B, 700), and (700: C, NULL), where each pair after the address stores (data, next). If the node at address 300 is relocated to address 500, which change preserves the same logical list?

Definition of linked list Hard
A. Change head from address 900 to address 500
B. Change the next field at address 700 from NULL to 500
C. Change the next field at address 500 from 700 to 900
D. Change the next field at address 900 from 300 to 500

42 Assume n is a newly allocated node and head points to the first node of a possibly nonempty singly linked list. Which ordering correctly inserts n at the front without losing access to the original list?

Implementation of singly linked list Hard
A. head = n; n->next = head;
B. n->next = head->next; head = n;
C. n->next = head; head = n;
D. head->next = n; n->next = head;

43 A singly linked structure may end in NULL or may contain a cycle. Which traversal strategy guarantees that every reachable node is processed exactly once and that traversal terminates in both cases?

Singly linked list traversal Hard
A. Use two pointers and process every node reached by the faster pointer
B. Store visited node addresses and stop before processing a repeated address
C. Stop whenever the current node's data equals the head's data
D. Continue following next until the current pointer becomes NULL

44 A sentinel-headed singly linked list is sorted in ascending order. A new value x must be inserted after all existing nodes equal to x. Starting with p at the sentinel, which loop finds the correct predecessor?

Singly linked list insertion Hard
A. while (p->next != NULL && p->next->data < x) p = p->next;
B. while (p->next != NULL && p->data <= x) p = p->next;
C. while (p->next != NULL && p->next->data >= x) p = p->next;
D. while (p->next != NULL && p->next->data <= x) p = p->next;

45 A singly linked list maintains both head and tail. Which operation correctly appends a new node n and preserves head == tail for a one-node list?

Singly linked list insertion Hard
A. Set n->next = NULL; if empty set head = tail = n, otherwise link tail->next = n and set tail = n
B. Set n->next = tail; if empty set head = n, otherwise link head->next = n and set tail = n
C. Set n->next = head; if empty set tail = n, otherwise set head = n and leave tail unchanged
D. Set tail->next = n; then set tail = n, and set head = n only when tail is NULL

46 Only a pointer p to a non-tail node of a singly linked list is available; neither head nor the predecessor is available. Assuming node identity need not be preserved, how can the logical element at p be deleted in time?

Singly linked list deletion Hard
A. Copy the successor's data into p, bypass the successor, and free the successor
B. Reverse links from p onward, remove the final node, and reverse them again
C. Copy p's data into its successor, redirect p, and then free p
D. Set p to its successor, clear the old data, and leave all links unchanged

47 The following pointer-to-pointer algorithm deletes every node whose data equals x: Node **link = &head; while (*link != NULL) { if ((*link)->data == x) { Node *t = *link; *link = t->next; free(t); } else { /* missing */ } }. Which statement correctly replaces the missing part?

Singly linked list deletion Hard
A. link = &head->next;
B. link = &(*link)->next;
C. link = &link[1];
D. *link = (*link)->next;

48 For a dynamically allocated linked-list stack with no imposed size limit, which pair most accurately describes underflow and overflow?

Linked list underflow and overflow conditions Hard
A. Underflow occurs when popping an empty list; overflow occurs when node allocation fails
B. Underflow occurs when one node remains; overflow occurs when addresses are noncontiguous
C. Underflow occurs when allocation fails; overflow occurs when an empty list is popped
D. Underflow occurs when head->next is NULL; overflow occurs when the tail is reached

49 A connected undirected tree has vertices. One new edge is added between two distinct existing vertices. Which statement must then be true?

Introduction to trees Hard
A. The graph has edges and contains exactly two cycles
B. The graph has edges and contains exactly one cycle
C. The graph has edges and remains acyclic
D. The graph has edges and contains exactly one cycle

50 A rooted tree has edges R-A, R-B, R-C, A-D, A-E, B-F, E-G, F-H, and F-I. Levels begin at , and height is measured in edges. Which description is correct?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Hard
A. R has degree , E has depth , and the tree has height
B. R has degree , E has depth , and the tree has height
C. R has degree , E has depth , and the tree has height
D. R has degree , E has depth , and the tree has height

51 A rooted tree contains nodes and leaves. Every nonleaf node has either one child or three children. How many nodes have degree three?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Hard
A. nodes
B. nodes
C. nodes
D. nodes

52 A rooted tree has edges R-A, R-B, A-C, A-D, D-E, B-F, F-G, and F-H. Which tuple correctly gives (number of nodes in the subtree rooted at D, length of the path from E to G, lowest common ancestor of E and G)?

Tree terminology: root, edge, parent, child, siblings, leaf, degree, level, height, depth, path and subtree Hard
A.
B.
C.
D.

53 The height of a binary tree is measured as the number of edges on its longest root-to-leaf path. What is the minimum possible height of a binary tree containing nodes?

Conceptual understanding of binary trees Hard
A.
B.
C.
D.

54 A complete binary tree contains nodes numbered from in level order. How many leaves and how many nodes with exactly one child does it contain?

Conceptual understanding of binary trees Hard
A. leaves and nodes with exactly one child
B. leaves and node with exactly one child
C. leaves and nodes with exactly one child
D. leaves and node with exactly one child

55 Assume all keys are distinct. Which sequence can be the preorder traversal of a binary search tree?

Conceptual understanding of binary search trees Hard
A. 40, 30, 20, 60, 35, 50, 70
B. 40, 30, 35, 20, 60, 50, 70
C. 40, 30, 20, 35, 60, 70, 50
D. 40, 30, 20, 35, 60, 50, 70

56 Keys 50, 30, 70, 20, 40, 60, 80, 65 are inserted in that order into an empty binary search tree. Node 70 is then deleted using its inorder successor. What is the resulting preorder traversal?

Conceptual understanding of binary search trees Hard
A. 50, 20, 30, 40, 80, 60, 65
B. 50, 30, 40, 20, 80, 65, 60
C. 50, 30, 20, 40, 60, 65, 80
D. 50, 30, 20, 40, 80, 60, 65

57 A binary tree has preorder A, B, D, E, C, F, G and inorder D, B, E, A, F, G, C. What is the preorder traversal of its mirror tree, obtained by swapping the left and right children of every node?

Preorder traversal Hard
A. A, C, F, G, B, D, E
B. A, C, F, G, B, E, D
C. A, B, E, D, C, F, G
D. A, C, G, F, B, E, D

58 A full binary tree with distinct labels has preorder A, B, D, E, C, F, G and postorder D, E, B, F, G, C, A. What is its inorder traversal?

Inorder traversal Hard
A. D, B, E, A, G, C, F
B. D, B, E, A, F, C, G
C. E, B, D, A, F, C, G
D. D, E, B, A, F, G, C

59 A binary tree has preorder K, D, B, F, E, H, M, L, P and inorder B, D, E, F, H, K, L, M, P. What is its postorder traversal?

Postorder traversal Hard
A. B, E, H, D, F, L, P, K, M
B. B, H, E, F, D, P, L, M, K
C. E, B, H, F, D, L, P, M, K
D. B, E, H, F, D, L, P, M, K

60 Keys 45, 25, 65, 15, 35, 55, 75, 30, 40, 70 are inserted into an empty binary search tree in that order. Which sequence is its postorder traversal?

Postorder traversal Hard
A. 15, 30, 40, 35, 25, 70, 55, 75, 65, 45
B. 15, 40, 30, 35, 25, 55, 70, 75, 65, 45
C. 15, 30, 40, 25, 35, 55, 75, 70, 65, 45
D. 15, 30, 40, 35, 25, 55, 70, 75, 65, 45