Java Engineering Programs Blog

optimal binary search tree program in java

optimal binary search tree program in java

import java.io.*; import java.util.*; class Optimal { public int p[]; // Probabilities with which we search for an element public int q[]; // Probabilities that an element is not found public int a[]; //...

prim’s algorithm program in java

prim’s algorithm program in java

import java.io.*; class prim { public static void main(String args[])throws IOException { int size=20; int nodes,v1,v2,length,i,j,n; int g[][]=new int[size][size]; DataInputStream in=new DataInputStream(System.in); System.out.println(“Enter number of nodes in graph”); nodes=Integer.parseInt(in.readLine()); System.out.println(“Enter number of edges in...

graph coloring algorithm program in java

graph coloring algorithm program in java

import java.util.*; class Graph_Coloring { private int adj[][],x[],m,n; public GraphColoring() { Scanner src = new Scanner(System.in); System.out.println(“Enter the number of nodes”); n=src.nextInt(); x=new int[n]; for (int i=0;i<n; i++) x[i]=0; adj=new int[n][n]; System.out.println(“Enter the adjacency...

program for prime number in java

program for prime number in java

Learn Java Programming for Beginners Prime number is number which is divisible by 1 and itself.for example Number 7 is prime number because it is divisible by 1 and 7 only.whereas 8 is divisible by 1,2,4,8...