From 6b468e51f0460af95ae852c6fb8a0b3024b25e56 Mon Sep 17 00:00:00 2001 From: maitriupadhyay03-cell Date: Sat, 6 Jun 2026 16:50:31 +0530 Subject: [PATCH 1/2] fix: correct treap split() to match docstring for equal values (#7854) The split() function in treap.py uses `<` comparison but the docstring states that the right subtree should contain values "greater or equal" to the split value. This fix changes `elif value < root.value:` to `elif value <= root.value:` so that equal values go to the right subtree as documented. Fixes #7854 --- data_structures/binary_tree/treap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data_structures/binary_tree/treap.py b/data_structures/binary_tree/treap.py index 3114c6fa1c26..5c67dc8d7ead 100644 --- a/data_structures/binary_tree/treap.py +++ b/data_structures/binary_tree/treap.py @@ -5,7 +5,7 @@ class Node: """ - Treap's node + Treap's nodeh Treap is a binary tree by value and heap by priority """ @@ -41,7 +41,7 @@ def split(root: Node | None, value: int) -> tuple[Node | None, Node | None]: """ if root is None or root.value is None: # None tree is split into 2 Nones return None, None - elif value < root.value: + elif value <= root.value: """ Right tree's root will be current node. Now we split(with the same value) current node's left son From 48e35c87ff23f2692c734700669d48280d91e73c Mon Sep 17 00:00:00 2001 From: maitriupadhyay03-cell Date: Sat, 6 Jun 2026 16:52:00 +0530 Subject: [PATCH 2/2] Fix typo in Treap node docstringfix: remove accidental typo in Node class docstring --- data_structures/binary_tree/treap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/binary_tree/treap.py b/data_structures/binary_tree/treap.py index 5c67dc8d7ead..ca81d5967cb6 100644 --- a/data_structures/binary_tree/treap.py +++ b/data_structures/binary_tree/treap.py @@ -5,7 +5,7 @@ class Node: """ - Treap's nodeh + Treap's node Treap is a binary tree by value and heap by priority """