SlideShare a Scribd company logo
1 of 12
Download to read offline
ANS:
import java.util.Scanner;
class Bina_node
{
Bina_node l_1, r_1;
int dt;//here declare variables
public Bina_node()//constructor
{
l_1 = null;
r_1 = null;
dt = 0;
}
public Bina_node(int n)//here parameter constractor
{
l_1 = null;
r_1 = null;
dt = n;
}
public void nin_left(Bina_node n)//copy constractor
{
l_1 = n;
}
public void nin_right(Bina_node n)
{
r_1 = n;
}
public Bina_node get_lstf()
{
return l_1;
}
public Bina_node get_go()
{
return r_1;
}
public void set_data(int d)
{
dt = d;
}
public int get_data()
{
return dt;
}
}
class Bina_tree//class banary tree
{
private Bina_node rf;
public Bina_tree()
{
rf = null;
}
public boolean isEmpty()//here empty or not
{
return rf == null;
}
public void tee_insert(int dt)
{
rf = tee_insert(rf, dt);
}
private Bina_node tee_insert(Bina_node node, int dt)
{
if (node == null)
node = new Bina_node(dt);
else
{
if (node.get_go() == null)
node.r_1 = tee_insert(node.r_1, dt);
else
node.l_1 = tee_insert(node.l_1, dt);
}
return node;
}
public int cou_Node()
{
return cou_Node(rf);
}
private int cou_Node(Bina_node r)
{
if (r == null)
return 0;
else
{
int l = 1;
l += cou_Node(r.get_lstf());
l += cou_Node(r.get_go());
return l;
}
}
public boolean bin_serc(int tree_val)//function called
{
return bin_serc(rf, tree_val);
}
private boolean bin_serc(Bina_node r, int tree_val)
{
if (r.get_data() == tree_val)
return true;
if (r.get_lstf() != null)
if (bin_serc(r.get_lstf(), tree_val))
return true;
if (r.get_go() != null)
if (bin_serc(r.get_go(), tree_val))
return true;
return false;
}
public void in_order()
{
in_order(rf);
}
private void in_order(Bina_node r)
{
if (r != null)
{
in_order(r.get_lstf());
System.out.print(r.get_data() +" ");
in_order(r.get_go());
}
}
public void pre_order()
{
pre_order(rf);
}
private void pre_order(Bina_node r)
{
if (r != null)
{
System.out.print(r.get_data() +" ");
pre_order(r.get_lstf());
pre_order(r.get_go());
}
}
public void post_order()
{
post_order(rf);
}
private void post_order(Bina_node r)
{
if (r != null)
{
post_order(r.get_lstf());
post_order(r.get_go());
System.out.print(r.get_data() +" ");
}
}
}
public class Bina_Tree//binary tree class
{
public static void main(String[] args)//here main methode
{
Scanner sc = new Scanner(System.in);//here scanner
Bina_tree bin_c = new Bina_tree();
System.out.println("Binary Tree  ");
char ch;
do
{
System.out.println(" here Binary Tree Operations ");
System.out.println("1 for insert 2 for search 3 for count 4 for check");//here choice
numbers
int cho = sc.nextInt();
int k;
switch (cho)
{
k++;
case 1 :System.out.println("please enter insert ele");
bin_c.tee_insert( sc.nextInt() );
break;
case 2 :System.out.println("enter bin_search");//here search option
System.out.println("result"+ bin_c.bin_serc( sc.nextInt() ));//result
break;
case 3 :System.out.println("Nodes"+ bin_c.cou_Node());
break;
case 4 :System.out.println("Empty"+ bin_c.isEmpty());
break;
default ://here default condition
System.out.println("enter 1 TO 4 only");//here enter 1 to 4
break;
}
System.out.print(" Post_order : ");
bin_c.post_order();
System.out.print(" Pre_order : ");
bin_c.pre_order();
System.out.print(" In_order : ");
bin_c.in_order();
System.out.println("do you want to continue type y or n ..*  ");
ch = sc.next().charAt(0); //to convert charat
} while(ch=='y'||ch=='Y');//TO CHECK THE CONDITON
}
System.out.println("sum of nodes is %d",k);
}
Solution
ANS:
import java.util.Scanner;
class Bina_node
{
Bina_node l_1, r_1;
int dt;//here declare variables
public Bina_node()//constructor
{
l_1 = null;
r_1 = null;
dt = 0;
}
public Bina_node(int n)//here parameter constractor
{
l_1 = null;
r_1 = null;
dt = n;
}
public void nin_left(Bina_node n)//copy constractor
{
l_1 = n;
}
public void nin_right(Bina_node n)
{
r_1 = n;
}
public Bina_node get_lstf()
{
return l_1;
}
public Bina_node get_go()
{
return r_1;
}
public void set_data(int d)
{
dt = d;
}
public int get_data()
{
return dt;
}
}
class Bina_tree//class banary tree
{
private Bina_node rf;
public Bina_tree()
{
rf = null;
}
public boolean isEmpty()//here empty or not
{
return rf == null;
}
public void tee_insert(int dt)
{
rf = tee_insert(rf, dt);
}
private Bina_node tee_insert(Bina_node node, int dt)
{
if (node == null)
node = new Bina_node(dt);
else
{
if (node.get_go() == null)
node.r_1 = tee_insert(node.r_1, dt);
else
node.l_1 = tee_insert(node.l_1, dt);
}
return node;
}
public int cou_Node()
{
return cou_Node(rf);
}
private int cou_Node(Bina_node r)
{
if (r == null)
return 0;
else
{
int l = 1;
l += cou_Node(r.get_lstf());
l += cou_Node(r.get_go());
return l;
}
}
public boolean bin_serc(int tree_val)//function called
{
return bin_serc(rf, tree_val);
}
private boolean bin_serc(Bina_node r, int tree_val)
{
if (r.get_data() == tree_val)
return true;
if (r.get_lstf() != null)
if (bin_serc(r.get_lstf(), tree_val))
return true;
if (r.get_go() != null)
if (bin_serc(r.get_go(), tree_val))
return true;
return false;
}
public void in_order()
{
in_order(rf);
}
private void in_order(Bina_node r)
{
if (r != null)
{
in_order(r.get_lstf());
System.out.print(r.get_data() +" ");
in_order(r.get_go());
}
}
public void pre_order()
{
pre_order(rf);
}
private void pre_order(Bina_node r)
{
if (r != null)
{
System.out.print(r.get_data() +" ");
pre_order(r.get_lstf());
pre_order(r.get_go());
}
}
public void post_order()
{
post_order(rf);
}
private void post_order(Bina_node r)
{
if (r != null)
{
post_order(r.get_lstf());
post_order(r.get_go());
System.out.print(r.get_data() +" ");
}
}
}
public class Bina_Tree//binary tree class
{
public static void main(String[] args)//here main methode
{
Scanner sc = new Scanner(System.in);//here scanner
Bina_tree bin_c = new Bina_tree();
System.out.println("Binary Tree  ");
char ch;
do
{
System.out.println(" here Binary Tree Operations ");
System.out.println("1 for insert 2 for search 3 for count 4 for check");//here choice
numbers
int cho = sc.nextInt();
int k;
switch (cho)
{
k++;
case 1 :System.out.println("please enter insert ele");
bin_c.tee_insert( sc.nextInt() );
break;
case 2 :System.out.println("enter bin_search");//here search option
System.out.println("result"+ bin_c.bin_serc( sc.nextInt() ));//result
break;
case 3 :System.out.println("Nodes"+ bin_c.cou_Node());
break;
case 4 :System.out.println("Empty"+ bin_c.isEmpty());
break;
default ://here default condition
System.out.println("enter 1 TO 4 only");//here enter 1 to 4
break;
}
System.out.print(" Post_order : ");
bin_c.post_order();
System.out.print(" Pre_order : ");
bin_c.pre_order();
System.out.print(" In_order : ");
bin_c.in_order();
System.out.println("do you want to continue type y or n ..*  ");
ch = sc.next().charAt(0); //to convert charat
} while(ch=='y'||ch=='Y');//TO CHECK THE CONDITON
}
System.out.println("sum of nodes is %d",k);
}

