Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56efd99

Browse files
author
shengshijun
committed
最近复习算法的时候,发现有不少地方是有问题的。所以我打算添加一些测试。
1 parentbd9f001 commit56efd99

File tree

89 files changed

+39
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+39
-26
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎lib/set.pyrenamed to‎src/lib/set.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎src/number_theory/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'
File renamed without changes.

‎src/queue/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎src/string/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎src/tree/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎tree/red_black_tree.pyrenamed to‎src/tree/red_black_tree.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -268,46 +268,47 @@ def __delete_fixup(self, node):
268268
parent=cur_node.parent
269269
ifparent.leftiscur_node:
270270
# 判断是左支还是右支,仅仅是实现所限
271-
uncle=parent.right
272-
ifuncle.is_red():
273-
# 情况一:叔节点是红色,则重新设色并左旋
274-
uncle.color=False
271+
brother=parent.right
272+
ifbrother.is_red():
273+
# 情况一:兄弟节点是红色,则重新设色并左旋
274+
brother.color=False
275275
parent.color=True
276276
self.__left_rotate(parent)
277-
elifuncle.left.is_black()anduncle.right.is_black():
278-
# 情况二(1):叔节点和其两个子节点都是黑色.则设置叔节点为红色,这个时候如果parent是红色,那么循环就会退出
279-
uncle.color=True
277+
cur_node=brother
278+
elifbrother.left.is_black()andbrother.right.is_black():
279+
# 情况二(1):兄弟节点和其两个子节点都是黑色.则设置兄弟节点为红色,这个时候如果parent是红色,那么循环就会退出
280+
brother.color=True
280281
cur_node=parent
281-
elifuncle.right.is_black():
282-
uncle.color=True
283-
uncle.left.color=False
284-
# 情况二(2):叔节点红和其右节点是黑色,那么意味着叔节点的左节点是红色,这个时候叔节点右旋并且父子节点交换颜色
285-
self.__right_rotate(uncle)
282+
elifbrother.right.is_black():
283+
brother.color=True
284+
brother.left.color=False
285+
# 情况二(2):兄弟节点红和其右节点是黑色,那么意味着兄弟节点的左节点是红色,这个时候兄弟节点右旋并且父子节点交换颜色
286+
self.__right_rotate(brother)
286287
else:
287-
# 情况二(3):叔节点是黑色,其右节点红色(可以由前面的转换而来),这个时候叔节点设红,其父节点和右子节点设黑并且父节点左旋
288+
# 情况二(3):兄弟节点是黑色,其右节点红色(可以由前面的转换而来),这个时候兄弟节点设红,其父节点和右子节点设黑并且父节点左旋
288289
parent.color=False
289-
uncle.color=True
290-
uncle.right.color=False
290+
brother.color=True
291+
brother.right.color=False
291292
self.__left_rotate(parent)
292293
# 退出情况
293294
cur_node=self.__root
294295
else:
295-
uncle=parent.left
296-
ifuncle.is_red():
297-
uncle.color=False
296+
brother=parent.left
297+
ifbrother.is_red():
298+
brother.color=False
298299
parent.color=True
299300
self.__right_rotate(parent)
300-
elifuncle.left.is_black()anduncle.right.is_black():
301-
uncle.color=True
301+
elifbrother.left.is_black()andbrother.right.is_black():
302+
brother.color=True
302303
cur_node=parent
303-
elifuncle.left.is_black():
304-
uncle.color=True
305-
uncle.right.color=False
306-
self.__left_rotate(uncle)
304+
elifbrother.left.is_black():
305+
brother.color=True
306+
brother.right.color=False
307+
self.__left_rotate(brother)
307308
else:
308309
parent.color=False
309-
uncle.color=True
310-
uncle.left.color=False
310+
brother.color=True
311+
brother.left.color=False
311312
self.__right_rotate(parent)
312313
cur_node=self.__root
313314
cur_node.color=False
File renamed without changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp