File tree Expand file tree Collapse file tree 2 files changed +397
-397
lines changed
Threaded Binary Tree/ThreadedBinaryTree.playground Expand file tree Collapse file tree 2 files changed +397
-397
lines changed Original file line number Diff line number Diff line change 3
3
4
4
// Simple little debug function to make testing output pretty
5
5
func check( _ tree: ThreadedBinaryTree < Int > ? ) {
6
- if let tree = tree {
7
- print ( " \( tree. count) Total Nodes: " )
8
- print ( tree)
9
- print ( " Debug Info: " )
10
- print ( tree. debugDescription)
11
- print ( " In-Order Traversal: " )
12
- let myArray = tree. toArray ( )
13
- for node in myArray {
14
- print ( node)
15
- }
16
- if tree. isBST ( minValue: Int . min, maxValue: Int . max) {
17
- print ( " This is a VALID binary search tree. " )
18
- } else {
19
- print ( " This is an INVALID binary search tree. " )
20
- }
21
- if tree. isThreaded ( ) {
22
- print ( " This is a VALID threaded binary tree. " )
23
- } else {
24
- print ( " This is an INVALID threaded binary tree. " )
25
- }
6
+ if let tree = tree {
7
+ print ( " \( tree. count) Total Nodes: " )
8
+ print ( tree)
9
+ print ( " Debug Info: " )
10
+ print ( tree. debugDescription)
11
+ print ( " In-Order Traversal: " )
12
+ let myArray = tree. toArray ( )
13
+ for node in myArray {
14
+ print ( node)
15
+ }
16
+ if tree. isBST ( minValue: Int . min, maxValue: Int . max) {
17
+ print ( " This is a VALID binary search tree. " )
18
+ } else {
19
+ print ( " This is an INVALID binary search tree. " )
20
+ }
21
+ if tree. isThreaded ( ) {
22
+ print ( " This is a VALID threaded binary tree. " )
23
+ } else {
24
+ print ( " This is an INVALID threaded binary tree. " )
25
+ }
26
26
} else {
27
- print ( " This tree is nil. " )
27
+ print ( " This tree is nil. " )
28
28
}
29
29
}
30
30
You can’t perform that action at this time.
0 commit comments