Select All true answers about linear and binary search
1. The advantage of linear search is that it runs in O(1) space complexity and binary search can only run in O(logn) space complexity
2. The disadvantage of binary search is that it requires the container to be sorted which linear search does not.
3. The advantage of binary search over linear search is that is more efficient O(logn)versus O(n) average/worst case).
4. The advantage of linear search is that it allow coders to select a pivot point and improve time complexity
5. The disadvantage of binary search is that it runs in O(nlogn) space complexity
6. The purpose of binary search is to determine the index (or absence) of an element in a sequential random access container
Point 1:- False. Both searching algorithm works on O(1) space complexity.
Point 2:- True. Binary Search requires containers to be sorted either in increasing or decreasing order, while there is no such condition for Linear Search.
Point 3:- True. Time complexity of Binary Search is O(logn) whereas the time complexity of Linear Search is O(n).
Point 4:- False. Linear Search has no such option of selecting a pivot point to improve time complexity.
Point 5:- False. Both binary search and Linear search runs in O(!) space complexity.
Point 6:- True. Binary Search randomly chooses an element of a container. So binary search can be used to find the index(or absence) of an element in a container.
Note:- Please comment down if you face any problem. :)
Get Answers For Free
Most questions answered within 1 hours.