Start learning 50% faster. Sign in now
In a singly linked list, deleting the first element is very efficient and takes O(1) time. This is because the head pointer of the linked list can directly reference the next node, bypassing the first node. No traversal or shifting of elements is required, unlike an array, where deletion involves shifting all subsequent elements, making it O(n) The pointer manipulation in a linked list ensures this operation is constant time, making it highly advantageous over arrays for scenarios involving frequent deletion of the first element. Why Other Options Are Incorrect · Option 1 (Accessing the middle element): In a singly linked list, accessing any element requires traversing from the head node to the desired position, making it O(n) In contrast, an array supports direct access using an index, making it O(1) · Option 3 (Accessing the last element): Accessing the last element in a singly linked list requires traversing through all nodes from the head, making it O(n) In an array, accessing the last element is an O(1) operation because the index of the last element is directly available. · Option 4 (Inserting an element at a specific position): To insert at a specific position, a singly linked list requires traversal up to that position, which is O(n) In an array, insertion requires shifting elements, also O(n), but for specific use cases, arrays might be preferable for direct indexing. · Option 5 (Searching for an element): Searching is linear in a singly linked list (O(n) , as each node must be checked. In arrays, searching can also be O(n) , but if the array is sorted, binary search can reduce complexity to O(log n)
Two inlet pipes 'A' and 'B' can fill an empty tank in 60 minutes and 120 minutes, respectively. Another outlet pipe 'C' can empty the tank in 240 minute...
Pipe ‘A’ and pipe ‘B’, together can fill 20% of a tank in 6 hours while pipe ‘C’ takes 36 hours to empty it. ...
Pipe 'X' takes 50 minutes to fill the tank by itself, while Pipe 'Y' can fill it in 30 minutes on its own. What is the time required for both pipes to f...
An empty tank can be filled by an inlet pipe in 10 hours, while an outlet pipe can empty it in 15 hours. If we open (N - 1) outlet pipes of the same cap...
A tank has two inlet pipes, A and B, which can fill the tank in 6 hours and 8 hours, respectively, and an outlet pipe C, which can empty the tank in 12 ...
Tap A can fill a tank in 20 hours and tap B can emptied it is 25 hours. Tap A starts filling and they opened for 1 hour each alternatively in what time...
Two pipes P and Q can fill tank A in 36 minutes and 72 minutes respectively and empty pipe M can empty the tank in 54 minutes. Tank A has the capacity o...
Pipe ‘A’ can fill a tank in 12 hours while pipe ‘B’ takes 15 hours to empty it. Pipe ‘A’ is opened alone when the tank was empty and after 1...
Two inlet pipes M and N alone can fill a tank in 10 hours and 12 hours respectively and an outlet pipe P alone can empty the whole tank in 5 hours. Firs...