-
Notifications
You must be signed in to change notification settings - Fork 0
/
TreeType.h
39 lines (35 loc) · 1.05 KB
/
TreeType.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
#include <string>
#include <fstream>
typedef int ItemType;
struct TreeNode;
#include "QueType.h"
enum OrderType {PRE_ORDER, IN_ORDER, POST_ORDER};
class TreeType
{
public:
TreeType(); // constructor
~TreeType(); // destructor
TreeType(const TreeType& originalTree);
void operator=(const TreeType& originalTree);
// copy constructor
void MakeEmpty();
bool IsEmpty() const;
bool IsFull() const;
int GetLength() const;
ItemType GetItem(ItemType item, bool& found);
void PutItem(ItemType item);
void DeleteItem(ItemType item);
void ResetTree(OrderType order);
ItemType GetNextItem(ItemType& item, OrderType order, bool& finished);
void Print(std::ofstream& outFile) const;
// Exercise 6
ItemType Ancestors(ItemType item, bool& found, std::ofstream& outFile);
ItemType AncestorsReverse(ItemType item, bool& found, std::ofstream& outFile);
ItemType LeafCount(int leaves);
ItemType SingleParentCount(int spcount);
private:
TreeNode* root;
QueType preQue;
QueType inQue;
QueType postQue;
};