OA. free
Free
Palo Alto Networks Core Computer Science Core Computer Science Medium

What is the time it takes for the ball to travel from the track when Tom hits it at 18 ft...

Palo Alto Networks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

What is the time it takes for the ball to travel from the track when Tom hits it at 18 ft per second?

Assume that when Tom smashes the ball, the ball is exactly at the tail end of the table and when it reaches Johnny, it travels exactly the full length of the table.

Select any one of the following options

Choose one option.
Show answer & explanation
Answer: B. B) \u00bd second

Binary search requires O(1) random access to find the middle element. Arrays support O(1) random access, whereas LinkedList requires O(n) sequential traversal, making binary search inefficient on linked lists.

Step-by-step Derivation:
Step 1: Binary search repeatedly divides the search range in half by jumping to the middle index: mid = (low + high) / 2.
Step 2: In an array, accessing element at index 'mid' takes O(1) time.
Step 3: In a linked list, accessing node at index 'mid' requires sequential traversal taking O(k) steps, leading to an overall O(n) time rather than O(log n). Hence binary search is unsuitable for linked lists.