1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#+title: Implementation of a dictionary based on hash tables and red‑black trees
* Task[fn:1]
1. Implement a data structure -- a hash table, which is characterized
by the following operations: insertion, deletion, and search.
Based on it, implement an application -- a dictionary. As a hash
function, you can choose an arbitrary function, for example, taking
the first letter of the word. Add The function for completely
clearing the dictionary and loading/updating the dictionary from a
text file.
2. For the selected text in Russian, build a dictionary based on
red‑black trees. Implement functions for adding, deleting, and
searching for a word. (use of ready‑made data structures is
PROHIBITED!!!). Add a function for completely clearing the
dictionary and loading/updating the dictionary from a text file.
The additional implementation also includes the possibility of
optimizing the dictionary (for example, searching for potential
cognates in different forms; the simplest criterion is 2/3 of the word
length). The choice of words to be kept in the dictionary is up to the
user. It is not allowed to use ready‑made solutions from the STL
library.
* Documentation
The exported report can be found at [[https://git.michalec.dev/uni/term-04/graph-theory/lab-06/report.pdf][this link]].
* Showcase
*Start of the program and the menu:*
#+begin_example
HASH-TABLE:......FILE LOADED (159 ENTRIES)
RED-BLACK-TREE:..FILE LOADED (159 ENTRIES)
SELECT:
[00] GENERAL:.........EXIT
[01] HASH-TABLE:......PRINT
[02] HASH-TABLE:......INSERT
[03] HASH-TABLE:......DELETE
[04] HASH-TABLE:......SEARCH
[05] HASH-TABLE:......CLEAR
[06] HASH-TABLE:......LOAD_FROM_FILE
[07] RED-BLACK-TREE:..PRINT
[08] RED-BLACK-TREE:..INSERT
[09] RED-BLACK-TREE:..DELETE
[10] RED-BLACK-TREE:..SEARCH
[11] RED-BLACK-TREE:..CLEAR
[12] RED-BLACK-TREE:..LOAD_FROM_FILE
>
#+end_example
*Example output of the PRINT menu items*:
#+attr_html: :width 400em
[[https://git.michalec.dev/uni/term-04/graph-theory/lab-06/example-hash-table.png]]
#+attr_html: :width 400em
[[https://git.michalec.dev/uni/term-04/graph-theory/lab-06/example-red-black-tree.png]]
*Example session:* (menu replaced with # comments)
#+begin_src text
> asdf
> -1
> 13
>
> 04 # (HASH-TABLE) SEARCH
WORD: словарь
ENTRY FOUND
> 10 # (RED-BLACK-TREE) SEARCH
WORD: словарь
ENTRY FOUND
>
> 04 # (HASH-TABLE) SEARCH
WORD: тест
ENTRY NOT FOUND
> 10 # (RED-BLACK-TREE) SEARCH
WORD: тест
ENTRY NOT FOUND
> 06 # (HASH-TABLE) LOAD_FROM_FILE
FILENAME: text
FILE LOADED (30 ENTRIES)
> 12 # (RED-BLACK-TREE) LOAD_FROM_FILE
FILENAME: text
FILE LOADED (30 ENTRIES)
> 04 # (HASH-TABLE) SEARCH
WORD: тест
ENTRY FOUND
> 10 # (RED-BLACK-TREE) SEARCH
WORD: тест
ENTRY FOUND
>
> 02 # (HASH-TABLE) INSERT
WORD: слово
ENTRY INSERTED
> 04 # (HASH-TABLE) SEARCH
WORD: слово
ENTRY FOUND
> 03 # (HASH-TABLE) DELETE
WORD: слово
ENTRY DELETED
> 04 # (HASH-TABLE) SEARCH
WORD: слово
ENTRY NOT FOUND
> 05 # (HASH-TABLE) CLEAR
HASH TABLE CLEARED
> 04 # (HASH-TABLE) SEARCH
WORD: тест
ENTRY NOT FOUND
>
> 08 # (RED-BLACK-TREE) INSERT
WORD: слово
ENTRY INSERTED
> 10 # (RED-BLACK-TREE) SEARCH
WORD: слово
ENTRY FOUND
> 09 # (RED-BLACK-TREE) DELETE
WORD: слово
ENTRY DELETED
> 10 # (RED-BLACK-TREE) SEARCH
WORD: слово
ENTRY NOT FOUND
> 11 # (RED-BLACK-TREE) CLEAR
HASH TABLE CLEARED
> 10 # (RED-BLACK-TREE) SEARCH
WORD: тест
ENTRY NOT FOUND
> 00 # (GENERAL) EXIT
#+end_src
* Unlicense
#+include: UNLICENSE verse
* Footnotes
[fn:1] Original text:
#+HTML: <i>
#+begin_quote
1. Реализовать структуру данных -- хеш-таблицу, для которой характерны
операции: добавления, удаления и поиска. На ее основе реализовать
приложение -- словарь. В качестве хеш-функции, можно выбрать
произвольную функцию, например, брать первую букву слова. Добавить
функцию полной очистки словаря и загрузки/дополнения словаря из
текстового файла.
2. Для выбранного текста на русском языке построить словарь на основе
красно-черных деревьев. Реализовать функции добавления, удаления и
поиска слова. (НЕЛЬЗЯ использовать готовые структуры данных!!!).
Добавить функцию полной очистки словаря и загрузки/дополнения
словаря из текстового файла.
Дополнительная реализация также включает возможность оптимизации
словаря (например, поиск потенциальных однокоренных слов в разных
формах; самый простой критерий -- 2/3 длины слова). Выбор слов,
которые следует оставить в словаре -- за пользователем. Использовать
готовые решения из библиотеки STL не разрешается.
#+end_quote
#+HTML: </i>
|