Answer
procedure quaternary search$(x: $ an integer $a_1, a_2, ... , a_n: $ list of integers$)$
$i:= 1$
$m := n$
while $i
Work Step by Step
This algorithm is an extension of the binary search to Quaternary search. It proceeds as follows:
First it splits the list into four subsets by defining five indices, at the beginning, after a quarter, after two quarters, after three quarters. and the end. Note how we use the floor function to get integer indices.
After this, we try to place our $x$ value in one of these intervals. Depending on which conditional is true, we modify the endpoints of the interval. Notice that with each step, the range should be getting decreased by a fourth.
Finally, our algorithm terminates when $i\ge j$ indicating that we have only one element in our array. We check if this element is equal to the target and return the index if it's the required result, $0$ otherwise.