-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathavl.h
More file actions
72 lines (68 loc) · 1.94 KB
/
avl.h
File metadata and controls
72 lines (68 loc) · 1.94 KB
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
#ifndef AVL_H
#define AVL_H
#include <QMainWindow>
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include<QLineEdit>
#include<QVector>
#include <QLabel>
#include <QMessageBox>
#include <QPainter>
#include <QEventLoop>
#include "types.h"
#include <QTimer>
#include <QThread>
#include <QResizeEvent>
#include<QQueue>
#include<QIntValidator>
class AVL : public QWidget
{
Q_OBJECT
int width, orgWidth;
int height, orgHeight;
int levels;
int time_delay;
bool formEdges;
bool isPaused;
TreeNode *root;
TreeNode *in_process;
QLabel *insert_label;
QLineEdit *delete_input;
QLabel *delete_label;
QLineEdit *insert_input;
TreeNode *empty_node;
TreeNode *predecessor;
QLabel *messagelabel;
QMap<int,QPushButton*> buttons;
public:
AVL(QWidget* parent, int Width, int Height) ;
void paintEvent(QPaintEvent *event) override;
void changeButtonsStatus(bool status) ;
void pauseResume() ;
void reset();
void resizeButtons(int w,int h);
void insertion();
void deletion();
void set_tree();
void setHeight( TreeNode* node ) ;
int getMaxLevel( TreeNode* node ) ;
int get_height(TreeNode* node);
int getBalanceFactor(TreeNode* node) ;
void delete_Node(TreeNode* node,TreeNode *parent, int key, bool& found);
void resizeEvent(QResizeEvent *event) override ;
TreeNode* find_predecessor(TreeNode *node);
TreeNode* leftRotation( TreeNode* node ) ;
TreeNode* rightRotation( TreeNode* node ) ;
void balanceNode( TreeNode* node ) ;
void move_subtree(TreeNode *from , TreeNode *to);
void rotate_subtree( TreeNode *from , TreeNode *to ) ;
void set_button(int &start_x,int start_y,int w,int h,int seperation,QString label,int button);
void display_message(QString message,int time);
~AVL();
signals:
void backToAlgorithms(); // Signal to go back
protected slots:
void handleBackButton(); // Slot for back button
};
#endif // AVL_H