MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / ceil

Method ceil

data_structures/binary_tree/red_black_tree.py:384–400  ·  view source on GitHub ↗

Returns the smallest element in this tree which is at least label. This method is guaranteed to run in O(log(n)) time.

(self, label: int)

Source from the content-addressed store, hash-verified

382 return self.label
383
384 def ceil(self, label: int) -> int | None:
385 """Returns the smallest element in this tree which is at least label.
386 This method is guaranteed to run in O(log(n)) time.
387 """
388 if self.label == label:
389 return self.label
390 elif self.label is not None and self.label < label:
391 if self.right:
392 return self.right.ceil(label)
393 else:
394 return None
395 else:
396 if self.left:
397 attempt = self.left.ceil(label)
398 if attempt is not None:
399 return attempt
400 return self.label
401
402 def get_max(self) -> int | None:
403 """Returns the largest element in this tree.

Callers 8

test_floor_ceilFunction · 0.95
sortFunction · 0.80
explicit_eulerFunction · 0.80
__init__Method · 0.80
euler_modifiedFunction · 0.80
runge_kuttaFunction · 0.80
strassenFunction · 0.80
decrypt_messageFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_floor_ceilFunction · 0.76