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 fixed set of adjacent memory locations
B. A collection of values stored in a table
C. A collection of nodes connected by links
D. A group of instructions executed repeatedly

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. Only data with no link to another node
D. Data and links to two previous nodes

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

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

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

Singly linked list traversal Easy
A. At a random node
B. At the final node
C. At the middle 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 the head
B. A link equal to null
C. A link equal to zero data
D. A link equal to the size

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 newly inserted node
B. The null value
C. The former second node
D. The former final node

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

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

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

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

9 When does linked list underflow occur?

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

10 When can linked list overflow occur?

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

11 Which description best matches a tree data structure?

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

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. Child
B. Leaf
C. Root
D. Sibling

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 leaf node
B. A root node
C. A sibling node
D. A parent 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. Siblings
B. Roots
C. Subtrees
D. Edges

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. Three
B. One
C. Four
D. Two

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. In its right subtree
C. At any leaf position
D. At the root only

18 Which order is used in preorder traversal?

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

19 Which order is used in inorder traversal?

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

20 Which order is used in postorder traversal?

Postorder traversal Easy
A. Right, root, left
B. Root, left, right
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. All records occupy one contiguous memory block allocated at creation time.
B. Records are automatically maintained in sorted order.
C. Every record can be accessed directly using its numeric index.
D. Insertion can be performed by changing links without shifting later records.

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

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

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. 8 3 6
B. 6 3 8
C. 8 6 3
D. 3 6 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 head node
B. The last 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. head = newNode.next; newNode.next = null;
C. newNode.next = head; head = newNode;
D. newNode.next = null; head.next = 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 = newNode; newNode.next = p.next;
D. p.next = 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.next; free(temp); head = temp;
B. head = null; free(head); temp = head.next;
C. free(head.next); head.next = null; temp = head;
D. temp = head; head = head.next; free(temp);

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

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

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

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

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

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

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. D and E are siblings, and the degree of R is 3.
B. A and D are siblings, and the degree of R is 2.
C. B is a child of A, and the degree of A is 3.
D. D is the parent of A, and the degree of A is 1.

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 3 and height 4
B. Depth 2 and height 3
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. An edge incident on X
B. A path ending at X
C. A set of siblings of X
D. A subtree rooted at 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. All leaves occur at the same level.
C. Each node has at most two children.
D. Each internal node has exactly two children and every level is completely filled before another level is created.

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 70
C. As the left child of 60
D. As the right child of 60

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 → 50 → 60
B. 40 → 60 → null
C. 60 → 40 → 50
D. 40 → 60 → 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. D, E, B, F, C, A
B. A, B, D, E, C, F
C. D, B, E, A, C, F
D. A, C, F, B, D, E

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. D, B, E, A, C, F
B. A, B, D, E, C, F
C. D, E, B, F, C, A
D. D, B, A, E, 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 500 from 700 to 900
C. Change the next field at address 700 from NULL to 500
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->next = n; n->next = head;
B. head = n; n->next = head;
C. n->next = head; head = n;
D. n->next = head->next; head = n;

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. Stop whenever the current node's data equals the head's data
B. Store visited node addresses and stop before processing a repeated address
C. Continue following next until the current pointer becomes NULL
D. Use two pointers and process every node reached by the faster pointer

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->data <= x) p = p->next;
B. while (p->next != NULL && p->next->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 tail->next = n; then set tail = n, and set head = n only when tail is NULL
B. Set n->next = tail; if empty set head = n, otherwise link head->next = n and set tail = n
C. Set n->next = NULL; if empty set head = tail = n, otherwise link tail->next = n and set tail = n
D. Set n->next = head; if empty set tail = n, otherwise set head = n and leave tail unchanged

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 p's data into its successor, redirect p, and then free p
B. Set p to its successor, clear the old data, and leave all links unchanged
C. Reverse links from p onward, remove the final node, and reverse them again
D. Copy the successor's data into p, bypass the successor, and free the successor

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 = &(*link)->next;
B. *link = (*link)->next;
C. link = &head->next;
D. link = &link[1];

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 head->next is NULL; overflow occurs when the tail is reached
C. Underflow occurs when one node remains; overflow occurs when addresses are noncontiguous
D. Underflow occurs when allocation fails; overflow occurs when an empty list is popped

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 node with exactly one child
B. leaves and nodes 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, 35, 60, 70, 50
B. 40, 30, 20, 60, 35, 50, 70
C. 40, 30, 20, 35, 60, 50, 70
D. 40, 30, 35, 20, 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, 30, 20, 40, 60, 65, 80
B. 50, 30, 40, 20, 80, 65, 60
C. 50, 30, 20, 40, 80, 60, 65
D. 50, 20, 30, 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, E, D
B. A, C, G, F, B, E, D
C. A, B, E, D, C, F, G
D. A, C, F, G, B, D, E

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. E, B, D, A, F, C, G
B. D, B, E, A, G, C, F
C. D, E, B, A, F, G, C
D. D, B, E, A, F, C, G

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, E, H, F, D, L, P, M, K
C. B, H, E, F, D, P, L, M, K
D. E, B, 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, 30, 40, 35, 25, 55, 70, 75, 65, 45
C. 15, 30, 40, 25, 35, 55, 75, 70, 65, 45
D. 15, 40, 30, 35, 25, 55, 70, 75, 65, 45