package com.thealgorithms.searches; import com.thealgorithms.devutils.searches.SearchAlgorithm; /** * An iterative implementation of the Ternary Search algorithm. * *
* Ternary search is a divide-and-conquer algorithm that splits the array into three parts * instead of two, as in binary search. This implementation is iterative, reducing the overhead * associated with recursive function calls. However, the recursive version can also be optimized * by the Java compiler to resemble the iterative version, resulting in similar performance. * *
* Worst-case performance: Θ(log3(N))
* Best-case performance: O(1)
* Average performance: Θ(log3(N))
* Worst-case space complexity: O(1)
*
*
* This class implements the {@link SearchAlgorithm} interface, providing a generic search method
* for any comparable type.
*
* @see SearchAlgorithm
* @see TernarySearch
* @since 2018-04-13
*/
public class IterativeTernarySearch implements SearchAlgorithm {
@Override
public