mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-19 15:00:58 +00:00
build
This commit is contained in:
@@ -2018,7 +2018,12 @@ AVL-дерево одновременно является и двоичным
|
||||
@root = insert_helper(@root, val)
|
||||
end
|
||||
|
||||
### Рекурсивная вставка узла (вспомогательный метод) ###
|
||||
### Вставка узла ###
|
||||
def insert(val)
|
||||
@root = insert_helper(@root, val)
|
||||
end
|
||||
|
||||
# ## Рекурсивная вставка узла (вспомогательный метод) ###
|
||||
def insert_helper(node, val)
|
||||
return TreeNode.new(val) if node.nil?
|
||||
# 1. Найти позицию вставки и вставить узел
|
||||
@@ -2606,7 +2611,12 @@ AVL-дерево одновременно является и двоичным
|
||||
@root = remove_helper(@root, val)
|
||||
end
|
||||
|
||||
### Рекурсивное удаление узла (вспомогательный метод) ###
|
||||
### Удаление узла ###
|
||||
def remove(val)
|
||||
@root = remove_helper(@root, val)
|
||||
end
|
||||
|
||||
# ## Рекурсивное удаление узла (вспомогательный метод) ###
|
||||
def remove_helper(node, val)
|
||||
return if node.nil?
|
||||
# 1. Найти узел и удалить его
|
||||
|
||||
Reference in New Issue
Block a user