More Related Content

Similar to ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf

C++ BinaryTree Help Creating main function for Trees...Here are .pdf
C++ BinaryTree Help  Creating main function for Trees...Here are .pdfC++ BinaryTree Help  Creating main function for Trees...Here are .pdf
C++ BinaryTree Help Creating main function for Trees...Here are .pdfforecastfashions
ย 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
ย 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
ย 
A perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfA perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfmichardsonkhaicarr37
ย 
7 functions
7  functions7  functions
7 functionsMomenMostafa
ย 
The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189Mahmoud Samir Fayed
ย 
The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31Mahmoud Samir Fayed
ย 
#include iostream #include deque #include stdio.hย ย  scan.pdf
#include iostream #include deque #include stdio.hย ย  scan.pdf#include iostream #include deque #include stdio.hย ย  scan.pdf
#include iostream #include deque #include stdio.hย ย  scan.pdfanandmobile
ย 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
ย 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfmail931892
ย 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015Binary Studio
ย 
Please help write BinaryTree-java Thank you! Create a class BinaryTr.pdf
Please help write BinaryTree-java Thank you!   Create a class BinaryTr.pdfPlease help write BinaryTree-java Thank you!   Create a class BinaryTr.pdf
Please help write BinaryTree-java Thank you! Create a class BinaryTr.pdfinfo750646
ย 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with PythonHan Lee
ย 
mainpublic class AssignmentThree { ย ย  public static void ma.pdf
mainpublic class AssignmentThree { ย ย  public static void ma.pdfmainpublic class AssignmentThree { ย ย  public static void ma.pdf
mainpublic class AssignmentThree { ย ย  public static void ma.pdffathimafancyjeweller
ย 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfillyasraja7
ย 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docxKamalSaini561034
ย 
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdfarihantmobileselepun
ย 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
ย 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
ย 
#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docx#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docxajoy21
ย 

Similar to ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf (20)

C++ BinaryTree Help Creating main function for Trees...Here are .pdf
C++ BinaryTree Help  Creating main function for Trees...Here are .pdfC++ BinaryTree Help  Creating main function for Trees...Here are .pdf
C++ BinaryTree Help Creating main function for Trees...Here are .pdf
ย 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
ย 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
ย 
A perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfA perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdf
ย 
7 functions
7  functions7  functions
7 functions
ย 
The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189
ย 
The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31The Ring programming language version 1.4.1 book - Part 22 of 31
The Ring programming language version 1.4.1 book - Part 22 of 31
ย 
#include iostream #include deque #include stdio.hย ย  scan.pdf
#include iostream #include deque #include stdio.hย ย  scan.pdf#include iostream #include deque #include stdio.hย ย  scan.pdf
#include iostream #include deque #include stdio.hย ย  scan.pdf
ย 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
ย 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
ย 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
ย 
Please help write BinaryTree-java Thank you! Create a class BinaryTr.pdf
Please help write BinaryTree-java Thank you!   Create a class BinaryTr.pdfPlease help write BinaryTree-java Thank you!   Create a class BinaryTr.pdf
Please help write BinaryTree-java Thank you! Create a class BinaryTr.pdf
ย 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
ย 
mainpublic class AssignmentThree { ย ย  public static void ma.pdf
mainpublic class AssignmentThree { ย ย  public static void ma.pdfmainpublic class AssignmentThree { ย ย  public static void ma.pdf
mainpublic class AssignmentThree { ย ย  public static void ma.pdf
ย 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdf
ย 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
ย 
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
ย 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
ย 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
ย 
#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docx#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docx
ย 

More from anukoolelectronics

When two atoms are covalently bonded, the more el.pdf
                     When two atoms are covalently bonded, the more el.pdf                     When two atoms are covalently bonded, the more el.pdf
When two atoms are covalently bonded, the more el.pdfanukoolelectronics
ย 
we can senthysise 4 methylheptanal to propene by .pdf
                     we can senthysise 4 methylheptanal to propene by .pdf                     we can senthysise 4 methylheptanal to propene by .pdf
we can senthysise 4 methylheptanal to propene by .pdfanukoolelectronics
ย 
The enthalpy change is negative because a bond is.pdf
                     The enthalpy change is negative because a bond is.pdf                     The enthalpy change is negative because a bond is.pdf
The enthalpy change is negative because a bond is.pdfanukoolelectronics
ย 
moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf
                     moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf                     moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf
moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdfanukoolelectronics
ย 
In Chemistry, a mixture is defined as two or more.pdf
                     In Chemistry, a mixture is defined as two or more.pdf                     In Chemistry, a mixture is defined as two or more.pdf
In Chemistry, a mixture is defined as two or more.pdfanukoolelectronics
ย 
Suppose distribution an IP datagram since A to F. Suppose over the e.pdf
Suppose distribution an IP datagram since A to F. Suppose over the e.pdfSuppose distribution an IP datagram since A to F. Suppose over the e.pdf
Suppose distribution an IP datagram since A to F. Suppose over the e.pdfanukoolelectronics
ย 
The picture is identified as the negative coccus.Gram-negative bac.pdf
The picture is identified as the negative coccus.Gram-negative bac.pdfThe picture is identified as the negative coccus.Gram-negative bac.pdf
The picture is identified as the negative coccus.Gram-negative bac.pdfanukoolelectronics
ย 
The disclosure requirements for the assignment of specific receivabl.pdf
The disclosure requirements for the assignment of specific receivabl.pdfThe disclosure requirements for the assignment of specific receivabl.pdf
The disclosure requirements for the assignment of specific receivabl.pdfanukoolelectronics
ย 
The answer is composite key.If the primarykey is combination of on.pdf
The answer is composite key.If the primarykey is combination of on.pdfThe answer is composite key.If the primarykey is combination of on.pdf
The answer is composite key.If the primarykey is combination of on.pdfanukoolelectronics
ย 
Temparatre.javaimport java.util.Scanner; public class Temparat.pdf
Temparatre.javaimport java.util.Scanner; public class Temparat.pdfTemparatre.javaimport java.util.Scanner; public class Temparat.pdf
Temparatre.javaimport java.util.Scanner; public class Temparat.pdfanukoolelectronics
ย 
Since They are not Divisible by any other number and are divisible 1.pdf
Since They are not Divisible by any other number and are divisible 1.pdfSince They are not Divisible by any other number and are divisible 1.pdf
Since They are not Divisible by any other number and are divisible 1.pdfanukoolelectronics
ย 
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdf
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdfSecurity issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdf
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdfanukoolelectronics
ย 
Just looking at a t table SolutionJust looking at a t tab.pdf
Just looking at a t table SolutionJust looking at a t tab.pdfJust looking at a t table SolutionJust looking at a t tab.pdf
Just looking at a t table SolutionJust looking at a t tab.pdfanukoolelectronics
ย 
Because there is the largest number of electrons .pdf
                     Because there is the largest number of electrons .pdf                     Because there is the largest number of electrons .pdf
Because there is the largest number of electrons .pdfanukoolelectronics
ย 
HPLC, is a chromatographic technique used to separate a mixture of c.pdf
HPLC, is a chromatographic technique used to separate a mixture of c.pdfHPLC, is a chromatographic technique used to separate a mixture of c.pdf
HPLC, is a chromatographic technique used to separate a mixture of c.pdfanukoolelectronics
ย 
F2 F is the most electronegative. Thus, among these diatomic speci.pdf
F2 F is the most electronegative. Thus, among these diatomic speci.pdfF2 F is the most electronegative. Thus, among these diatomic speci.pdf
F2 F is the most electronegative. Thus, among these diatomic speci.pdfanukoolelectronics
ย 
evo-devo stands for Evolutionary developmental biology (It compares .pdf
evo-devo stands for Evolutionary developmental biology (It compares .pdfevo-devo stands for Evolutionary developmental biology (It compares .pdf
evo-devo stands for Evolutionary developmental biology (It compares .pdfanukoolelectronics
ย 
e) none of the aboveSolutione) none of the above.pdf
e) none of the aboveSolutione) none of the above.pdfe) none of the aboveSolutione) none of the above.pdf
e) none of the aboveSolutione) none of the above.pdfanukoolelectronics
ย 
An s orbital is spherical in shape.Its electron d.pdf
                     An s orbital is spherical in shape.Its electron d.pdf                     An s orbital is spherical in shape.Its electron d.pdf
An s orbital is spherical in shape.Its electron d.pdfanukoolelectronics
ย 

More from anukoolelectronics (20)

When two atoms are covalently bonded, the more el.pdf
                     When two atoms are covalently bonded, the more el.pdf                     When two atoms are covalently bonded, the more el.pdf
When two atoms are covalently bonded, the more el.pdf
ย 
we can senthysise 4 methylheptanal to propene by .pdf
                     we can senthysise 4 methylheptanal to propene by .pdf                     we can senthysise 4 methylheptanal to propene by .pdf
we can senthysise 4 methylheptanal to propene by .pdf
ย 
The enthalpy change is negative because a bond is.pdf
                     The enthalpy change is negative because a bond is.pdf                     The enthalpy change is negative because a bond is.pdf
The enthalpy change is negative because a bond is.pdf
ย 
moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf
                     moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf                     moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf
moles F- = 0.100 M x 0.0250 L=0.00250 moles H+ ad.pdf
ย 
In Chemistry, a mixture is defined as two or more.pdf
                     In Chemistry, a mixture is defined as two or more.pdf                     In Chemistry, a mixture is defined as two or more.pdf
In Chemistry, a mixture is defined as two or more.pdf
ย 
Suppose distribution an IP datagram since A to F. Suppose over the e.pdf
Suppose distribution an IP datagram since A to F. Suppose over the e.pdfSuppose distribution an IP datagram since A to F. Suppose over the e.pdf
Suppose distribution an IP datagram since A to F. Suppose over the e.pdf
ย 
YesSolutionYes.pdf
YesSolutionYes.pdfYesSolutionYes.pdf
YesSolutionYes.pdf
ย 
The picture is identified as the negative coccus.Gram-negative bac.pdf
The picture is identified as the negative coccus.Gram-negative bac.pdfThe picture is identified as the negative coccus.Gram-negative bac.pdf
The picture is identified as the negative coccus.Gram-negative bac.pdf
ย 
The disclosure requirements for the assignment of specific receivabl.pdf
The disclosure requirements for the assignment of specific receivabl.pdfThe disclosure requirements for the assignment of specific receivabl.pdf
The disclosure requirements for the assignment of specific receivabl.pdf
ย 
The answer is composite key.If the primarykey is combination of on.pdf
The answer is composite key.If the primarykey is combination of on.pdfThe answer is composite key.If the primarykey is combination of on.pdf
The answer is composite key.If the primarykey is combination of on.pdf
ย 
Temparatre.javaimport java.util.Scanner; public class Temparat.pdf
Temparatre.javaimport java.util.Scanner; public class Temparat.pdfTemparatre.javaimport java.util.Scanner; public class Temparat.pdf
Temparatre.javaimport java.util.Scanner; public class Temparat.pdf
ย 
Since They are not Divisible by any other number and are divisible 1.pdf
Since They are not Divisible by any other number and are divisible 1.pdfSince They are not Divisible by any other number and are divisible 1.pdf
Since They are not Divisible by any other number and are divisible 1.pdf
ย 
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdf
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdfSecurity issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdf
Security issues of Neighbor Discovery in IPv6IPv6 nodes use the N.pdf
ย 
Just looking at a t table SolutionJust looking at a t tab.pdf
Just looking at a t table SolutionJust looking at a t tab.pdfJust looking at a t table SolutionJust looking at a t tab.pdf
Just looking at a t table SolutionJust looking at a t tab.pdf
ย 
Because there is the largest number of electrons .pdf
                     Because there is the largest number of electrons .pdf                     Because there is the largest number of electrons .pdf
Because there is the largest number of electrons .pdf
ย 
HPLC, is a chromatographic technique used to separate a mixture of c.pdf
HPLC, is a chromatographic technique used to separate a mixture of c.pdfHPLC, is a chromatographic technique used to separate a mixture of c.pdf
HPLC, is a chromatographic technique used to separate a mixture of c.pdf
ย 
F2 F is the most electronegative. Thus, among these diatomic speci.pdf
F2 F is the most electronegative. Thus, among these diatomic speci.pdfF2 F is the most electronegative. Thus, among these diatomic speci.pdf
F2 F is the most electronegative. Thus, among these diatomic speci.pdf
ย 
evo-devo stands for Evolutionary developmental biology (It compares .pdf
evo-devo stands for Evolutionary developmental biology (It compares .pdfevo-devo stands for Evolutionary developmental biology (It compares .pdf
evo-devo stands for Evolutionary developmental biology (It compares .pdf
ย 
e) none of the aboveSolutione) none of the above.pdf
e) none of the aboveSolutione) none of the above.pdfe) none of the aboveSolutione) none of the above.pdf
e) none of the aboveSolutione) none of the above.pdf
ย 
An s orbital is spherical in shape.Its electron d.pdf
                     An s orbital is spherical in shape.Its electron d.pdf                     An s orbital is spherical in shape.Its electron d.pdf
