-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathttTree.h
49 lines (44 loc) · 1.28 KB
/
ttTree.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
// Assignment: Project 3
// Created By: Jevan Smith, Isaac Davidson
// Course: CS 415
// Date: April 16, 2019
// Descriptions: A simple Binary Search Tree, and 2-3 Tree
// implementation supporting features like
// search, insert and inorder traversal.
#ifndef TTTREE_H
#define TTTREE_H
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
class ttTree {
public:
ttTree();
void printTree(ostream & out = cout);
void contains();
void buildTree(ifstream & input);
void timeTaken();
private:
struct node {
node * left;
node * middle;
node * right;
string leftKey;
string rightKey;
vector<int> leftLines;
vector<int> rightLines;
};
node * root;
vector<string> words;
node * createNode(const string x, node * left, node * middle, node * right);
bool isLeafNode(node * x);
node * add(node * x, node * n);
node * insert(const string &key, int line, node * root, int &distWord);
bool searchTreeHelper(node * x, string value, vector<int> &lines);
void printLines(node * x, bool isLeft, ostream & out);
void print(node * x, ostream & out);
void printTreeHelper(node * x, ostream & out);
int findHeight(node * x);
};
#endif