Choose true statement :(I) Binary search is faster than linear search....
Understanding the Statements
The question compares two searching algorithms: binary search and linear search. Let's break down each statement.
Statement I: Binary search is faster than linear search.
- Binary search operates in O(log n) time complexity, making it significantly faster for large, sorted datasets.
- Linear search has a time complexity of O(n), meaning it checks each element one by one.
- Thus, for sorted lists, binary search is indeed faster than linear search.
Statement II: Binary search may not be applied on all the input lists on which linear search can be applied.
- Linear search can be applied to any list, regardless of whether it is sorted.
- Binary search requires the input list to be sorted beforehand to function correctly.
- Therefore, there are instances where binary search cannot be used, while linear search can be applied to the same dataset.
Conclusion: Both Statements are True
- Since both statements accurately describe the characteristics of binary and linear search, the correct answer is option 'C', which indicates that both statements are true.
This understanding underscores the importance of knowing the conditions under which different algorithms operate effectively, allowing for optimized performance in search operations.
Choose true statement :(I) Binary search is faster than linear search....
The correct answer is option C.
Concept:
Statement 1: Binary search is faster than linear search.
True, Unless the array size is tiny, binary search is faster than linear search. However, sorting the array is required before doing a binary search. In contrast to binary search, there exist specialized data structures created for quick searching, such as hash tables.
Statement 2:Binary search may not be applied on all the input lists on which linear search can be applied.
True, Binary search is applied only on the sorted list it can not apply to an unsorted list. Whereas linear search is applicable for all types of lists. It means the sorted or unsorted type of lists.
Hence the correct answer is Both I and II.