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)
Speed of train A and train B is 90 km/hr and 36 km/hr respectively. They cross each other in 10 seconds when they are running in opposite directions. Le...
Two trains A and B, were proceeding in the same direction on parallel tracks at 24 km/hr and 78 km/hr respectively. A man noticed that it took exactly 2...
When a train Q vacated station A at 4 am and reached station B at 7 am. Another train P Vacated station B at 6 am and reached station A at 8:30 am. At a...
A train moves at 90 km/h to arrive at its station on time. If it moves at 100 km/h, it will arrive 15 minutes earlier. Find the t...
A train 270 metre long takes 36 sec to cross a man running at a speed of 4 km/hr in the direction opposite to that of train. What is the speed of the tr...
Trains 'M' and 'N' travel at speeds of 72 km/h and 90 km/h, respectively. It takes train 'M' 32 seconds to pass a certain platform, while train 'N' requ...
A train 200 metre long takes 20 sec to cross a man running at a speed of 4 km/hr in the direction same to that of train. What is the speed of the train?
Without stopping the speed of the train is 135 kmph, with stopping the speed of the train is 90 kmph.Find the stop time of the train?
Two trains start from places A and B, respectively, and travel towards each other at the speeds of 60 km/h and 50 km/h, respectively. By the time they ...