-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homework 2 #39
base: main
Are you sure you want to change the base?
Homework 2 #39
Conversation
task_02/src/stack.hpp
Outdated
@@ -1,23 +1,23 @@ | |||
#pragma once | |||
|
|||
#include <stack> | |||
#include <vector> | |||
struct Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше перенести эту структуру в сам класс стека
task_02/src/stack.hpp
Outdated
|
||
class Stack { | ||
public: | ||
struct Stack { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и тут лучше все-таки класс применить и наружу не светить Node, если исправишь будет чуть больше баллов за д.з.
task_04/src/heap.cpp
Outdated
|
||
void Heap::SiftDown(int index) { | ||
while (2 * index + 1 < heap_.size()) { | ||
int l = 2 * index + 1, r = 2 * index + 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай 1 объявление 1 строчка?
task_05/src/qsort.hpp
Outdated
#include <vector> | ||
|
||
template <typename T> | ||
int Partition(std::vector<T>& arr, int l, int r) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно унести в lib/src/util.hpp уберем дублирование кода)
task_07/src/test.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавил бы ещё тест с пустым деревом и попыткой удаления
task_02/src/stack.cpp
Outdated
data_.pop(); | ||
return result; | ||
Node* t = this->top_; | ||
this->top_ = this->top_->prev_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай не будем использовать тут this, только усложняет чтение
task_02/src/stack.hpp
Outdated
|
||
private: | ||
std::stack<int> data_; | ||
Node* Top(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node это приватный тип, а Top публичный метод, довольно странно
task_02/src/stack.hpp
Outdated
void Push(int value); | ||
int Pop(); | ||
int GetMin(); | ||
|
||
private: | ||
std::vector<int> data_; | ||
Stack s_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай сделаем их приватными полями
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай еще нормальные имена дадим, не однобуквенные
task_04/src/heap.cpp
Outdated
|
||
void Heap::SiftDown(int index) { | ||
while (2 * index + 1 < heap_.size()) { | ||
int l = 2 * index + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай по длинее имена переменных сделаем: left
task_04/src/heap.cpp
Outdated
while (2 * index + 1 < heap_.size()) { | ||
int l = 2 * index + 1; | ||
int r = 2 * index + 2; | ||
int j = l; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и тут j не понятно что за переменная
task_05/src/qsort.hpp
Outdated
#include <iostream> | ||
#include <vector> | ||
|
||
#include "../../lib/src/util.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а просто #include <util.hpp>
не работает?
#include <vector> | ||
|
||
template <class T> | ||
int Partition(std::vector<T>& data, int l, int r) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а из util.hpp не получится использовать?
task_06/src/order_stats.hpp
Outdated
template <class T> | ||
int Partition(std::vector<T>& data, int l, int r) { | ||
std::srand(std::time(nullptr)); | ||
int pivotPos = l + std::rand() % (r - l); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pivot_pos
task_07/src/tree.hpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
по всему файлу: Node* n давай как-то не так коротко назовем?
task_02/src/stack.hpp
Outdated
void Push(int value); | ||
int Pop(); | ||
int GetMin(); | ||
|
||
private: | ||
std::vector<int> data_; | ||
Stack s_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай еще нормальные имена дадим, не однобуквенные
ASSERT_EQ(TempUpDayCounter(std::vector<int>{5, 12, 4, 9, 5, 4, 2}), | ||
(std::vector<int>{1, 0, 1, 0, 0, 0, 0})); | ||
ASSERT_EQ(TempUpDayCounter(std::vector<int>{2, 6, 17, 7, 3, 4}), | ||
(std::vector<int>{1, 1, 0, 0, 1, 0})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
везде в ответах 0 или 1 давай еще добавим еще каких-нибудь чисел)
task_04/src/heap.cpp
Outdated
#include <vector> | ||
|
||
void Heap::SiftUp(int index) { | ||
while (heap_[index] < heap_[(index - 1) / 2]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я бы добавил еще index != 0
что бы было явно понятно что в отрицательные числа не пойдем (можно просто index > 0 еще более явно)
No description provided.