-
Notifications
You must be signed in to change notification settings - Fork 0
/
binaryTree.h
49 lines (39 loc) · 964 Bytes
/
binaryTree.h
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
#ifndef BINARYTREE_H
#define BINARYTREE_H
#include <string>
#include <vector>
#include "bstream.h"
struct Node {
char c;
int n;
Node *l, *r;
};
class BinaryTree {
public:
static Node *merge(Node *l, Node *r);
static void free(const Node *n);
static Node *copy(const Node *n);
static std::string findPath(const Node *n, char c);
static int depth(const Node *n);
static void encode(const Node *n, obstream &obs);
static bool compare(const Node *l, const Node *r);
};
struct Pos {int row, col;};
struct Item {std::string str, leaf;};
class Fig {
std::vector<std::vector<Item>> fig;
Pos pos;
void autoFill();
public:
Fig();
void print();
void operator<= (Item item);
void downToLeft();
void downToRight();
void UpFromLeft();
void UpFromRight();
};
bool isPrintableChar(char ch);
void printTree_finer_helper(Fig &fig, const Node *n);
void printTree_finer(const Node *n);
#endif