How do I write a 4-ary search algorithm and then compare its speed with that of binary search?

  algorithm, python, search, tree

I want write to write a 4-ary search algorithm and then compare it empirically to binary-search algorithm.

this is my sample four-ary code:
def four_ary_search(A, l, r, key):

    n = len(A)
    l = 0
    r = n - 1

    while l <= r:
        m = int(floor((l + r) / 2))

        if key == A[m]:
            return m
        else:
            if key < A[m]:
                r = m - 1
            else: 
                l = m + 1
    return -1  

Source: Python Questions

LEAVE A COMMENT