ProgrammingHard
A singly linked list is built by inserting 1, 2, 3 at the head. Then two nodes are popped from the head and their values printed. What is printed?
- A. 3 2
- B. 1 2
- C. 3 1
- D. 2 3
Correct answer: A. 3 2
Head insertion makes 3 the first node, then 2. Popping from the head removes 3 and then 2, so they print in that order.
More C Programming questions
- A circular singly linked list holds 1 -> 2 -> 3 -> back to 1. Starting at the head node, the program prints six consecutive values. What…
- A sorted list 1, 1, 2, 3, 3 has its duplicates removed by a loop that unlinks a node whose value equals the previous node's value. How…
- A dynamic array starts with capacity 1 and doubles whenever it is full, until its capacity is at least 10. What is the final capacity?
- A complete binary tree has levels 0 to 2 (depth 3 in this count). How many nodes does it have?
- A chained hash bucket holds the nodes 30, 20, 10 in that order from the head. The node holding 20 is deleted and freed. How many nodes…
- A program makes three malloc calls and two free calls, with no other allocations. How many blocks are still allocated when the program…