Computer Science · Data Structures
Consider a singly linked list containing elements 10 and 20 in order. If we execute the following function as insertEnd(&head, 30), what will be the resulting list structure? struct Node { int data; Node* next; }; void insertEnd(Node head, int val) { Node* newNode = new Node{val, nullptr}; if (head == nullptr) { head = newNode; return; } Node temp = head; while (temp->next != nullptr) temp = temp->next; temp->next = newNode; }
- 1{10, 20, 30}✓
- 2{30, 10, 20}
- 3{10, 30, 20}
- 4{20, 10, 30}
Correct answer
{10, 20, 30}
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Data Structures?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Data Structures