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

Commitb55e79a

Browse files
committed
Update BST image.
1 parent7236dac commitb55e79a

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed

‎src/data-structures/tree/binary-search-tree/README.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,34 @@
33
_Read this in other languages:_
44
[_Português_](README.pt-BR.md)
55

6-
In computer science,**binary search trees** (BST), sometimes called
7-
ordered or sorted binary trees, are a particular type of container:
8-
data structures that store "items" (such as numbers, names etc.)
9-
in memory. They allow fast lookup, addition and removal of
10-
items, and can be used to implement either dynamic sets of
11-
items, or lookup tables that allow finding an item by its key
6+
In computer science,**binary search trees** (BST), sometimes called
7+
ordered or sorted binary trees, are a particular type of container:
8+
data structures that store "items" (such as numbers, names etc.)
9+
in memory. They allow fast lookup, addition and removal of
10+
items, and can be used to implement either dynamic sets of
11+
items, or lookup tables that allow finding an item by its key
1212
(e.g., finding the phone number of a person by name).
1313

14-
Binary search trees keep their keys in sorted order, so that lookup
15-
and other operations can use the principle of binary search:
16-
when looking for a key in a tree (or a place to insert a new key),
17-
they traverse the tree from root to leaf, making comparisons to
18-
keys stored in the nodes of the tree and deciding, on the basis
19-
of the comparison, to continue searching in the left or right
20-
subtrees. On average, this means that each comparison allows
21-
the operations to skip about half of the tree, so that each
22-
lookup, insertion or deletion takes time proportional to the
23-
logarithm of the number of items stored in the tree. This is
24-
much better than the linear time required to find items by key
25-
in an (unsorted) array, but slower than the corresponding
14+
Binary search trees keep their keys in sorted order, so that lookup
15+
and other operations can use the principle of binary search:
16+
when looking for a key in a tree (or a place to insert a new key),
17+
they traverse the tree from root to leaf, making comparisons to
18+
keys stored in the nodes of the tree and deciding, on the basis
19+
of the comparison, to continue searching in the left or right
20+
subtrees. On average, this means that each comparison allows
21+
the operations to skip about half of the tree, so that each
22+
lookup, insertion or deletion takes time proportional to the
23+
logarithm of the number of items stored in the tree. This is
24+
much better than the linear time required to find items by key
25+
in an (unsorted) array, but slower than the corresponding
2626
operations on hash tables.
2727

2828
A binary search tree of size 9 and depth 3, with 8 at the root.
2929
The leaves are not drawn.
3030

31-
![Binary Search Tree](https://upload.wikimedia.org/wikipedia/commons/d/da/Binary_search_tree.svg)
31+
![Trie](./images/binary-search-tree.jpg)
32+
33+
*Made with[okso.app](https://okso.app)*
3234

3335
##Pseudocode for Basic Operations
3436

@@ -45,7 +47,7 @@ insert(value)
4547
end if
4648
end insert
4749
```
48-
50+
4951
```text
5052
insertNode(current, value)
5153
Pre: current is the node to start from
@@ -84,8 +86,8 @@ contains(root, value)
8486
end if
8587
end contains
8688
```
87-
88-
89+
90+
8991
###Deletion
9092

9193
```text
@@ -186,7 +188,7 @@ findNode(root, value)
186188
end if
187189
end findNode
188190
```
189-
191+
190192
###Find Minimum
191193

192194
```text
@@ -200,7 +202,7 @@ findMin(root)
200202
findMin(root.left)
201203
end findMin
202204
```
203-
205+
204206
###Find Maximum
205207

206208
```text
@@ -214,7 +216,7 @@ findMax(root)
214216
findMax(root.right)
215217
end findMax
216218
```
217-
219+
218220
###Traversal
219221

220222
####InOrder Traversal
@@ -244,7 +246,7 @@ preorder(root)
244246
end if
245247
end preorder
246248
```
247-
249+
248250
####PostOrder Traversal
249251

250252
```text
@@ -258,7 +260,7 @@ postorder(root)
258260
end if
259261
end postorder
260262
```
261-
263+
262264
##Complexities
263265

264266
###Time Complexity

‎src/data-structures/tree/binary-search-tree/README.pt-BR.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ Uma pesquisa de árvore binária de tamanho 9 e profundidade 3, com valor 8
2626
na raíz.
2727
As folhas não foram desenhadas.
2828

29+
![Trie](./images/binary-search-tree.jpg)
2930

30-
![Binary Search Tree](https://upload.wikimedia.org/wikipedia/commons/d/da/Binary_search_tree.svg)
31+
*Made with[okso.app](https://okso.app)*
3132

3233
##Pseudocódigo para Operações Básicas
3334

@@ -44,7 +45,7 @@ insert(value)
4445
end if
4546
end insert
4647
```
47-
48+
4849
```text
4950
insertNode(current, value)
5051
Pre: current is the node to start from
@@ -83,8 +84,8 @@ contains(root, value)
8384
end if
8485
end contains
8586
```
86-
87-
87+
88+
8889
###Remoção
8990

9091
```text
@@ -185,7 +186,7 @@ findNode(root, value)
185186
end if
186187
end findNode
187188
```
188-
189+
189190
###Encontrar Mínimo
190191

191192
```text
@@ -199,7 +200,7 @@ findMin(root)
199200
findMin(root.left)
200201
end findMin
201202
```
202-
203+
203204
###Encontrar Máximo
204205

205206
```text
@@ -213,7 +214,7 @@ findMax(root)
213214
findMax(root.right)
214215
end findMax
215216
```
216-
217+
217218
###Traversal
218219

219220
####Na Ordem Traversal (InOrder Traversal)
@@ -243,7 +244,7 @@ preorder(root)
243244
end if
244245
end preorder
245246
```
246-
247+
247248
####Pós Ordem Traversal (PostOrder Traversal)
248249

249250
```text
@@ -257,7 +258,7 @@ postorder(root)
257258
end if
258259
end postorder
259260
```
260-
261+
261262
##Complexidades
262263

263264
###Complexidade de Tempo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp