Complexity Analysis of Ternary Search
Time Complexity:
- Worst case: O(log3N)
- Average case: Θ(log3N)
- Best case: Ω(1)
Auxiliary Space: O(1)
Ternary Search
Computer systems use different methods to find specific data. There are various search algorithms, each better suited for certain situations. For instance, a binary search divides information into two parts, while a ternary search does the same but into three equal parts. It’s worth noting that ternary search is only effective for sorted data. In this article, we’re going to uncover the secrets of Ternary Search – how it works, why it’s faster in some situations.
Table of Content
- What is the Ternary Search?
- When to use Ternary Search
- Working of Ternary Search
- Implementation of Ternary Search
- Complexity Analysis of Ternary Search
- Binary search Vs Ternary Search
- Advantages
- Disadvantages
- Summary