Home
GitHub
Solve Program
Tutorials and Solve Programming Problems
≡
Home
Java
PHP
Home
»
algorithm
»
binary-tree
»
data-structure
»
java
»
How to Find Minimum Leaf or Node Value from Tree - Java
How to Find Minimum Leaf or Node Value from Tree - Java
By Solve Program
How to Find Minimum Leaf or Node Value from Tree - Java
Java Programming
Node Class
public class Node { public int id; public String data; public Node leftChild; public Node rightChild; Node(int id) { this.id = id; leftChild = null; rightChild = null; } public void displayNode() { System.out.print("( " + id + ", " + data + " )"); } }
Find minimum leaf method in binary tree
public Node findMinimum(Node node) { if (node.leftChild != null) { return findMinimum(node.leftChild); } return node; }
Case for show minimum leaf value from the tree
int choice = getChar(); switch (choice) { case 'n': Node minNode = theTree.findMinimum(theTree.root); System.out.println("Minimum node value is " + minNode.id); break; }
Related Solving and Tutorial:
How to Find Maximum Leaf or Node Value from Tree - Java
Binary Tree Algorithm - Java
Find The Power Of Number - Java
Find Factorial - Java
Stack - Java
Queue - Java
Newer Post
Older Post
Home
Programming Language
Java
PHP
Data Structure
All Data Structure
Array
Sort
Stack
Queue