diff --git "a/Homework \342\204\2267/Number1/Number1.sln" "b/Homework \342\204\2267/Number1/Number1.sln" new file mode 100644 index 0000000..c37b494 --- /dev/null +++ "b/Homework \342\204\2267/Number1/Number1.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Number1", "Number1\Number1.vcxproj", "{3F278950-A66B-4F9F-91D5-768E2910EB77}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Debug|x64.ActiveCfg = Debug|x64 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Debug|x64.Build.0 = Debug|x64 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Debug|x86.ActiveCfg = Debug|Win32 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Debug|x86.Build.0 = Debug|Win32 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Release|x64.ActiveCfg = Release|x64 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Release|x64.Build.0 = Release|x64 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Release|x86.ActiveCfg = Release|Win32 + {3F278950-A66B-4F9F-91D5-768E2910EB77}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7C0DA989-2AA5-485B-9AF3-4A74C3CC0A9B} + EndGlobalSection +EndGlobal diff --git "a/Homework \342\204\2267/Number1/Number1/Main.c" "b/Homework \342\204\2267/Number1/Number1/Main.c" new file mode 100644 index 0000000..e12548f --- /dev/null +++ "b/Homework \342\204\2267/Number1/Number1/Main.c" @@ -0,0 +1,125 @@ +#include "../../Tree/Tree/Tree.h" +#include +#include + +int main() +{ + setlocale(LC_ALL, "rus"); + printf("0 \n"); + printf("1 \n"); + printf("2 \n"); + printf("3 \n"); + printf("4 \n"); + Node* tree = createTree(); + int number = 1; + Error error = 0; + while (number != 0) + { + printf(" \n"); + while (scanf_s("%d", &number) == 0) + { + printf(", , 0 4\n"); + while (getchar() != '\n') + { + continue; + } + } + switch (number) + { + case 0: + { + deleteTree(&tree); + return 0; + } + case 1: + { + printf(", \n"); + int key = 0; + const int firstScanfResult = scanf_s("%d", &key); + if (firstScanfResult == 0) + { + printf(" \n"); + break; + } + printf(", , ( 100 )\n"); + char string[100] = { '\0' }; + const int secondScanfResult = scanf_s("%s", string, (unsigned)sizeof(string)); + if (secondScanfResult == 0) + { + printf(" \n"); + break; + } + tree = addNode(tree, key, string, &error); + if (error == INSUFFICIENT_MEMORY) + { + deleteTree(&tree); + printf(" \n"); + return -1; + } + printf(" \n"); + break; + } + case 2: + { + printf(", \n"); + int key = 0; + const int firstScanfResult = scanf_s("%d", &key); + if (firstScanfResult == 0) + { + printf(" \n"); + break; + } + printf("%s\n", getValue(tree, key)); + break; + } + case 3: + { + printf(", \n"); + int key = 0; + const int firstScanfResult = scanf_s("%d", &key); + if (firstScanfResult == 0) + { + printf(" \n"); + break; + } + bool result = inTree(tree, key); + if (!result) + { + printf(" \n"); + break; + } + printf(" \n"); + break; + } + case 4: + { + printf(", \n"); + int key = 0; + const int firstScanfResult = scanf_s("%d", &key); + if (firstScanfResult == 0) + { + printf(" \n"); + break; + } + deleteNode(&tree, key, &error); + if (error == INSUFFICIENT_MEMORY) + { + printf(" \n"); + return -1; + } + if (error == ROOT_IS_MISSING) + { + printf(" \n"); + break; + } + printf(" \n"); + break; + } + default: + { + printf(", , 0 4\n"); + break; + } + } + } +} \ No newline at end of file diff --git "a/Homework \342\204\2267/Number1/Number1/Number1.vcxproj" "b/Homework \342\204\2267/Number1/Number1/Number1.vcxproj" new file mode 100644 index 0000000..9e84ce5 --- /dev/null +++ "b/Homework \342\204\2267/Number1/Number1/Number1.vcxproj" @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {3f278950-a66b-4f9f-91d5-768e2910eb77} + Number1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Homework \342\204\2267/Number1/Number1/Number1.vcxproj.filters" "b/Homework \342\204\2267/Number1/Number1/Number1.vcxproj.filters" new file mode 100644 index 0000000..a1c2d4c --- /dev/null +++ "b/Homework \342\204\2267/Number1/Number1/Number1.vcxproj.filters" @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree.sln" "b/Homework \342\204\2267/Tree/Tree.sln" new file mode 100644 index 0000000..a09c740 --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tree", "Tree\Tree.vcxproj", "{1B08B554-064D-4A2D-A418-3C73FF3D4652}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Debug|x64.ActiveCfg = Debug|x64 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Debug|x64.Build.0 = Debug|x64 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Debug|x86.ActiveCfg = Debug|Win32 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Debug|x86.Build.0 = Debug|Win32 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Release|x64.ActiveCfg = Release|x64 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Release|x64.Build.0 = Release|x64 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Release|x86.ActiveCfg = Release|Win32 + {1B08B554-064D-4A2D-A418-3C73FF3D4652}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0EEF711C-36E8-4AC3-9FFA-66083037F612} + EndGlobalSection +EndGlobal diff --git "a/Homework \342\204\2267/Tree/Tree/Main.c" "b/Homework \342\204\2267/Tree/Tree/Main.c" new file mode 100644 index 0000000..48035ec --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/Main.c" @@ -0,0 +1,10 @@ +#include "Tree.h" +#include "TestTree.h" + +int main() +{ + if (!testAddNode() || !testDeleteNode() || !testInTree() || !testGetValue()) + { + return -1; + } +} \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree/TestTree.c" "b/Homework \342\204\2267/Tree/Tree/TestTree.c" new file mode 100644 index 0000000..b716487 --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/TestTree.c" @@ -0,0 +1,91 @@ +#include "TestTree.h" +#include "Tree.h" +#include + +bool testAddNode() +{ + Error error = NOT_ERROR; + Node* tree = createTree(); + tree = addNode(tree, 3, "awa", &error); + tree = addNode(tree, 5, "sdadad", &error); + bool firstCheck = invariant(tree, 5, 3); + tree = addNode(tree, 1, "wdwddw", &error); + bool secondCheck = invariant(tree, 1, 3); + bool thirdCheck = invariant(tree, 3, 5); + tree = addNode(tree, 6, "afwfwfw", &error); + bool fourthCheck = invariant(tree, 6, 1); + bool fifthCheck = invariant(tree, 1, 5); + bool sixthCheck = invariant(tree, 5, 3); + tree = addNode(tree, 2, "adwdwd", &error); + bool seventhCheck = invariant(tree, 2, 1); + bool eighthCheck = invariant(tree, 2, 6); + bool ninthCheck = invariant(tree, 6, 3); + bool tenthCheck = invariant(tree, 3, 5); + deleteTree(&tree); + return firstCheck && secondCheck && thirdCheck + && fourthCheck && fifthCheck && sixthCheck + && seventhCheck && eighthCheck && ninthCheck && tenthCheck && error == NOT_ERROR; +} + +bool testDeleteNode() +{ + Error error = NOT_ERROR; + Node* tree = createTree(); + tree = addNode(tree, 3, "Hello World", &error); + tree = addNode(tree, 8, "Hello army", &error); + tree = addNode(tree, 1, "AVL tree", &error); + tree = addNode(tree, -8, "^-^", &error); + tree = addNode(tree, 12, "Test", &error); + tree = addNode(tree, 2, "git commit", &error); + deleteNode(&tree, 12, &error); + bool firstCheck = inTree(tree, 12); + deleteNode(&tree, 1, &error); + bool secondCheck = inTree(tree, 1); + deleteNode(&tree, -8, &error); + bool thirdCheck = inTree(tree, -8); + deleteTree(&tree); + return !firstCheck && !secondCheck && !thirdCheck && error == NOT_ERROR; +} + +bool testInTree() +{ + Error error = NOT_ERROR; + Node* tree = createTree(); + tree = addNode(tree, 3, "cyclic list", &error); + tree = addNode(tree, -123, "Memory link", &error); + tree = addNode(tree, 10, "git checkout -b", &error); + tree = addNode(tree, -5, "eeeeee", &error); + tree = addNode(tree, 12, "stormbringer", &error); + tree = addNode(tree, 2, "i surrender", &error); + bool firstCheck = inTree(tree, 3); + bool secondCheck = inTree(tree, -5); + bool thirdCheck = inTree(tree, 12); + bool fourthCheck = inTree(tree, 2); + bool fifthCheck = inTree(tree,-123); + + bool sixthCheck = inTree(tree, 2021); + deleteNode(&tree, 2, &error); + bool seventhCheck = inTree(tree, 2); + bool eighthCheck = inTree(tree, 0); + deleteNode(&tree, -123, &error); + bool ninthCheck = inTree(tree, -123); + bool tenthCheck = inTree(tree, -47); + deleteTree(&tree); + return firstCheck && secondCheck && thirdCheck + && fourthCheck && fifthCheck && !sixthCheck + && !seventhCheck && !eighthCheck && !ninthCheck && !tenthCheck && error == NOT_ERROR; +} + +bool testGetValue() +{ + Error error = NOT_ERROR; + Node* tree = createTree(); + tree = addNode(tree, 3, "cyclic list", &error); + tree = addNode(tree, 10, "git checkout -b", &error); + const char* firstValue = getValue(tree, 3); + const char* secondValue = getValue(tree, 4); + const char* thirdValue = getValue(tree, 10); + bool result = strcmp(firstValue, "cyclic list") == 0 && strcmp(thirdValue, "git checkout -b") == 0 && secondValue == NULL && error == NOT_ERROR; + deleteTree(&tree); + return result; +} diff --git "a/Homework \342\204\2267/Tree/Tree/TestTree.h" "b/Homework \342\204\2267/Tree/Tree/TestTree.h" new file mode 100644 index 0000000..f89c36c --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/TestTree.h" @@ -0,0 +1,14 @@ +#pragma once +#include + +// Function to check the function that adds a node +bool testAddNode(); + +// Function to check the function that deletes the node +bool testDeleteNode(); + +// Function for checking a function that checks for the presence of a key +bool testInTree(); + +// Function for checking a function that gets values by key +bool testGetValue(); \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree/Tree.c" "b/Homework \342\204\2267/Tree/Tree/Tree.c" new file mode 100644 index 0000000..8c1dc5b --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/Tree.c" @@ -0,0 +1,394 @@ +#include "Tree.h" +#include +#include + +typedef struct Node +{ + struct Node* leftSon; + struct Node* rightSon; + struct Node* parent; + int key; + char* value; +} Node; + +typedef enum Direction +{ + left, + right +} Direction; + +Node* createTree() +{ + return NULL; +} + +void deleteTreeRecursive(Node* root) +{ + if (root == NULL) + { + return; + } + deleteTreeRecursive(root->leftSon); + deleteTreeRecursive(root->rightSon); + free(root->value); + free(root); +} + +void deleteTree(Node** root) +{ + deleteTreeRecursive(*root); + *root = NULL; +} + +void attach(Node* parent, Node* child, Direction direction) +{ + if (direction == left) + { + parent->leftSon = child; + } + else + { + parent->rightSon = child; + } + if (child != NULL) + { + child->parent = parent; + } +} + +void zig(Node* x) +{ + Node* father = x->parent; + if (x == father->leftSon) + { + Node* rightSon = x->rightSon; + attach(x, father, right); + attach(father, rightSon, left); + } + else + { + Node* leftSon = x->leftSon; + attach(x, father, left); + attach(father, leftSon, right); + } + x->parent = NULL; +} + +void zigZig(Node* x) +{ + Node* father = x->parent; + Node* grandFather = father->parent; + Node* grandGrandFather = grandFather->parent; + if (x == father->leftSon) + { + Node* rightSon = x->rightSon; + Node* bro = father->rightSon; + attach(father, rightSon, left); + attach(grandFather, bro, left); + attach(father, grandFather, right); + attach(x, father, right); + } + else if (x == father->rightSon) + { + Node* leftSon = x->leftSon; + Node* bro = father->leftSon; + attach(father, leftSon, right); + attach(grandFather, bro, right); + attach(father, grandFather, left); + attach(x, father, left); + } + if (grandGrandFather != NULL) + { + if (grandGrandFather->leftSon == grandFather) + { + grandGrandFather->leftSon = x; + } + else if (grandGrandFather->rightSon == grandFather) + { + grandGrandFather->rightSon = x; + } + } + x->parent = grandGrandFather; +} + +void zigZag(Node* x) +{ + Node* father = x->parent; + Node* grandFather = father->parent; + Node* grandGrandFather = grandFather->parent; + if (father->rightSon == x) + { + Node* leftSon = x->leftSon; + Node* rightSon = x->rightSon; + attach(x, father, left); + attach(grandFather, rightSon, left); + attach(father, leftSon, right); + attach(x, grandFather, right); + } + else if (father->leftSon == x) + { + Node* leftSon = x->leftSon; + Node* rightSon = x->rightSon; + attach(x, father, right); + attach(grandFather, leftSon, right); + attach(father, rightSon, left); + attach(x, grandFather, left); + } + if (grandGrandFather != NULL) + { + if (grandGrandFather->leftSon == grandFather) + { + grandGrandFather->leftSon = x; + } + else if (grandGrandFather->rightSon == grandFather) + { + grandGrandFather->rightSon = x; + } + } + x->parent = grandGrandFather; +} + +Node* splay(Node* x) +{ + if (x->parent == NULL) + { + return x; + } + if (x->parent->parent == NULL) + { + zig(x); + return x; + } + if ((x->parent->leftSon == x && x->parent->parent->leftSon == x->parent) + || (x->parent->rightSon == x && x->parent->parent->rightSon == x->parent)) + { + zigZig(x); + } + else + { + zigZag(x); + } + return splay(x); +} + + +Node* addNode(Node* root, int key, const char* value, Error* error) +{ + if (*error != NOT_ERROR) + { + return root; + } + char* copyValue = calloc(strlen(value) + 1, sizeof(char)); + if (copyValue == NULL) + { + *error = INSUFFICIENT_MEMORY; + return root; + } + strcpy(copyValue, value); + if (root == NULL) + { + Node* newRoot = (Node*)calloc(1, sizeof(Node)); + if (newRoot == NULL) + { + *error = INSUFFICIENT_MEMORY; + free(copyValue); + return root; + } + newRoot->key = key; + newRoot->value = copyValue; + return newRoot; + } + Node* currentRoot = root; + while (currentRoot != NULL) + { + if (key > currentRoot->key) + { + if (currentRoot->rightSon == NULL) + { + Node* newRoot = (Node*)calloc(1, sizeof(Node)); + if (newRoot == NULL) + { + *error = INSUFFICIENT_MEMORY; + free(copyValue); + return root; + } + newRoot->key = key; + newRoot->value = copyValue; + attach(currentRoot, newRoot, right); + return splay(newRoot); + } + currentRoot = currentRoot->rightSon; + } + else if (key == currentRoot->key) + { + free(currentRoot->value); + currentRoot->value = copyValue; + return splay(currentRoot); + } + else + { + if (currentRoot->leftSon == NULL) + { + Node* newRoot = (Node*)calloc(1, sizeof(Node)); + if (newRoot == NULL) + { + *error = INSUFFICIENT_MEMORY; + free(copyValue); + return root; + } + newRoot->key = key; + newRoot->value = copyValue; + attach(currentRoot, newRoot, left); + return splay(newRoot); + } + currentRoot = currentRoot->leftSon; + } + } + free(copyValue); + return root; +} + +Node* search(Node* root, int key) +{ + Node* newRoot = root; + while (newRoot != NULL) + { + if (key > newRoot->key) + { + newRoot = newRoot->rightSon; + } + else if (key < newRoot->key) + { + newRoot = newRoot->leftSon; + } + else + { + return newRoot; + } + } + return NULL; +} + +bool inTree(Node* root, int key) +{ + Node* searchResult = search(root, key); + return searchResult != NULL; +} + +void deleteNode(Node** root, int key, Error* error) +{ + if (*error != NOT_ERROR) + { + return; + } + Node* searchResult = search(*root, key); + if (searchResult == NULL) + { + *error = ROOT_IS_MISSING; + return; + } + *root = searchResult; + if ((*root)->rightSon == NULL && (*root)->leftSon == NULL) + { + Node* parent = (*root)->parent; + if (parent != NULL) + { + if ((*root)->parent->rightSon == (*root)) + { + (*root)->parent->rightSon = NULL; + } + else + { + (*root)->parent->leftSon = NULL; + } + } + free((*root)->value); + free(*root); + (*root) = (parent != NULL) ? splay(parent) : NULL; + return; + } + if ((*root)->rightSon != NULL && (*root)->leftSon != NULL) + { + Node* currentRoot = *root; + currentRoot = currentRoot->leftSon; + while (currentRoot->rightSon != NULL) + { + currentRoot = currentRoot->rightSon; + } + if (currentRoot == (*root)->leftSon) + { + Node* parent = (*root)->parent; + attach(currentRoot, (*root)->rightSon, right); + if (parent == NULL) + { + currentRoot->parent = NULL; + } + else + { + attach((*root)->parent, (*root)->leftSon, left); + } + free((*root)->value); + free(*root); + *root = parent == NULL ? currentRoot : splay(currentRoot->parent); + return; + } + Node* currentRootParent = currentRoot->parent; + (*root)->key = currentRoot->key; + char* newValue = calloc(strlen(currentRoot->value) + 1, sizeof(char)); + if (newValue == NULL) + { + *error = INSUFFICIENT_MEMORY; + return; + } + free((*root)->value); + strcpy(newValue, currentRoot->value); + (*root)->value = newValue; + currentRootParent->rightSon = NULL; + free(currentRoot->value); + free(currentRoot); + *root = splay(currentRootParent); + return; + } + if ((*root)->parent == NULL) + { + *root = (*root)->rightSon == NULL ? (*root)->leftSon : (*root)->rightSon; + if ((*root)->parent != NULL) + { + free((*root)->parent->value); + } + free((*root)->parent); + (*root)->parent = NULL; + return; + } + Node* parent = (*root)->parent; + if ((*root)->rightSon == NULL) + { + parent->leftSon == *root ? attach(parent, (*root)->leftSon, left) + : attach(parent, (*root)->leftSon, right); + } + else + { + parent->leftSon == *root ? attach(parent, (*root)->rightSon, left) + : attach(parent, (*root)->rightSon, right); + } + free((*root)->value); + free(*root); + *root = splay(parent); + return; +} + +bool invariant(Node* tree, int parentKey, int childKey) +{ + Node* searchResult = search(tree, childKey); + return searchResult->parent->key == parentKey && searchResult->key == childKey; +} + +char* getValue(Node* root, int key) +{ + Node* searchResult = search(root, key); + if (searchResult == NULL) + { + return NULL; + } + return searchResult->value; +} \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree/Tree.h" "b/Homework \342\204\2267/Tree/Tree/Tree.h" new file mode 100644 index 0000000..5bafa26 --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/Tree.h" @@ -0,0 +1,33 @@ +#include + +// Structure representing a tree +typedef struct Node Node; + +// Structure representing a tree +typedef enum Error +{ + NOT_ERROR, + ROOT_IS_MISSING, + INSUFFICIENT_MEMORY +} Error; + +// Function for creating a tree +Node* createTree(); + +// Function for deleting a tree +void deleteTree(Node** root); + +// Function for adding a node +Node* addNode(Node* root, int key, const char* value, Error* error); + +// Function for checking the availability of a key +bool inTree(Node* root, int key); + +// Function for deleting a node +void deleteNode(Node** root, int key, Error* error); + +// Function for checking the tree invariant +bool invariant(Node* tree, int firstKey, int secondKey); + +// Function of getting a value by key +char* getValue(Node* root, int key); \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree/Tree.vcxproj" "b/Homework \342\204\2267/Tree/Tree/Tree.vcxproj" new file mode 100644 index 0000000..1f66300 --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/Tree.vcxproj" @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {1b08b554-064d-4a2d-a418-3c73ff3d4652} + Tree + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Homework \342\204\2267/Tree/Tree/Tree.vcxproj.filters" "b/Homework \342\204\2267/Tree/Tree/Tree.vcxproj.filters" new file mode 100644 index 0000000..b5b3253 --- /dev/null +++ "b/Homework \342\204\2267/Tree/Tree/Tree.vcxproj.filters" @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file