-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBianaryTreeVisualization
More file actions
153 lines (118 loc) · 3.46 KB
/
BianaryTreeVisualization
File metadata and controls
153 lines (118 loc) · 3.46 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!-- this program is designed to display a complete bianary tree and use jquery to visualize to fidning of an object using a binary search algorithm. The user will/may enter and change values of objects and find objects using basic html and javascript.
most basic of steps:
-create a list (ordered or unordered) of numbers
-display it to the user > add css to make it pretty
-sort the list if unsorted (use jquery to show sorting algorithm)
-equate the list into a complete binary tree
-perform a search by prompting the user for a value under a defined range
-nuke button to destory everything
-ask for $20 to recover everything
<!doctype html>
<html>
<head>
<title>
Completely Lost in a Complete Bianry Tree
</title>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
<style>
var numberTree = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
#numberTree {
width: 52em;
background-color: blue;
color: white;
padding: 1em;
text-align: center;
}
.numberTreed {
width: 4em;
display: inline-block;
}
.swapping {
background-color: yellow;
color: black;
}
</style>
</head>
<body>
<h1>Visualizing a Bianry Search Algorithm in a Complete Bianry Tree</h1>
<ul id="numberTree" class="collection">
</ul>
<button>Find your favorite number!</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
/* this is how the program stores and creates array/tree elements
location = base + n*i + n*(bj-1). --- n=1 to determine which element node i at level j is stored in.
*/
public numberTree getAll()
{
for(int i = 0; i < numberTrees.size(); i++) //numberTrees name of arraylist
{
numberTree numberTree = numberTrees.get(i);
{
return numberTrees.get (i);
}
}
return null;
}
</script>
this.level=0;
this.node=0;
this.root=function(value){
this.level=0;
this.node=0;
if (value !== undefined) {
this.Nodes[this.btSMF(this.level,this.node)]=value;
}
return this.Nodes[this.btSMF(this.level,this.node)];
}
taversing:
function traverse(){
alert(tree.getNode());
if(tree.leftChild()!==undefined)traverse();
tree.parent();
if(tree.rightChild()!==undefined)traverse();
tree.parent();
}
*/
function shuffle(m) {
// finds favorite number
//the buton that finds the number
$('button').on('click', function() {
shuffle($(".numberTreed").length - 1);
});
tree=new BinaryTree();
tree.setNode(1,0,0);
tree.setNode(2,1,0);
tree.setNode(3,1,1);
tree.setNode(4,2,0);
tree.setNode(5,2,1);
tree.setNode(6,2,2);
tree.setNode(7,2,3);
alert(tree.getNode(2,1));
function BinaryTree(){
this.btSMF=function(level,node){
return node+(1<<level)-1;
}
}
how to print an array, may not work
public numberTree getAll()
{
for(int i = 0; i < numberTrees.size(); i++) //numberTrees name of arraylist
{
numberTree numberTree = numberTrees.get(i);
{
return numberTrees.get (i);
}
}
return null;
}
-->
</body>
</html>
-->