-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbt.h
49 lines (30 loc) · 1.3 KB
/
bt.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
#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <queue>
using namespace std;
class bt { // class binary tree acronym
private:
struct node { // strcture node
node* left; // declaring node left
node* right; // declaring node right
string morse; // declaring string to hold morse identity
char character; // declaring string to hold character identity
};
struct node* create(int i) { // strcuture to create binary tree iteratively
while (i != 0) { // iterate recursively i times
node* root = new node(); // create new node n
root->left = create(i - 1); // branching left
root->right = create(i - 1); // branching right
return root; // returning node value
}
};
node* root = create(5); // creating empty unordered binary tree with depth 4
public:
bt(); // default constructor
queue<string> toMorse(queue<char>& queueParameter); // translating and returning morse
void findMorse(int i, node* ptr, char charParameter, queue<string>& queueParameter); // finding morse in unordered binary tree
void toCharacter(queue<string> queueParameter); // translating back to characters
void findCharacter(int i, node* ptr, string strParameter); // finding character in unordered binary tree
};