Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Khalilov_Shokhboz_cw/Khalilov_Shokhboz_cw.odt
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/Khalilov_Shokhboz_cw.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions Khalilov_Shokhboz_cw/RBTree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
BASE_DIR=$(dirname "$(readlink -f "$0")")
export LD_LIBRARY_PATH="$BASE_DIR"/lib/:"$BASE_DIR":$LD_LIBRARY_PATH
export QML_IMPORT_PATH="$BASE_DIR"/qml/:$QML_IMPORT_PATH
export QML2_IMPORT_PATH="$BASE_DIR"/qml/:$QML2_IMPORT_PATH
export QT_PLUGIN_PATH="$BASE_DIR"/plugins/:$QT_PLUGIN_PATH
export QTWEBENGINEPROCESS_PATH="$BASE_DIR"/bin/QtWebEngineProcess
export QTDIR="$BASE_DIR"
export QT_QPA_PLATFORM_PLUGIN_PATH="$BASE_DIR"/plugins/platforms:$QT_QPA_PLATFORM_PLUGIN_PATH

"$BASE_DIR/bin/RBTree" "$@"
Binary file added Khalilov_Shokhboz_cw/RBTree.zip
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/bin/RBTree
Binary file not shown.
7 changes: 7 additions & 0 deletions Khalilov_Shokhboz_cw/bin/qt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Paths]
Prefix= ./../
Libraries= ./lib/
Plugins= ./plugins/
Imports= ./qml/
Translations= ./translations/
Qml2Imports= ./qml/
Binary file added Khalilov_Shokhboz_cw/lib/libQt5Core.so.5
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libQt5DBus.so.5
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libQt5Gui.so.5
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libQt5Widgets.so.5
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libQt5XcbQpa.so.5
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libicudata.so.56
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libicui18n.so.56
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/lib/libicuuc.so.56
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Khalilov_Shokhboz_cw/plugins/platforms/libqxcb.so
Binary file not shown.
1,042 changes: 1,042 additions & 0 deletions Khalilov_Shokhboz_cw/src/Makefile

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions Khalilov_Shokhboz_cw/src/RBTree.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#TEMPLATE = app
#TARGET = RBTree
##INCLUDEPATH += .
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++20

DEFINES += QT_DEPRECATED_WARNINGS
# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

# Input
HEADERS += documentation.h helperfunctions.h mainwindow.h node.hpp \
libs.h
SOURCES += documentation.cpp \
helperfunctions.cpp \
main.cpp \
mainwindow.cpp \
node.cpp
RESOURCES += resource.qrc


# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
355 changes: 355 additions & 0 deletions Khalilov_Shokhboz_cw/src/RBTree.pro.user

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions Khalilov_Shokhboz_cw/src/documentation.cpp

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Khalilov_Shokhboz_cw/src/documentation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef DOCUMENTATION_H
#define DOCUMENTATION_H

#include "libs.h"

class Documentation : public QDialog
{
Q_OBJECT
private:
QPushButton *close;
QGridLayout *grid_layout;
QScrollArea *ScrolArea;
QTextBrowser *info;

public:
Documentation(QWidget *parent = 0);
~Documentation();
};

#endif // DOCUMENTATION_H
171 changes: 171 additions & 0 deletions Khalilov_Shokhboz_cw/src/helperfunctions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#include "helperfunctions.h"

bool isRed(Node *elem)
{
if (elem != nullptr)
return elem->getColor() == RED;

return false;
}

bool isBlack(Node *elem)
{
if (elem != nullptr){

return elem->getColor() == BLACK;
}

return true;
}

Node *Parent(Node *elem)
{
// * Обратите внимание, что для корневого узла родительский элемент имеет значение null.
return elem == nullptr ? nullptr : elem->getParent();
}

Node *GrandParent(Node *elem)
{
// * Обратите внимание, что он вернет nullptr, если это root или дочерний элемент root
return Parent(Parent(elem));
}

bool isLeft(Node *elem)
{
if (Parent(elem))
return Parent(elem)->getLeft() == elem;

return false;
}

