-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter2.h
35 lines (25 loc) · 847 Bytes
/
chapter2.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
#ifndef CHAPTER2_H
#define CHAPTER2_H
#include "tools.h"
#include "tree.h"
#include <vector>
using namespace std;
// recursive way
vector<int> inOrderTraversalR(TreeNode* root);
vector<int> preOrderTraversalR(TreeNode* root);
vector<int> postOrderTraversalR(TreeNode* root);
// using stack or queue
vector<int> inOrderTraversal(TreeNode* root);
vector<int> preOrderTraversal(TreeNode* root);
vector<int> postOrderTraversal(TreeNode* root);
vector<int> levelOrderTraversal(TreeNode* root);
// binary search tree
bool isValidBST(TreeNode* root);
bool isValidBST1(TreeNode* root);
// find largest element in a binary tree
int findLargestBT(TreeNode* root, int current);
int findSmallestBT(TreeNode* root, int current);
// balanced tree
int maxDepth(TreeNode* root);
bool isBalanced(TreeNode* root);
#endif