Professional Documents
Culture Documents
▪ Input: arr[] = {10, 20, 30, 40, 60, 110, 120, 130, 170}, x = 175
▪ Output: -1
▪ Explanation: Element x is not present in arr[].
NGUYEN MINH DAO - STC -UTE Time Complexity: O(log3n), where n is the size of the array. 2/22/2023 41
Auxiliary Space: O(1)
Recursive Implementation of Ternary Search
NGUYEN MINH DAO - STC -UTE Time Complexity: O(log3n), where n is the size of the array. 2/22/2023 42
Auxiliary Space: O(1)
[V] JUMP SEARCH
▪ Jump search technique also works for ordered lists. It
creates a block and tries to find the element in that block. If
the item is not in the block, it shifts the entire block.
▪ The block size is based on the size of the list. If the size of
the list is n then block size will be √n. After finding a
correct block it finds the item using a linear search
technique. The jump search lies between linear search and
binary search according to its performance.