Category: Analysis of Algorithms

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...

Binary Search Tree program in java

Binary Search Tree program in java

import java.util.Scanner; class TreeNode { TreeNode left,right; int info; public TreeNode(int data) { info=data; left=null; right=null; } } class Operations { TreeNode ptree,p,q; Operations() {p=q=ptree=null; } public void preorder(TreeNode ptree) { if(ptree!=null) {System.out.print(ptree.info +...

8 queen problem program in java

8 queen problem program in java

import java.io.*; class operation { int x[]=new int[20]; int count=0; public boolean place(int row,int column) { int i; for(i=1;i<=row-1;i++) { //checking for column and diagonal conflicts if(x[i] == column) return false; else if(Math.abs(x[i] –...