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-coding-problems/BinaryTree.java at main · GitH05/java-coding-problems

Expand file tree

/

BinaryTree.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
50 lines (48 loc) · 893 Bytes
/

BinaryTree.java

Copy path

File metadata and controls

50 lines (48 loc) · 893 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
import java.util.*;
public class BinaryTree
{
private TreeNode root;
private class TreeNode
{
private TreeNode left;
private TreeNode right;
private int data;
public TreeNode(int data)
{
this.data=data;
}
}
public void CreateBinaryTree()
{
TreeNode first=new TreeNode(1);
TreeNode second=new TreeNode(2);
TreeNode third=new TreeNode(3);
TreeNode fourth=new TreeNode(4);
TreeNode fifth=new TreeNode(5);
TreeNode sixth=new TreeNode(6);
//insertion of the data to the nodes
root=first;
first.left=second;
first.right=third;
second.left=fourth;
second.right=fifth;
third.left=sixth;
}
//preorder traversal of the binarry tree:
public void preOrder(TreeNode root)
{
if (root==null)
{
return;
}
System.out.println(root.data+" ");
preOrder(root.left);
preOrder(root.right);
}
public static void main(String[] args)
{
BinaryTree bt =new BinaryTree();
bt.CreateBinaryTree();
bt.preOrder(bt.root);
}
}
You are visitor 01402520 — 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.