Skip to content

Commit 4216965

Browse files
authored
Apply suggestions from code review
1 parent 2062e5e commit 4216965

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pydatastructs/trees/binary_trees.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ class SplayTree(SelfBalancingBinaryTree):
10671067
10681068
References
10691069
==========
1070+
10701071
.. [1] https://en.wikipedia.org/wiki/Splay_tree
10711072
10721073
"""
@@ -1138,11 +1139,9 @@ def join(self, other):
11381139
elements = traverse.depth_first_search(order='pre_order', node=other.root_idx)
11391140
for i in range(len(elements)):
11401141
super(SelfBalancingBinaryTree, self).insert(elements[i].key, elements[i].data)
1141-
j = len(elements)-1
1142-
while j>=0:
1142+
for j in range(len(elements) - 1, -1, -1):
11431143
e, p = super(SelfBalancingBinaryTree, other).search(elements[j].key, parent=True)
11441144
other.tree[e] = None
1145-
j-=1
11461145

11471146
def split(self, x):
11481147
"""
@@ -1173,10 +1172,8 @@ def split(self, x):
11731172
elements = traverse.depth_first_search(order='pre_order', node=self.tree[self.root_idx].right)
11741173
for i in range(len(elements)):
11751174
super(SelfBalancingBinaryTree, other).insert(elements[i].key, elements[i].data)
1176-
j = len(elements)-1
1177-
while j>=0:
1175+
for j in range(len(elements) - 1, -1, -1):
11781176
e, p = super(SelfBalancingBinaryTree, self).search(elements[j].key, parent=True)
11791177
self.tree[e] = None
1180-
j-=1
11811178
self.tree[self.root_idx].right = None
11821179
return other

0 commit comments

Comments
 (0)