
from collections.abc import Callable





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase    ,		__lowerCAmelCase    ,		__lowerCAmelCase							):
    snake_case__						=				a
    snake_case__						=				b
    if function(__lowerCAmelCase							) == 0:  # one of the a or b is a root for the function
        return a
    elif function(__lowerCAmelCase							) == 0:
        return b
    elif (
        function(__lowerCAmelCase							) * function(__lowerCAmelCase							) > 0
    ):  # if none of these are root and they are both positive or negative,
        # then this algorithm can't find the root
        raise ValueError("could not find root in given interval."							)
    else:
        snake_case__						=				start + (end - start) / 2.0
        while abs(start - mid							) > 10**-7:  # until precisely equals to 10^-7
            if function(__lowerCAmelCase							) == 0:
                return mid
            elif function(__lowerCAmelCase							) * function(__lowerCAmelCase							) < 0:
                snake_case__						=				mid
            else:
                snake_case__						=				mid
            snake_case__						=				start + (end - start) / 2.0
        return mid





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase							):
    return x**3 - 2 * x - 5


if __name__ == "__main__":
     print(bisection(f, 1, 1_000))

     import doctest

     doctest.testmod()





from __future__ import annotations





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase    ,		__lowerCAmelCase							):
    snake_case__						,					snake_case__						=				set(__lowerCAmelCase							), [start]

    while stack:
        snake_case__						=				stack.pop()
        explored.add(__lowerCAmelCase							)
        # Differences from BFS:
        # 1) pop last element instead of first one
        # 2) add adjacent elements to stack without exploring them
        for adj in reversed(graph[v]							):
            if adj not in explored:
                stack.append(__lowerCAmelCase							)
    return explored


__magic_name__            =  {
    '''A''': ['''B''', '''C''', '''D'''],
    '''B''': ['''A''', '''D''', '''E'''],
    '''C''': ['''A''', '''F'''],
    '''D''': ['''B''', '''D'''],
    '''E''': ['''B''', '''F'''],
    '''F''': ['''C''', '''E''', '''G'''],
    '''G''': ['''F'''],
}

if __name__ == "__main__":
     import doctest

     doctest.testmod()
     print(depth_first_search(G, '''A'''))



