Java Engineering Programs Blog

next fit program in java

next fit program in java

import java.io.*; class NFit { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int nh,np; System.out.println(“Enter the number of Holes:”); nh=Integer.parseInt(br.readLine()); System.out.println(“Enter the number of Processes:”); np=Integer.parseInt(br.readLine()); int P[]=new int[np];...

dining philosophers problem in java

Dining Philosophers Problem: Consider five philosophers who spend time in thinking and eating.the philosophers share a common circular table surrounded by five chairs,each belonging to one philosopher.In the center of the table is a...

bankers algorithm program in java

bankers algorithm program in java

import java.util.*; class Bankers { int claim[][],alloc[][],av[],need[],p,r,alsum[],sum,temp[][]; int a=0,b=0,c; boolean flag; Scanner src = new Scanner(System.in); Bankers(int p,int r) { this.p=p; this.r=r; claim=new int[p][r]; alloc=new int[p][r]; av=new int [r]; need=new int [r]; alsum=new int[r];...

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