






"""simple docstring"""



class 					a						:



    """simple docstring"""



    def __init__(     self: Any    ,						UpperCamelCase: list       ):






         """simple docstring"""


         A__										=  set_counts
         A__										=  max(UpperCamelCase       )
         A__										=  len(UpperCamelCase       )
         A__										=  [1] * num_sets
         A__										=  list(range(UpperCamelCase       )       )

    def 				UpperCamelCase	(     self: Any    ,						UpperCamelCase: int    ,						UpperCamelCase: int       ):






         """simple docstring"""


         A__										=  self.get_parent(UpperCamelCase       )
         A__										=  self.get_parent(UpperCamelCase       )

         if src_parent == dst_parent:
              return False

         if self.ranks[dst_parent] >= self.ranks[src_parent]:
              self.set_counts[dst_parent] += self.set_counts[src_parent]
              A__										=  0
              A__										=  dst_parent
              if self.ranks[dst_parent] == self.ranks[src_parent]:
                   self.ranks[dst_parent] += 1
              A__										=  self.set_counts[dst_parent]
         else:
              self.set_counts[src_parent] += self.set_counts[dst_parent]
              A__										=  0
              A__										=  src_parent
              A__										=  self.set_counts[src_parent]

         A__										=  max(self.max_set    ,						UpperCamelCase       )
         return True





    def 				UpperCamelCase	(     self: Tuple    ,						UpperCamelCase: int       ):






         """simple docstring"""


         if self.parents[disj_set] == disj_set:
              return disj_set
         A__										=  self.get_parent(self.parents[disj_set]       )
         return self.parents[disj_set]









"""simple docstring"""



from collections.abc import Callable





def  _snake_case     (    UpperCAmelCase_  :					Callable[[float], float]					,   UpperCAmelCase_  :					float					,   UpperCAmelCase_  :					float			):
     A__										=  a
     A__										=  b
     if function(UpperCAmelCase_			) == 0:  # one of the a or b is a root for the function
          return a
     elif function(UpperCAmelCase_			) == 0:
          return b
     elif (
         function(UpperCAmelCase_			) * function(UpperCAmelCase_			) > 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:
          A__										=  start + (end - start) / 2.0
          while abs(start - mid			) > 10**-7:  # until precisely equals to 10^-7
               if function(UpperCAmelCase_			) == 0:
                    return mid
               elif function(UpperCAmelCase_			) * function(UpperCAmelCase_			) < 0:
                    A__										=  mid
               else:
                    A__										=  mid
               A__										=  start + (end - start) / 2.0
          return mid





def  _snake_case     (    UpperCAmelCase_  :					float			):
     return x**3 - 2 * x - 5


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

 import doctest

 doctest.testmod()






