bully algorithm in java source code
#1

please give me the java code for bully algorithm
Reply
#2
import java.util.*;
class Bully1
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=0;
while(n==0)
{
System.out.println("enter number of processes");
n=sc.nextInt();
if(n==0)
System.out.println("dude, process cannot be 0 ");
}
int pid[]=new int[n];

for(int i=0;i<n;i++)
{
pid[i]=1;
}
/*for(int k:pid)
System.out.println(k);*/
int max=Max.max(pid,0);
int cord=max;
System.out.println(":cord"+(cord));



//crash-=1;
while(true)
{
System.out.println("enter option:\n1.crash a process\n2.revoke\n3.exit");
int choice =sc.nextInt();
switch(choice)
{
case 1:
System.out.println("enter process to be crash");
int crash=sc.nextInt();
try
{
if(pid[crash]==0)
{
System.out.println("process already crashed");
}
else
{
pid[crash]=0;
System.out.println("enter the process who will initiate election");
int start=sc.nextInt();
//revoke-=1;

if(pid[start]==0)
{
System.out.println("process dead");
continue;
}
else
{

System.out.println("nold coordinator :"+cord);

cord=Max.max(pid,start);
System.out.println("new coordinator :"+cord);




}
}
}
catch(ArrayIndexOutOfBoundsException d)
{
System.out.println("does not exist"+d);
}
catch(Exception e)
{
System.out.println(e);
}

break;
case 2:
try
{
System.out.println("enter process u want to revoke");
int revoke=sc.nextInt();
if(pid[revoke]==1)
{
System.out.println("dude,process already alive");
}
else
{
pid[revoke]=1;
if(cord<revoke)
cord=revoke;
System.out.println("new coordinator is "+cord);

}
}
catch(ArrayIndexOutOfBoundsException d)
{
System.out.println("does not exist"+d);
}
catch(Exception e)
{
System.out.println(e);
}
break;
case 3:
return;
default:System.out.println("wrong choice");
break;

}
}

}



}
class Max
{
public static int max(int pid[],int k)
{
int max=0;
for(int i=k;i<pid.length;i++)
{
System.out.println("message received by process"+i);
if(pid[i]==1)
{
max=i;
}
}
return max;
}
}
Reply
#3
To get full information or details of bully algorithm in java source code please have a look on the pages

http://studentbank.in/report-bully-algor...ource-code

if you again feel trouble on bully algorithm in java source code please reply in that page and ask specific fields in bully algorithm in java source code
Reply
#4
To get full information or details of bully algorithm in java source code please have a look on the pages

http://studentbank.in/report-bully-algor...ource-code

if you again feel trouble on bully algorithm in java source code please reply in that page and ask specific fields in bully algorithm in java source code
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Tagged Pages: bully algorithm source code, bully algorithm program in java, http googleweblight com lite url http seminarprojects org t bully algorithm in java source code ei los2cg2l lc en in s 1 m 71, bully election algorithm program in java, bully algorithm implementation in java, bully algorithm in java, to study bully algorithm with java program,
Popular Searches: rreal time application example of bully algorithm, bully algorithm implementation in java source code, ring and bully algorithms java program, bully election algorithm java code, bully gets body, revoke q, bully algorithm in c,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  free download source code of online college magazine 5 18,628 29-06-2018, 10:09 AM
Last Post: Guest
  opengl source code for butterfly 3 3,330 14-05-2018, 08:57 AM
Last Post: Akshatha k
  ice cream parlour management system in vb source code 4 5,353 04-04-2018, 11:58 PM
Last Post: vprk77
  dwt code in java for image 2 6,475 24-03-2018, 10:06 PM
Last Post: Guest
  source code in php for online training and placement cell management 1 6,733 23-03-2018, 09:06 AM
Last Post: ritzi
  free download college website project in html with source code 2 4,697 24-02-2018, 10:46 AM
Last Post: Guest
  source code for hospital management system in jsp 4 1,986 13-01-2018, 10:51 AM
Last Post: dhanabhagya
  source code in c for dna cryptography in computer sc ppt 1 1,569 09-01-2018, 09:59 PM
Last Post: harshavarshinib
  to find whether a number is krishnamurthy number or not using java 1 11,315 01-01-2018, 11:39 AM
Last Post: dhanabhagya
  java programmings for bus ticket reservation source code 1 6,255 09-11-2017, 11:28 PM
Last Post: Ayushi Nagar

Forum Jump: