-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBST.h
More file actions
62 lines (47 loc) · 1.03 KB
/
BST.h
File metadata and controls
62 lines (47 loc) · 1.03 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
#ifndef BST_H
#define BST_H
#include <iostream>
#include <QGraphicsView>
#include <QTextStream>
#include <QProcess>
#include "ui_mainwindow.h"
using namespace std;
struct Node{
Node *p;
int key;
Node *left;
Node *right;
};
class BST
{
public:
void init(QGraphicsScene* scene, QGraphicsView* view);
void insert(int a);
QString preorderWalk();
QString postorderWalk();
QString inorderWalk();
void deleteNode(int val);
void deleteNode(Node* p);
void show(QLabel *label);
int countNodes();
int countLevels();
int countLeftNodes();
Node* findElem(int val);
protected:
private:
int countNodes(Node* p);
int countLevels(Node* p);
int countLeftNodes(Node *p);
void PreorderWalk(Node* p);
void PostorderWalk(Node* p);
void InorderWalk(Node* p);
Node* findSuccessor(int val);
QByteArray _prepareGraph();
void _graphWalk(Node* p, QTextStream* stream);
Node* findElem(int val, Node* p);
Node* _root;
QString string;
QGraphicsScene* _scene;
QGraphicsView* _view;
};
#endif // BST_H