Trees, BST

This commit is contained in:
Evgeniy Ilyushin 2018-01-10 08:43:46 +03:00
parent 41efccb339
commit 964b27f023
1 changed files with 47 additions and 47 deletions

View File

@ -739,59 +739,59 @@ Google не возьмёт тебя на работу.
- [ ] абсолютные значения:
- [Absolute Integer](http://bits.stephan-brumme.com/absInteger.html)
## Trees
## Деревья
- ### Trees - Notes & Background
- [ ] [Series: Core Trees (video)](https://www.coursera.org/learn/data-structures-optimizing-performance/lecture/ovovP/core-trees)
- [ ] [Series: Trees (video)](https://www.coursera.org/learn/data-structures/lecture/95qda/trees)
- basic tree construction
- traversal
- manipulation algorithms
- BFS (breadth-first search)
- [MIT (video)](https://www.youtube.com/watch?v=s-CYnVz-uh4&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&index=13)
- level order (BFS, using queue)
time complexity: O(n)
space complexity: best: O(1), worst: O(n/2)=O(n)
- DFS (depth-first search)
- [MIT (video)](https://www.youtube.com/watch?v=AfSk24UTFS8&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&index=14)
- notes:
time complexity: O(n)
space complexity:
best: O(log n) - avg. height of tree
worst: O(n)
- inorder (DFS: left, self, right)
- postorder (DFS: left, right, self)
- preorder (DFS: self, left, right)
- ### Деревья - Заметки & Основные понятия
- [ ] [Основы деревьев (видео)](https://www.coursera.org/learn/data-structures-optimizing-performance/lecture/ovovP/core-trees)
- [ ] [Деревья (видео)](https://www.coursera.org/learn/data-structures/lecture/95qda/trees)
- базовые конструкции деревьев
- обход
- алгоритмы манипуляции
- BFS (breadth-first search - поиск в ширину)
- [MIT (видео)](https://www.youtube.com/watch?v=s-CYnVz-uh4&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&index=13)
- порядок уровня (BFS, использование очереди)
сложность по времени выполнения: O(n)
сложность по памяти: лучшая: O(1), худшая: O(n/2)=O(n)
- DFS (depth-first search - поиск в глубину)
- [MIT (видео)](https://www.youtube.com/watch?v=AfSk24UTFS8&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&index=14)
- заметки:
сложность по времени выполнения: O(n)
сложность по памяти:
лучшая: O(log n) - средняя высота дерева
худшая: O(n)
- in-order (DFS: левый, вершина, правый)
- post-order (DFS: левый, правый, вершина)
- pre-order (DFS: вершина, левый, правый)
- ### Binary search trees: BSTs
- [ ] [Binary Search Tree Review (video)](https://www.youtube.com/watch?v=x6At0nzX92o&index=1&list=PLA5Lqm4uh9Bbq-E0ZnqTIa8LRaL77ica6)
- [ ] [Series (video)](https://www.coursera.org/learn/data-structures-optimizing-performance/lecture/p82sw/core-introduction-to-binary-search-trees)
- starts with symbol table and goes through BST applications
- [ ] [Introduction (video)](https://www.coursera.org/learn/data-structures/lecture/E7cXP/introduction)
- [ ] [MIT (video)](https://www.youtube.com/watch?v=9Jry5-82I68)
- ### Бинарное дерево поиска(Binary search trees): BSTs
- [ ] [Обзор бинарного дерева поиска (видео)](https://www.youtube.com/watch?v=x6At0nzX92o&index=1&list=PLA5Lqm4uh9Bbq-E0ZnqTIa8LRaL77ica6)
- [ ] [Лекции (видео)](https://www.coursera.org/learn/data-structures-optimizing-performance/lecture/p82sw/core-introduction-to-binary-search-trees)
- начинается с таблицы символов и заканчивая BST приложениями
- [ ] [Введение (видео)](https://www.coursera.org/learn/data-structures/lecture/E7cXP/introduction)
- [ ] [MIT (видео)](https://www.youtube.com/watch?v=9Jry5-82I68)
- C/C++:
- [ ] [Binary search tree - Implementation in C/C++ (video)](https://www.youtube.com/watch?v=COZK7NATh4k&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=28)
- [ ] [BST implementation - memory allocation in stack and heap (video)](https://www.youtube.com/watch?v=hWokyBoo0aI&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=29)
- [ ] [Find min and max element in a binary search tree (video)](https://www.youtube.com/watch?v=Ut90klNN264&index=30&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Find height of a binary tree (video)](https://www.youtube.com/watch?v=_pnqMz5nrRs&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=31)
- [ ] [Binary tree traversal - breadth-first and depth-first strategies (video)](https://www.youtube.com/watch?v=9RHO6jU--GU&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=32)
- [ ] [Binary tree: Level Order Traversal (video)](https://www.youtube.com/watch?v=86g8jAQug04&index=33&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Binary tree traversal: Preorder, Inorder, Postorder (video)](https://www.youtube.com/watch?v=gm8DUJJhmY4&index=34&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Check if a binary tree is binary search tree or not (video)](https://www.youtube.com/watch?v=yEwSGhSsT0U&index=35&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Delete a node from Binary Search Tree (video)](https://www.youtube.com/watch?v=gcULXE7ViZw&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=36)
- [ ] [Inorder Successor in a binary search tree (video)](https://www.youtube.com/watch?v=5cPbNCrdotA&index=37&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] Implement:
- [ ] insert // insert value into tree
- [ ] get_node_count // get count of values stored
- [ ] print_values // prints the values in the tree, from min to max
- [ ] [Бинарное дерево поиска - реализация на C/C++ (видео)](https://www.youtube.com/watch?v=COZK7NATh4k&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=28)
- [ ] [BST реализация - аллокация памяти в стеке и куче (видео)](https://www.youtube.com/watch?v=hWokyBoo0aI&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=29)
- [ ] [Поиск минимального и максимального элемента в BST (видео)](https://www.youtube.com/watch?v=Ut90klNN264&index=30&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Нахождение высоты BST (видео)](https://www.youtube.com/watch?v=_pnqMz5nrRs&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=31)
- [ ] [Обход BST - breadth-first и depth-first стратегии (видео)](https://www.youtube.com/watch?v=9RHO6jU--GU&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=32)
- [ ] [Бинарное дерево: обход по уровням (видео)](https://www.youtube.com/watch?v=86g8jAQug04&index=33&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Обход бинарного дерева: Pre-order, In-order, Post-order (видео)](https://www.youtube.com/watch?v=gm8DUJJhmY4&index=34&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Проверка - бинарное дерево BST или нет (видео)](https://www.youtube.com/watch?v=yEwSGhSsT0U&index=35&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] [Удаление узов в BST (видео)](https://www.youtube.com/watch?v=gcULXE7ViZw&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=36)
- [ ] [In-order аналог в BST (видео)](https://www.youtube.com/watch?v=5cPbNCrdotA&index=37&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P)
- [ ] Реализация:
- [ ] insert // вставка значения в дерево
- [ ] get_node_count // получение количества хранящихся значений
- [ ] print_values // вывод значений, начиная с min к max
- [ ] delete_tree
- [ ] is_in_tree // returns true if given value exists in the tree
- [ ] get_height // returns the height in nodes (single node's height is 1)
- [ ] get_min // returns the minimum value stored in the tree
- [ ] get_max // returns the maximum value stored in the tree
- [ ] is_in_tree // возвращает если переданное значение есть в дереве
- [ ] get_height // возвращает высоту дерева в количестве узлов (высота одного узла 1)
- [ ] get_min // возвращает минимальное значение хранящиеся в узлах дерева
- [ ] get_max // возвращает максимальное значение хранящиеся в узлах дерева
- [ ] is_binary_search_tree
- [ ] delete_value
- [ ] get_successor // returns next-highest value in tree after given value, -1 if none
- [ ] get_successor // возвращает следующее максимальное значение в дереве после переданного, -1 если none
- ### Heap / Priority Queue / Binary Heap
- visualized as a tree, but is usually linear in storage (array, linked list)