The statements of pseudocode for searching the first element with key k in the linked list L are given below. Arrange them in the correct order.
(A) while (x != NIL and x.key != k)
(B) x = L.head
(C) x = x.next
(D) return x
Step 1: Understanding the pseudocode.
To search for an element in a linked list, the steps typically follow this flow:
- **(B)** Set `x = L.head`, as the search starts from the head of the linked list.
- **(A)** Use a **while** loop to check that the current node (`x`) is not `NIL` and the key (`x.key`) is not equal to `k`. This continues until the element is found or the end of the list is reached.
- **(C)** Move to the next node by updating `x = x.next`.
- **(D)** If the node with the desired key is found, return `x`.
Step 2: Conclusion.
The correct order of the steps is **(B), (A), (C), (D)**. This order ensures that the search starts at the head, continues through the list, and terminates when the element is found.
Match List-I with List-II.
| List-I | List-II |
|---|---|
| A. AND | I. Output 1 only if both inputs are 1 |
| B. OR | II. Output 1 if any input is 1 |
| C. NAND | III. Output 0 only if both inputs are 1 |
| D. NOR | IV. Output 1 only if both inputs are 0 |
Choose the correct answer from the options given below:
Match List-I with List-II:
| List-I (Personalities/Public Figures) | List-II (Bodies/Institutions) | ||
|---|---|---|---|
| (A) | Sanjay Malhotra | (I) | National Human Rights Commission |
| (B) | Om Prakash Rawat | (IV) | Election Commission of India |
| (C) | Justice V. Ramasubramanian | (III) | Supreme Court of India |
| (D) | Justice Deepak Misra | (II) | Reserve Bank of India |