-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmain.m
More file actions
32 lines (26 loc) · 893 Bytes
/
Copy pathmain.m
File metadata and controls
32 lines (26 loc) · 893 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.m
// BinaryTree
//
// Created by Matt Eaton on 11/21/18.
// Copyright © 2018 Matt Eaton. All rights reserved.
//
#import <Foundation/Foundation.h>
#include "BinaryTree.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSArray *binaryTreeRawData = @[@5, @6, @17, @1, @15, @32, @3, @8, @91];
Node *root = [[Node alloc] init];
BinaryTree *tree = [[BinaryTree alloc] init];
// Create the
root = [tree createBinaryTree:binaryTreeRawData andRoot:root];
[tree printBinaryTree:root];
int level = [tree find:15 atLevel:0 onTree:root];
NSString *message = @"Numeric value not found in Binary Tree";
if (level != -1) {
message = [NSString stringWithFormat:@"Numeric value found at level: %d", level];
}
NSLog(@"%@", message);
}
return 0;
}