Skip to content

Hw1 bwt#2

Open
MikePuzanov wants to merge 4 commits intomasterfrom
hw1BWT
Open

Hw1 bwt#2
MikePuzanov wants to merge 4 commits intomasterfrom
hw1BWT

Conversation

@MikePuzanov
Copy link
Copy Markdown
Owner

No description provided.

Comment thread hw1BWT/hw1BWT/BWT.cs Outdated
}
string oldString1 = ReverseBWT("cbaab", numberOfString);
return (oldString1 == string1);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Надо пустые строки между методами, и между свойствами/полями и методами, и т.д.

Comment thread hw1BWT/hw1BWT/BWT.cs Outdated
return false;
}
string oldString1 = ReverseBWT("cbaab", numberOfString);
return (oldString1 == string1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А тут скобки не обязательны

Comment thread hw1BWT/hw1BWT/BWT.cs Outdated
{
table[i, j] = table[i - 1, j - 1];
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Явное построение таблицы вращений лишает надежды на ещё один балл за "продвинутость" алгоритма.

Comment thread hw1BWT/hw1BWT/BWT.cs
numberOfStr = i;
break;
}
}

This comment was marked as resolved.

Comment thread hw1BWT/hw1BWT/BWT.cs Outdated

namespace hw1BWT
{
class BWT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

static

Comment thread hw1BWT/hw1BWT/BWT.cs Outdated
alphabet += str[i];
}
}
char[] alphaberArray = alphabet.ToCharArray(0, alphabet.Length);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Опечатка :)

Copy link
Copy Markdown
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Теперь алгоритм прямого преобразования не наивный, но реализован так, что всё равно будет работать не очень :)

Comment thread hw1BWT/hw1BWT/BWT.cs
return suffixArray;
}

public static Tuple<string, int> BWTtransform(string str)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

BWTTransform, или BwtTransform, в CamelCase каждое слово должно быть с заглавной

Comment thread hw1BWT/hw1BWT/BWT.cs
for (int j = 0; j < suffixArray.Length - i; j++)
{
string str1 = str.Substring(suffixArray[j]) + str.Substring(0, suffixArray[j]);
string str2 = str.Substring(suffixArray[j + 1]) + str.Substring(0, suffixArray[j + 1]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Substring каждый раз создаёт новую строку, так что это может быть очень серьёзным ударом по потребляемой памяти. Тут лучше было руками написать "циклическое сравнение с заданного индекса"

Comment thread hw1BWT/hw1BWT/BWT.cs
suffixArray[j + 1] = swaper;
}
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

И потом, квадратичная сортировка тут может быть не очень, потому что строки бывают длинные. В идеале надо было реализовать свой IComparer и воспользоваться библиотечным Array.Sort, передав ему компаратор.

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.

3 participants