Searching in ABR
This commit is contained in:
parent
6b6dd822f1
commit
11e383bcc6
1 changed files with 14 additions and 0 deletions
|
@ -160,3 +160,17 @@ def planter(racine, val):
|
||||||
else:
|
else:
|
||||||
racine.fd = new Noeud(val=val, fg=None, fd=None)
|
racine.fd = new Noeud(val=val, fg=None, fd=None)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Rechercher dans un ABR
|
||||||
|
```python
|
||||||
|
def recherche(racine, val):
|
||||||
|
cur_node = racine
|
||||||
|
while cur_node:
|
||||||
|
if cur_node.val == val:
|
||||||
|
return True
|
||||||
|
else if cur_node.val > val:
|
||||||
|
cur_node = cur_node.fg
|
||||||
|
else:
|
||||||
|
cur_node = cur_node.fd
|
||||||
|
return False
|
||||||
|
```
|
Loading…
Reference in a new issue