Category: Analysis of Algorithms

Analysis of algorithm and design programs such as searching, sorting ,knapsack

n queens problem using backtracking program in java

n queens problem using backtracking 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] -...

insertion sort in java

insertion sort in java

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

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

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