Skip to content
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

1 1# #6

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

1 1# #6

wants to merge 10 commits into from

Conversation

MartyanovVV
Copy link
Owner

No description provided.

@MartyanovVV MartyanovVV requested a review from smatskevich April 3, 2022 19:03
1_1/main.cpp Outdated
}

int Hash(const std::string &s, int i, int table_size, unsigned long long k = 0) {
if (s.empty()) return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем проверка для пустой строки?

1_1/main.cpp Outdated
return {false, hash_string == hash0 ? hash : hash_string};
} else if (hash0 == hash_string && table[hash] == Deleted) {
hash_string = hash;
iteration += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти две строки нужно бы вытащить из ifов

1_1/main.cpp Outdated
while (iteration <= table.size()) {
if (table[hash] == s) {
return {true, hash};
} else if (table[hash] == "0") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else можно не писать

1_1/main.cpp Outdated
return {true, hash};
} else if (table[hash] == "0") {
return {false, hash_string == hash0 ? hash : hash_string};
} else if (hash0 == hash_string && table[hash] == Deleted) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else можно не писать

1_1/main.cpp Outdated
return true;
}

void ReTable() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот метод надо сделать приватным.

1_1/main.cpp Outdated

int Hash(const std::string &s, int i, int table_size, unsigned long long k = 0) {
if (s.empty()) return 0;
return (k + i * i / 2 + i / 4) % table_size;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему такой выбор констант квадратичного пробирования перебирает все ячейки? 0ая и 1ая итерация совпадают. Да, вы перебираете от 1ой, но некоторые итерации могут совпадать и дальше. Требуется или доказательство, или использование стандартных констант )

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я там сразу вызываю Hash для 1 итерации, Нужно просто переписать для С1=С2=1/2?

1_1/main.cpp Outdated
@@ -15,14 +15,22 @@ unsigned long long Sum(const std::string &s, int table_size) {
}

int Hash(const std::string &s, int i, int table_size, unsigned long long k = 0) {
if (s.empty()) return 0;
return (k + i * i / 2 + i / 4) % table_size;
return (k + i * i / 2 + i / 2) % table_size;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь целочисленное деление. Чтобы правильно работало, надо (k + (i * (i + 1))/2)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А никак нельзя задачу на выше чем 2 из 4 исправить?

Copy link
Collaborator

@smatskevich smatskevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято на 4 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants