Correction of c++ SJF simulation code

I am creating an SJF code ( no preemtion). It is functioning correctly (as far as i can tell) but always some processes(1-4 out of 10) are not sorted correctly. Assume there are 10 processes

I attached my code with comments. Also here is my logic behind it.

Burst times and arrival times are generated and are known before the algoithm begins

1) I sort all processes and find the one that is going to be executed first ( if two have same arrival time its the one with the lower burst time)

2)After this there are three variables. Completed ( how many processes are done), Totaltime( time that has passed) and counter ( how many processes have arrived after 1 was completed

3) i begin a repetition for i=1 until 10 ( the rest 9 processes). Totaltime has been initialized as burst[0]+arrival[0]. each time count how many processes have arrived. Also perform a completed++ at the very end of the repetition (after the next steps that is)

4) the tricky part : perform bubblesort for 1=completed until counter-1 and for j=i until counter ( the problem almost certainly is here)

5)The next process has been found , so its burst time is added to totaltime, counter is set to 0 and some other calculations which you have to check

turnaroundtime ( time that passed from the arrival of a process until its completation) and waittime ( time passed from arrival until it was started)

P.S 1)If you think my logic is totally flawed you are free to make your own version but all the variables mentioned have to be there

Skills: Algorithm, C++ Programming

See more: sjf, sjf code, sort algorithm, set algorithm, problem algorithm, my code, make algorithm, logic algorithm, how to make an algorithm, how to make algorithm, how to find that i am for programming, free programming code, creating algorithm, cplusplus set, counter programming, algorithm sort, algorithm set, algorithm problem, algorithm of programming, algoithm

About the Employer:
( 4 reviews ) athens, Greece

Project ID: #5021933

Awarded to:


Γεια σου. Το λάθος σου είναι στην ταξινόμηση των διεργασιών που έχουν φτάσει, με βάση το burst time. Συγκεκριμένα, γράφεις: //for the arrived processes arrange them with smaller burst time first for (int i1 = compl More

€8 EUR in 0 days
(0 Reviews)

7 freelancers are bidding on average €51 for this job


Hi Sir, I am ready to work for you.I have 8 years of experience in C/C++/java and Iphone/android. please see some of my works also check my reviews you will get better idea about my skill.I deliver quality work within More

€52 EUR in 3 days
(58 Reviews)

Hi, I am C++ expert and can help you with this project, Please let me know if you are interested. Thank You

€30 EUR in 1 day
(119 Reviews)

I am very proficient in c, c++. I have 15 years c++ developing experience now, and I have worked for 5 years. My work is online game developing, and mainly focus on server side, the lauguage is c++ under linux os. So, More

€28 EUR in 2 days
(20 Reviews)

Hi. i can help you to fix your program. please give me a chance to work on your file and prove my ability. thank you.

€29 EUR in 1 day
(7 Reviews)

Hi, I have done Assignment of SJF (Shortest Job First) algorithm and have Coded This in C++ and php as well. 1:if You want i can fix Your Code because I have done lots of Projects in C++ 2:I can Code this as a new More

€8 EUR in 0 days
(0 Reviews)

Can help... I am an Expert... Please check the past projects I have handled and check my reviews for what employers have to say about my work... Can start right now...

€200 EUR in 7 days
(0 Reviews)

I have made the changes , Hope below one will solve your purpose. for (i = completed; i < nPages; i++) { //find how many processes have smaller arrival time than the current time for (j = completed; More

€9 EUR in 3 days
(0 Reviews)