GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java/BinaryTree.java at master · shivgy/Java

Expand file tree

/

BinaryTree.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
59 lines (49 loc) · 946 Bytes
/

BinaryTree.java

Copy path

File metadata and controls

59 lines (49 loc) · 946 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
public class BinaryTree{
public static void main(String[] args){
new BinaryTree().run();
}
static class Node{
Node left;
Node right;
int data;
public Node(int data){
this.data = data;
}
}
public void run(){
Node root = new Node(5);
System.out.println(root.data + " ");
insert(root, 1);
insert(root, 8);
insert(root, 6);
insert(root, 3);
insert(root, 9);
System.out.println("Traversing Tree InOrder");
inOrder(root);
}
public void insert(Node node, int data){
if(data < node.data){
if(node.left != null){
insert(node.left, data);
}
else{
node.left = new Node(data);
}
}
else if(data > node.data){
if(node.right != null){
insert(node.right, data);
}
else{
node.right = new Node(data);
}
}
}
public void inOrder(Node node){
if(node != null){
inOrder(node.left);
System.out.println(node.data);
inOrder(node.right);
}
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.