-
Notifications
You must be signed in to change notification settings - Fork 0
/
btPrettyPrint.h
48 lines (42 loc) · 1.06 KB
/
btPrettyPrint.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
//
// btPrettyPrint.h
//
// Created by ritute on 2012-12-18.
// Copyright (c) 2012 ritute. All rights reserved.
//
#ifndef __btPrettyPrint__
#define __btPrettyPrint__
namespace btPrettyPrint {
/*
* Binary tree node
*/
template <typename Comparable>
struct BTNode {
Comparable data;
BTNode* left;
BTNode* right;
/*
* d : Comparable item representing the node's data
* l : pointer to node's left child
* r : pointer to node's right child
*/
BTNode(Comparable d, BTNode* l = nullptr, BTNode* r = nullptr)
: data(d), left(l), right(r) {}
};
/*
* Prints the binary tree to standard output, in tree-like fashion.
*
* root : pointer to root of binary tree
*
* eg. (A)
* / \
* / \
* / \
* (B) (C)
* / \ / \
* (D) (E) (F) (G)
*/
template <typename Comparable>
void printBT(BTNode<Comparable>* root);
}
#endif /* defined(__btPrettyPrint__) */