-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbet.h
More file actions
51 lines (46 loc) · 1.27 KB
/
Copy pathbet.h
File metadata and controls
51 lines (46 loc) · 1.27 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
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
using namespace std;
class BET
{
struct BinaryNode
{
string element;
BinaryNode *left;
BinaryNode *right;
BinaryNode(const string & theElement, BinaryNode *lt, BinaryNode *rt)
{
element = theElement;
left = lt;
right = rt;
}
BinaryNode(string && theElement, BinaryNode *lt, BinaryNode *rt)
{
element = std::move(theElement);
left = lt;
right = rt;
}
};
public:
BET();
BET(const string& postfix);
BET(const BET&);
~BET();
bool buildFromPostfix(const string& postfix);
const BET & operator=(const BET &);
void printInfixExpression()const;
void printPostfixExpression()const;
size_t size()const;
size_t leaf_nodes()const;
bool empty()const;
private:
void printInfixExpression(BinaryNode *n)const;
void makeEmpty(BinaryNode* &t);
BinaryNode * clone(BinaryNode *t)const;
void printPostfixExpression(BinaryNode *n)const;
size_t size(BinaryNode *t)const;
size_t leaf_nodes(BinaryNode *t)const;
BinaryNode *start;
};