0% found this document useful (0 votes)
23 views3 pages

Questions in Linked List

The document contains a series of questions related to linked lists, covering topics such as memory allocation, node insertion, and traversal efficiency. It addresses the advantages and disadvantages of linked lists compared to arrays, as well as specific operations and representations in C++. The questions are designed to test knowledge on the fundamental concepts and functionalities of linked lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Questions in Linked List

The document contains a series of questions related to linked lists, covering topics such as memory allocation, node insertion, and traversal efficiency. It addresses the advantages and disadvantages of linked lists compared to arrays, as well as specific operations and representations in C++. The questions are designed to test knowledge on the fundamental concepts and functionalities of linked lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Questions in linked list

1. What is the primary reason a linked list can efficiently shrink or grow
during program execution?
a) It uses contiguous memory allocation.
b) It stores elements in sorted order.
c) It dynamically allocates/deallocates memory at runtime.
d) It uses fixed-size nodes.

2. Why is random access inefficient in a singly linked list?


a) Nodes store both data and pointers.
b) Direct access by index is impossible; traversal is required.
c) Memory allocation is non-contiguous.
d) Pointers consume extra memory.

3. When inserting a node at the beginning of a linked list, what is the


correct sequence?
a) Update new node's `next` to head, then set head to new node.
b) Set new node's `next` to head, then update head to point to the new
node.
c) Copy head to new node, then update head's `next`.
d) Traverse to the end first.

4. What is a key disadvantage of linked lists compared to arrays for small


datasets?
a) Faster insertion/deletion.
b) No significant benefits; arrays may be simpler and faster.
c) Better memory utilization.
d) Easier random access.

5. In C++, how is a node typically represented in a singly linked list?


a) `struct node { int data; int next; };`
b) `class Node { int value; Node prev; };`
c) `class Node { public: int value; Node next; };`
d) `struct node { int data; node link; };`

6. What happens if `head = NULL` during deletion from the front?


a) The first node is automatically deallocated.
b) The list is empty; deletion is undefined/impossible.
c) The last node is removed.
d) A segmentation fault always occurs.
7. Why does a linked list use more memory per element than an array?
a) Data fields are larger.
b) Each node requires extra memory for a pointer.
c) Memory is allocated in chunks.
d) Arrays compress data.

8. Which operation is impossible in a singly linked list?


a) Insertion at the head.
b) Deletion at the tail.
c) Efficient reverse traversal.
d) Concatenation.

9. What does the `next` pointer of the last node in a linked list point to?
a) The first node.
b) Itself.
c) `NULL`.
d) A sentinel value.

10. What is the purpose of `getnode()` in linked list algorithms?


a) Obtains an empty node (allocates memory).
b) Frees a node.
c) Finds a node by value.
d) Counts nodes.

11. After concatenating two linked lists A (with `n` nodes) and B (with
`m` nodes), how many nodes does list A contain?
a) `n`
b) `m`
c) `n + m`
d) `max(n, m)`

12. What makes linked lists "flexible" according to the PPT?


a) Fixed size.
b) Elements are not stored in contiguous memory.
c) Static memory allocation.
d) Random access capability.

13. In the C++ code from the PPT, what does `head = head->next`
accomplish?
a) Inserts a new node.
b) Moves traversal to the next node.
c) Deletes the current node.
d) Reverses the list.
14. Why is traversal slower in linked lists than in arrays?
a. Pointers cause cache misses.
b. Each node requires dereferencing a pointer to access the next element.
c. Arrays use hardware acceleration.
d. Linked lists cannot use loops.

You might also like