Conversation
Амортизационный анализ
Depreciation analysis
…нализ алгоритмов.pdf
task_02/src/stack.hpp
Outdated
| : data(_data), prevptr(_prev) {} | ||
| StackNode() : data(), prevptr(nullptr) {} | ||
| T data; | ||
| StackNode<T> *prevptr; |
task_02/src/stack.hpp
Outdated
| int Pop(); | ||
| Stack() : top(nullptr), size(0) {} | ||
| void push(T value); | ||
| T pop(); |
task_02/src/stack.hpp
Outdated
| void push(T value); | ||
| T pop(); | ||
| T getTop(); | ||
| int getSize(); |
task_02/src/stack.hpp
Outdated
| Stack() : top(nullptr), size(0) {} | ||
| void push(T value); | ||
| T pop(); | ||
| T getTop(); |
task_02/src/stack.hpp
Outdated
|
|
||
| private: | ||
| std::stack<int> data_; | ||
| StackNode<T> *top; |
task_05/src/test.cpp
Outdated
| TEST(quickSort, Simple) { | ||
| std::vector<int> data = {1, 2, 3, 4, 5}; | ||
| quickSort<int>(data); | ||
| for (auto curr : data) std::cout << curr << " "; |
There was a problem hiding this comment.
Ой, да, это рудимент какой-то
task_07/src/BinaryTree.hpp
Outdated
| template <class T> | ||
| class BinaryTree { | ||
| public: | ||
| BinaryTree() : root(nullptr) {} |
There was a problem hiding this comment.
тут виже только обычное дерево поиска, без балансировки, в задании дерево с балансировкой
task_08/src/HashTable.hpp
Outdated
|
|
||
| void insert(const Key& key, const Value& value); | ||
|
|
||
| bool search(const Key& key); |
There was a problem hiding this comment.
нет функции которая возвращает value
task_02/src/stack.hpp
Outdated
| if (size_ == 0) { | ||
| throw std::underflow_error("Empty stack"); | ||
| } | ||
| T returning_value = top_->data; |
There was a problem hiding this comment.
давай так чуть соптимизируем:
T returning_value = std::move(top_->data);
There was a problem hiding this comment.
weather_report.cpp
ну и hpp тоже переименуй
There was a problem hiding this comment.
и в других задачах тоже
task_04/src/heap.hpp
Outdated
| int GetLefrChildIndex(int i) { return 2 * i + 1; } | ||
| int GetRightChildIndex(int i) { return 2 * i + 2; } | ||
|
|
||
| void heapify(int i); |
task_05/src/QuickSort.hpp
Outdated
| #include <vector> | ||
|
|
||
| template <class T> | ||
| int partition(std::vector<T>& v, int low, int high) { |
task_06/src/nStatistics.hpp
Outdated
| #include <vector> | ||
|
|
||
| template <class T> | ||
| int partition(std::vector<T>& v, int low, int high) { |
There was a problem hiding this comment.
та же функция что и в предидущей задаче, давай вынесем в lib/src/utils.hpp
task_07/src/BinaryTree.hpp
Outdated
| BinaryTree() : root_(nullptr) {} | ||
| ~BinaryTree() { DestroyTree(root_); } | ||
|
|
||
| void insert(int value) { root_ = InsertRecursive(root_, value); } |
There was a problem hiding this comment.
Insert
и в других местах поправь имена методов по код стайлу
task_08/src/HashTable.hpp
Outdated
| return pair.second; | ||
| } | ||
| } | ||
| throw std::logic_error("No such key in table"); |
task_08/src/HashTable.hpp
Outdated
| template <class Key, class Value> | ||
| void HashTable<Key, Value>::Rehash() { | ||
| std::vector<std::list<std::pair<Key, Value>>> new_table(table_.size() * 2); | ||
| for (const auto& list : table_) { |
There was a problem hiding this comment.
если убрать const в обеих for то можно будет переместить элементы: new_table[index].emplace_back(std::move(pair));
No description provided.