-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (28 loc) · 813 Bytes
/
Copy pathmain.cpp
File metadata and controls
32 lines (28 loc) · 813 Bytes
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
//
// main.cpp
// algorithms. BST applications. second largest node.
//
// Created by alifar on 11/26/16.
// Copyright © 2016 alifar. All rights reserved.
//
#include "second_largest_node.hpp"
#include <iostream>
using namespace std;
int main(int argc, const char *argv[]){
cout << "Binart Search Tree. Second Largest Node" << endl;
BinarySearchTree<int> tree;
cout << "Insert integers into Tree: " << endl;
int item;
do{
cin >> item;
tree.Insert(item);
} while(cin.get() != '\n');
cout << "Enter an item for the task: " << endl;
cin >> item;
Tnode<int> *n1 = tree.Search(item);
Tnode<int> *result = SecondLargestNode(tree.get_root());
cout << "For Whole Tree: " << result->data << endl;
result = SecondLargestNode(n1);
cout << "For Given Node: " << result->data << endl;
return 0;
}