An s orbital is spherical in shape.Its electron d.pdf
ย 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
ย 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
ย 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
ย 
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X79953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
ย 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
ย 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
ย 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
ย 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
ย 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
ย 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
ย 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
ย 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
ย 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
ย 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
ย 

Recently uploaded (20)

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
ย 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
ย 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
ย 
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
ย 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
ย 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
ย 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
ย 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
ย 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
ย 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
ย 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
ย 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
ย 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
ย 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
ย 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
ย 

ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf

  • 1. ANS: import java.util.Scanner; class Bina_node { Bina_node l_1, r_1; int dt;//here declare variables public Bina_node()//constructor { l_1 = null; r_1 = null; dt = 0; } public Bina_node(int n)//here parameter constractor { l_1 = null; r_1 = null; dt = n; } public void nin_left(Bina_node n)//copy constractor { l_1 = n; } public void nin_right(Bina_node n) { r_1 = n; } public Bina_node get_lstf() { return l_1; } public Bina_node get_go() {
  • 2. return r_1; } public void set_data(int d) { dt = d; } public int get_data() { return dt; } } class Bina_tree//class banary tree { private Bina_node rf; public Bina_tree() { rf = null; } public boolean isEmpty()//here empty or not { return rf == null; } public void tee_insert(int dt) { rf = tee_insert(rf, dt); } private Bina_node tee_insert(Bina_node node, int dt) { if (node == null) node = new Bina_node(dt); else { if (node.get_go() == null) node.r_1 = tee_insert(node.r_1, dt);
  • 3. else node.l_1 = tee_insert(node.l_1, dt); } return node; } public int cou_Node() { return cou_Node(rf); } private int cou_Node(Bina_node r) { if (r == null) return 0; else { int l = 1; l += cou_Node(r.get_lstf()); l += cou_Node(r.get_go()); return l; } } public boolean bin_serc(int tree_val)//function called { return bin_serc(rf, tree_val); } private boolean bin_serc(Bina_node r, int tree_val) { if (r.get_data() == tree_val) return true; if (r.get_lstf() != null) if (bin_serc(r.get_lstf(), tree_val)) return true; if (r.get_go() != null) if (bin_serc(r.get_go(), tree_val)) return true; return false;
  • 4. } public void in_order() { in_order(rf); } private void in_order(Bina_node r) { if (r != null) { in_order(r.get_lstf()); System.out.print(r.get_data() +" "); in_order(r.get_go()); } } public void pre_order() { pre_order(rf); } private void pre_order(Bina_node r) { if (r != null) { System.out.print(r.get_data() +" "); pre_order(r.get_lstf()); pre_order(r.get_go()); } } public void post_order() { post_order(rf); } private void post_order(Bina_node r) { if (r != null) { post_order(r.get_lstf());
  • 5. post_order(r.get_go()); System.out.print(r.get_data() +" "); } } } public class Bina_Tree//binary tree class { public static void main(String[] args)//here main methode { Scanner sc = new Scanner(System.in);//here scanner Bina_tree bin_c = new Bina_tree(); System.out.println("Binary Tree "); char ch; do { System.out.println(" here Binary Tree Operations "); System.out.println("1 for insert 2 for search 3 for count 4 for check");//here choice numbers int cho = sc.nextInt(); int k; switch (cho) { k++; case 1 :System.out.println("please enter insert ele"); bin_c.tee_insert( sc.nextInt() ); break; case 2 :System.out.println("enter bin_search");//here search option System.out.println("result"+ bin_c.bin_serc( sc.nextInt() ));//result break; case 3 :System.out.println("Nodes"+ bin_c.cou_Node()); break;
  • 6. case 4 :System.out.println("Empty"+ bin_c.isEmpty()); break; default ://here default condition System.out.println("enter 1 TO 4 only");//here enter 1 to 4 break; } System.out.print(" Post_order : "); bin_c.post_order(); System.out.print(" Pre_order : "); bin_c.pre_order(); System.out.print(" In_order : "); bin_c.in_order(); System.out.println("do you want to continue type y or n ..* "); ch = sc.next().charAt(0); //to convert charat } while(ch=='y'||ch=='Y');//TO CHECK THE CONDITON } System.out.println("sum of nodes is %d",k); } Solution ANS: import java.util.Scanner; class Bina_node { Bina_node l_1, r_1; int dt;//here declare variables public Bina_node()//constructor { l_1 = null; r_1 = null; dt = 0;
  • 7. } public Bina_node(int n)//here parameter constractor { l_1 = null; r_1 = null; dt = n; } public void nin_left(Bina_node n)//copy constractor { l_1 = n; } public void nin_right(Bina_node n) { r_1 = n; } public Bina_node get_lstf() { return l_1; } public Bina_node get_go() { return r_1; } public void set_data(int d) { dt = d; } public int get_data() { return dt; } } class Bina_tree//class banary tree {
  • 8. private Bina_node rf; public Bina_tree() { rf = null; } public boolean isEmpty()//here empty or not { return rf == null; } public void tee_insert(int dt) { rf = tee_insert(rf, dt); } private Bina_node tee_insert(Bina_node node, int dt) { if (node == null) node = new Bina_node(dt); else { if (node.get_go() == null) node.r_1 = tee_insert(node.r_1, dt); else node.l_1 = tee_insert(node.l_1, dt); } return node; } public int cou_Node() { return cou_Node(rf); } private int cou_Node(Bina_node r) { if (r == null) return 0; else
  • 9. { int l = 1; l += cou_Node(r.get_lstf()); l += cou_Node(r.get_go()); return l; } } public boolean bin_serc(int tree_val)//function called { return bin_serc(rf, tree_val); } private boolean bin_serc(Bina_node r, int tree_val) { if (r.get_data() == tree_val) return true; if (r.get_lstf() != null) if (bin_serc(r.get_lstf(), tree_val)) return true; if (r.get_go() != null) if (bin_serc(r.get_go(), tree_val)) return true; return false; } public void in_order() { in_order(rf); } private void in_order(Bina_node r) { if (r != null) { in_order(r.get_lstf()); System.out.print(r.get_data() +" "); in_order(r.get_go()); } }
  • 10. public void pre_order() { pre_order(rf); } private void pre_order(Bina_node r) { if (r != null) { System.out.print(r.get_data() +" "); pre_order(r.get_lstf()); pre_order(r.get_go()); } } public void post_order() { post_order(rf); } private void post_order(Bina_node r) { if (r != null) { post_order(r.get_lstf()); post_order(r.get_go()); System.out.print(r.get_data() +" "); } } } public class Bina_Tree//binary tree class { public static void main(String[] args)//here main methode { Scanner sc = new Scanner(System.in);//here scanner Bina_tree bin_c = new Bina_tree(); System.out.println("Binary Tree "); char ch;
  • 11. do { System.out.println(" here Binary Tree Operations "); System.out.println("1 for insert 2 for search 3 for count 4 for check");//here choice numbers int cho = sc.nextInt(); int k; switch (cho) { k++; case 1 :System.out.println("please enter insert ele"); bin_c.tee_insert( sc.nextInt() ); break; case 2 :System.out.println("enter bin_search");//here search option System.out.println("result"+ bin_c.bin_serc( sc.nextInt() ));//result break; case 3 :System.out.println("Nodes"+ bin_c.cou_Node()); break; case 4 :System.out.println("Empty"+ bin_c.isEmpty()); break; default ://here default condition System.out.println("enter 1 TO 4 only");//here enter 1 to 4 break; } System.out.print(" Post_order : "); bin_c.post_order(); System.out.print(" Pre_order : "); bin_c.pre_order(); System.out.print(" In_order : "); bin_c.in_order(); System.out.println("do you want to continue type y or n ..* ");
  • 12. ch = sc.next().charAt(0); //to convert charat } while(ch=='y'||ch=='Y');//TO CHECK THE CONDITON } System.out.println("sum of nodes is %d",k); }