FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/sort.py at data-struct · XSFLLQ/python · GitHub
XSFLLQ
/
python
Public
forked from
flypythoncom/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (48 loc) · 1.2 KB
Breadcrumbs
python
/
sort.py
Copy path
File metadata and controls
78 lines (48 loc) · 1.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class
BTree
:
def
__init__
(
self
,
value
):
self
.
left
=
None
self
.
data
=
value
self
.
right
=
None
def
insertLeft
(
self
,
value
):
self
.
left
=
BTree
(
value
)
return
self
.
left
def
insertRight
(
self
,
value
):
self
.
right
=
BTree
(
value
)
return
self
.
right
def
show
(
self
):
print
self
.
data
def
inorder
(
node
):
if
node
.
data
:
if
node
.
left
:
inorder
(
node
.
left
)
node
.
show
()
if
node
.
right
:
inorder
(
node
.
right
)
def
rinorder
(
node
):
if
node
.
data
:
if
node
.
right
:
rinorder
(
node
.
right
)
node
.
show
()
if
node
.
left
:
rinorder
(
node
.
left
)
def
insert
(
node
,
value
):
if
value
>
node
.
data
:
if
node
.
right
:
insert
(
node
.
right
,
value
)
else
:
node
.
insertRight
(
value
)
else
:
if
node
.
left
:
insert
(
node
.
left
,
value
)
else
:
node
.
insertLeft
(
value
)
if
__name__
==
"__main__"
:
l
=
[
88
,
11
,
2
,
33
,
22
,
4
,
55
,
33
,
221
,
34
]
Root
=
BTree
(
l
[
0
])
node
=
Root
for
i
in
range
(
1
,
len
(
l
)):
insert
(
Root
,
l
[
i
])
print
"1---->10"
inorder
(
Root
)
print
"10--->1"
rinorder
(
Root
)
Back
|
FazBrowse Home
|
New Git URL