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

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[]; //...

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