if (C< 0 && (A != 0 || B != 0))//if there is where
to borrow
{
C += overSize;
B -= 1;
}
if (B< 0 &&A != 0)//we borrow for the middle
block
{
B += overSize;
A -= 1; }
else if (B < 0)
{
B *= -1;
return new myBigInt(A, B, C, -1);
}
return new myBigInt(A, B, C, left.flag);
}
static myBigInt revers(myBigInt x, int flag)//flag
changes {
return new myBigInt(x.A, x.B, x.C, x.flag * flag); }
}
6. Conclusion
As a result, this method shows itself as a possible alternative to the built-in class. Despite the faster processing of operations, the proposed method loses in terms of speed of initialization and memory. But it is worth saying that this method can be significantly accelerated by reworking the initialization and the operations themselves using shifts, while maintaining the idea of dividing a number into blocks, the proposed method can also be redone to store any values. Thus, both methods have their pros and cons, and the idea in the proposed method can be developed for a very long time to achieve better results.
The reported study was funded by RFBR [Project title: The development of the theory of quality assessment of the information, taking into account its structural component, № 19-47-230004, from 19.04.2019]. All the work on compiling the paper and obtaining calculated and experimental data was evenly distributed among its authors.
References
1. Brent RP, Zimmermann P. Modern Computer Arithmetic. Cambridge: Cambridge University Press; 2011.
2. Microsoft MSDN open resource.
A WAY TO IMPLEMENT A BINARY SEARCH TREE IN PROGRAMMING LANGUAGE C#
Popova O.,
Associate professor - associate professor of the department of the information systems and programming of the institute of computer systems and information security of the Kuban state technological university
Bogatsky N.
Student of the department of the information systems and programming of the institute of computer systems and
information security of the Kuban state technological university
Abstract
In this article, is considered, implemented and tested one of the options for organizing binary trees, as well as its improved version. The test results were checked against one of the common implementations of a binary tree in the C# programming language. Mainly these binary trees are used to implement sets and associative arrays, and there are other uses as well. The scope of the method covers any implementation of a binary tree. The implemented class can be used as a more productive alternative to the built-in or any other implementation of the binary tree. The solution considered was implemented using Microsoft Visual Studio 2017. The results include theoretical conclusions drawn from practical research.
Keywords: Visual Studio 2017, Processing Time, Binary Tree, Time Initialization, Search in Binary Tree, Organization Method.
1. Introduction
1.1. Binary tree feature
A binary tree is a binary tree for which the properties of the search tree are executed. Each parent can have two children. Usually, when initializing a tree, try to make it as balanced as possible. This will reduce the depth of the tree, but the cell values will be relatively chaotic [1, 2].
1.2. Common Binary Tree Implementation.
Often, an implementation consists of a tree class
that concatenates multiple instances of a cell class. The cell class contains a reference to the parent, left and right child, and cell values. The tree class contains the root - the cell from which the tree starts. It is worth noting that a binary tree can only be implemented through
a cell class. Adding an element to the tree is to find free space and take it. The search consists in the fact that we look at the current element, if it is equal to the desired value, we return true, otherwise we look at the tracking cell, and so on until the tree ends. If it ended and the element was not found, then false is returned. It is the implementation described above that will be taken as the usual one, you can implement the tree in a different way, but the principles will remain the same [1, 2].
1.3. Binary search tree.
Binary search tree is a binary tree for which the properties of the search tree are executed [1, 2]. The essence of this organization is that the right child will be larger than the parent cell, and the left one will be smaller. In this tree, the search will be faster, since we
always know where the element should be. This is achieved by the similarity of the algorithms for adding and finding elements. In addition, we go to the right if the inserted element is larger than the parent and to the left if it is smaller, until we find free space. When searching, we do the same, that is, we go to the place where the element given to us should stand, if it is not there, we will return a lie, otherwise the truth. An important detail of this implementation is that the tree can go very deep on one side, when the other is empty, which can significantly affect the time for which we will look for an element, it also affects the occupied space.
2. Method
The developed class offers not only the usual implementation of the binary search tree, but also its improved version. To begin with, consider a class element that implements the basic principles.
classMyTree //tree class {
classMyNode //cell class {
publicMyNode Left; //left cell publicMyNode Right; //right cell publicint data; //cell value publicMyNode() //cell constructor { Left = null; Right = null; } } } This class uses a variant of implementation through the main tree class and an additional cell class. The cell class contains references to the right and left parent as well as cell value fields.
publicMyTree() //default constructor {root = null;}
The default constructor only sets the root values to empty.
publicvoid Add(inti) //add item {
MyNode childe = newMyNode();//added element
childe.data = i; //the value of the added element
if (root == null) //if there is no tree
{root = childe; } //starting from the root
else //if the root is already there
{ MyNode iteration = root; //the cell we are in
while (true) //until we reach the right place
{ if (i>iteration.data) //if the added value is greater
than the current one, go to the right
{ if (iteration.Right == null) //if there is no right
child
{iteration.Right = childe; //put in place
break; }
else
{ iteration = iteration.Right; //if the place does not suit us, we continue to search continue; } } else
{ if (iteration.Left == null) //the same thing only if the value is less we go to the left
{ iteration.Left = childe;
break; }
else
{ iteration = iteration.Left;
continue; } } } }
}
The method for adding an element is fully consistent with the above-described principle of allowing an element to a binary search tree. We take the current element of the tree and look in which direction we need to go. When we reach the right place, we add an element there.
publicbool Find(int x)//finding an element in the
tree
{ MyNode iteration = root; //starting from the root while (iteration != null) //if exists { int data = iteration.data; //the values of the current cell
if (data == x) //if matched, then found return true;
else if(data < x) //if the value is greater we go to the right
{ iteration = iteration.Right; continue; }
else //if the value is less, go to the right { iteration = iteration.Left; continue; } }
return false; } //if not found The search algorithm repeats the algorithm for adding an element, only instead of inserting an element, we return true or false. This is the basis of the binary search tree. As mentioned earlier, the tree can go one way. We can say if the following values are supplied to the input: 1,4,5,6 (see Fig.1).
Fig. 1. An example of a deep binary search tree.
This happens if the root value is small or large, relative to the incoming elements to be added to the tree. Ideally, you want the tree with such values to look like this (Fig.2).
1 5
I
6
Fig. 2. An example of the best binary tree construction.
The implemented class contains a constructor that organizes the tree in a similar way. The bottom line is that an array of elements that will be added to the graph is sent to the input at once. The array is sorted. Then the
element in the middle of the sorted array is taken. Further adding is divided into two stages. First we would add more than average elements, then less than average. We will also add in a special way, and not everything in a row, as this will cause a strong departure into the depths of the tree. We will add in pairs, and first a larger value in a pair, then a smaller one. This way we will achieve the most even distribution of cells in the tree. publicMyTree(int[] putArr)//constructor via array { Array.Sort(putArr); int middle = putArr.Length / 2; Add(putArr[middle]); try
{ for (inti = middle + 2; i<putArr.Length; i++)
{Add(putArr[i]);
Add(putArr[i - 1]);
i++; } }
catch
{Add(putArr[putArr.Length - 1]); } try
{for (inti = middle - 2; i>= 0; i--) {Add(putArr[i]); Add(putArr[i + 1]); i--;} } catch
{Add(putArr[0]); } }
We use built-in sorting as it is very efficient. Of the minuses - we spend resources on processing the array, but this is not a serious problem. Also, if we know the collection in advance, it will be a plus. 3. Result
Table 1.
Initialization and search time per 100,000 items
Type Initialization, sec Find, sec
myTreeUp 07.23 07.29
myTree 22.56 27.34
ordinaryTree 62.59 63.07
The first line contains a variant of a binary search tree through a sorted array, the second line is a classic version of a binary search tree and the third line is a regular binary tree (see Table 1). From the table of results it can be seen that the second method is almost twice as fast as usually the implementation of the tree, and the improved version is significantly superior to its competitors (Table 2).
Table 2.
Memory occupied by implementations per 100000 el-
ements
memory 100000
myTreeUp 3999984
myTree 4000040
ordinaryTree 4800048
Due to the more rational storage of elements, the result is the same as in the first table. Improved binary search tree storage is also significantly ahead of its competitors.
4. Program code (C#): classMyTree //tree class {classMyNode //cell class {publicMyNodeLeft; //left cell
publicMyNode Right; //right cell publicint data; //cell value publicMyNode() //cell constructor { Left = null; Right = null; } } MyNode root; //tree root public MyTree() //default constructor {root = null; }
public MyTree(int[] putArr) //constructor via array
{Array.Sort(putArr);
int middle = putArr.Length / 2;
Add(putArr[middle]);
try
{for (inti = middle + 2; i<putArr.Length; i++)
{Add(putArr[i]);
Add(putArr[i - 1]);
i++; } } catch
{Add(putArr[putArr.Length - 1]); } try
{for (inti = middle - 2; i>= 0; i--) {Add(putArr[i]); Add(putArr[i + 1]); i-- ; } } catch
{Add(putArr[0]);}} publicvoid Add(inti) //add item {MyNode childe = newMyNode(); //added element
childe.data = i; //the value of the added element
if (root == null) //if there is no tree
{root = childe; } //starting from the root
else //if the root is already there
{MyNode iteration = root; //cell in which we are
while (true) //until we reach the right place
{if (i>iteration.data) //if the added value is greater
than
the current one, go to the right
{if (iteration.Right == null) //if there is no right
child
{iteration.Right = childe; //put in place
break; }
else
{ iteration = iteration.Right; //if the place does not suit us,
we continue to search
continue; } }
else
{if (iteration.Left == null) //the same thing only if the value
is less we go to the left {iteration.Left = childe; break; } else
{iteration = iteration.Left; continue; } } } } }
publicboolFind(intx) //finding an element in the
tree
{MyNode iteration = root; //starting from the root while (iteration != null) //if exists {int data = iteration.data; //the values of the current cell
if (data == x) //if matched, then found return true;
else if(data < x) //if the value is greater, go to the
right
{ iteration = iteration.Right; continue; }
else //if the value is less, go to the right {iteration = iteration.Left; continue; } }
return false; } } //if not found 5. Conclusion
As a result, the implemented method proved to be a good way to implement a binary tree in the C # programming language. It is also important to remember that if other languages have binary search trees, then the option of organizing through an array is a unique way that can significantly improve the processing time for
working with binary trees. This improvement can be easily implemented in another programming language.
The reported study was funded by RFBR [Project title: The development of the theory of quality assessment of the information, taking into account its structural component, № 19-47-230004, from 19.04.2019]. All the work on compiling the paper and obtaining calculated and experimental data was evenly distributed among its authors.
References
3. Siehedazu Traversierung (mit Code be is pielen) und Ben Pfaff. An Introduction to Binary Search Trees and Balanced Trees. Free Software Foundation. Boston; 2004.
4. Microsoft MSDN open resource.
РАЗРАБОТКА СИСТЕМЫ СОЗДАНИЯ И ХРАНЕНИЯ СЛОВАРНЫХ СТАТЕЙ ТОЛКОВОГО
СЛОВАРЯ
Смалюк А. Ф.
Белорусский Национальный Технический Университет, Минск Беларусь
Кощенко В.А.
Институт языкознания имени Якуба Коласа Центра белорусской культуры, языка и литературы
НАН Беларуси
DEVELOPMENT OF A SYSTEM FOR CREATION AND STORING VOCABULARY ARTICLES OF
A EXPLANATORY DICTIONARY
Smaliuk A.,
Belarusian National Technical University, Minsk Belarus
Koshchanka U.
The Jakub Kolas Institute for Linguistics of the Center for the Belarusian Culture, Language and Literature, NASB of Belarus
Аннотация
В статье описывается разработанная система для автоматизации процесса создания толкового словаря. Данная система призвана сократить трудозатраты при создании словаря, упростить взаимодействие между членами коллектива, занимающегося его составлением, ускорить и удешевить процесс разработки. Клиент серверная архитектура приложения позволяет централизовано хранить данные словаря, и при этом обеспечивает одновременный доступ нескольких пользователей к нему. В статье рассмотрены основные требования с создаваемому программному обеспечению, выполнен анализ и обоснование используемых при разработке технологий. Рассмотрена архитектура приложения, основной функционал его составляющих, особенности взаимодействия между его компонентами.
Abstract
The article describes the developed system for automating the process of creating an explanatory dictionary. This system is designed to reduce labor costs when creating a dictionary, to simplify the interaction between members of the team involved in its creation, to speed up and reduce the cost of the development process. The clientserver architecture of the application allows to centrally store the dictionary data, while providing simultaneous access to multiple users. The article discusses the basic requirements for the created software, analyzes and justifies the technologies used in the development. The architecture of the application, the main functionality of its components, the features of the interaction between its components are discussed.
Ключевые слова: толковый словарь, базы данных, веб-сервисы, Java, словарная статья.
Keywords: explanatory dictionary, database, web service, Java, dictionary article.
Введение
Разработка толкового словаря для является чрезвычайно сложной и объемной задачей. Фундаментальные толковые словари отличаются значительным объемом, зачастую являясь многотомными и требуют выполнения большого объема работы
для создания. Как правило, над созданием толковых словарей работают большие коллективы лингвистов в течение продолжительного времени. В связи с этим возникает необходимость в автоматизации многих операций связанных с созданием и хране-