bool isRight(Node *elem)
{
if (Parent(elem))
return Parent(elem)->getRight() == elem;
return false;
}

Node *Brother(Node *elem){
// * Отсутствие родителя означает отсутствие брата или сестры.
if (Parent(elem))
{
if (isLeft(elem))
{
return Parent(elem)->getRight();
}
else
{
return Parent(elem)->getLeft();
}
}

return nullptr;
}

Node *Uncle(Node *elem)
{
//* Отсутствие родителя означает отсутствие дяди
return Brother(Parent(elem));
}

Node *Root(Node *elem){

Node *root = elem;
if(root){
while (root->getParent())
{
root = root->getParent();
}
}
return root;
}

Node *findElem(Node *root, int key)
{
Node *tmp = root;
while (tmp != nullptr)
{
if (tmp->getValue() == key)
{
return tmp;
}
if (tmp->getValue() > key)
{
tmp = tmp->getLeft();
}
else
{
tmp = tmp->getRight();
}
}
return nullptr;
}

void free(Node *elem){

if( isLeaf( elem )){

return;
}
if( isLeft ( elem ) ) {

Parent(elem )->setLeft(nullptr);
}
else if( isRight ( elem ) )
{
Parent(elem)->setRight(nullptr);
}

delete elem;
elem = nullptr;
}

int CountElem(Node *elem, int key){

int l = 0, r = 0;
if(elem->getLeft())
l = CountElem(elem->getLeft(), key);

if(elem->getRight())
r = CountElem(elem->getRight(), key);

if( elem->getValue() == key ){
return 1+l+r;
}
return l+r;
}

bool isNotLeaf(Node *elem){
return elem != nullptr;
}

bool isLeaf(Node *elem){
return elem == nullptr;
}


//int Show(Node *elem, QGraphicsScene *Scene, int x, int y){

// int l = 0;
// int r = 0;
// if(elem == nullptr){
// return 1;
// }
// Scene->addItem(elem);
// l = Show(elem->getLeft(), Scene, x-50, y+50);
// r = Show(elem->getRight(), Scene, x+50, y+50);

// if( isLeft( elem ) ) {

// elem->setPos(x-r*50, y);

// }
// else if( isRight(elem) ){

// elem->setPos(x+l*50, y);
// }
// else {
// elem->setPos(x, y);
// }
// return l>r? l : r;
//}
37 changes: 37 additions & 0 deletions Khalilov_Shokhboz_cw/src/helperfunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef HELPERFUNCTIONS_H
#define HELPERFUNCTIONS_H
#include "node.hpp"

void createForest(Node *&root, int *arr, int size);

bool isRed(Node *elem);

bool isBlack(Node *elem);

Node *Parent(Node *elem);

Node *GrandParent(Node *elem);

bool isLeft(Node *elem);

bool isRight(Node *elem);

Node *Brother(Node *elem);

Node *Uncle(Node *elem);

Node * Root(Node* elem);;

Node *findElem(Node *root, int key);

void free(Node *elem);

bool isLeaf(Node *elem);

bool isNotLeaf(Node *elem);

int CountElem(Node *elem, int key);

//int Show(Node *elem, QGraphicsScene *Scene, int x, int y );

#endif // HELPERFUNCTIONS_H
34 changes: 34 additions & 0 deletions Khalilov_Shokhboz_cw/src/libs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef LIBS_H
#define LIBS_H

#include <QDialog>
#include <QGridLayout>
#include <QPushButton>
#include <QScrollArea>
#include <QTextBrowser>
#include <QMainWindow>
#include <QSlider>
#include <QTextBrowser>
#include <QTimer>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QBoxLayout>
#include <QGraphicsEllipseItem>
#include <QObject>
#include <QColor>
#include <QBrush>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QScrollBar>


#include <QSpinBox>


#include <iostream>
#include <fstream>
#include <string>


#endif // LIBS_H
11 changes: 11 additions & 0 deletions Khalilov_Shokhboz_cw/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Loading