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

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

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