From f151b796a66adfb1d6b7bf151f2d85fd78cc0a64 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sat, 7 Nov 2026 07:42:12 +0300 Subject: publish --- README.org | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 README.org (limited to 'README.org') diff --git a/README.org b/README.org new file mode 100644 index 0000000..64b46ec --- /dev/null +++ b/README.org @@ -0,0 +1,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: +#+begin_quote +1. Реализовать структуру данных -- хеш-таблицу, для которой характерны + операции: добавления, удаления и поиска. На ее основе реализовать + приложение -- словарь. В качестве хеш-функции, можно выбрать + произвольную функцию, например, брать первую букву слова. Добавить + функцию полной очистки словаря и загрузки/дополнения словаря из + текстового файла. +2. Для выбранного текста на русском языке построить словарь на основе + красно-черных деревьев. Реализовать функции добавления, удаления и + поиска слова. (НЕЛЬЗЯ использовать готовые структуры данных!!!). + Добавить функцию полной очистки словаря и загрузки/дополнения + словаря из текстового файла. + +Дополнительная реализация также включает возможность оптимизации +словаря (например, поиск потенциальных однокоренных слов в разных +формах; самый простой критерий -- 2/3 длины слова). Выбор слов, +которые следует оставить в словаре -- за пользователем. Использовать +готовые решения из библиотеки STL не разрешается. +#+end_quote +#+HTML: -- cgit v1.3.1