Java Engineering Programs Blog

knapsack problem program in java

knapsack problem program in java

knapsack problem program in java Program import java.io.*; class knapsack { public static void main(String args[])throws IOException { DataInputStream in=new DataInputStream(System.in); int i,j; double p1=0.0; System.out.println(“Enter NO of Elements”); int n=Integer.parseInt(in.readLine()); System.out.println(“Enter Capacity”); float...

Hamiltonian Cycle program in java

Hamiltonian Cycle program in java

import java.io.*; public class Hamiltonian { static boolean found = false; public static void main(String args[]) throws IOException { DataInputStream in=new DataInputStream(System.in); System.out.println(“\t\t\t\tHamiltonian Cycle”); System.out.print(“\nEnter the number of the vertices: “); int n =...

kruskal algorithm program in java

kruskal algorithm program in java

import java.io.*; class kruskal { 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...

Merge Sort in java

Merge Sort in java

import java.io.*; class MergeSort { public static void main(String args[ ]) { int i,n=0; int increments[]={5,3,1}; int x[]=new int[25]; DataInputStream in = new DataInputStream(System.in); try { System.out.print(“Enter how many numbers to be sorted :...