subject
Engineering, 25.10.2019 20:43 alexanderavrett

Use only c language to do this assignmentin this assignment, you have to simulate the josephus problem. there are n number of prisonersstanding in a circle waiting to be executed. the counting out begins at some point in the circle andproceeds around the circle in a fixed direction. in each step, a certain number of people are skippedand the next person is executed. the elimination proceeds around the circle (which is becomingsmaller and smaller as the executed people are removed), until only the last person remains, whois given freedom. given the total number of persons n and a number k which indicatesthat k-1 persons are skippedand kth person is killed in circle. the task is to choose the place in the initial circle so that you arethe last one remaining and so survive. examplefor example, if n = 5 and k = 2, then the safe position is 3. firstly, the person at position 2 is killed, then person at position 4 is killed, then person at position 1 is killed. finally, the person at position5 is killed. so, the person at position 3 survives. if n = 7 and k = 3, then the safe position is 4. the personsat positions 3, 6, 2, 7, 5, 1 are killed inorder, and person at position 4 survives. input: n and koutput: the position number whowill survive.

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Asingle-geared blanking press has a stroke of 200 mm and a rated capacity of 320 kn. a cam driven ram is assumed to be capable of delivering the full press load at constant force during the last 15 percent of a constant-velocity stroke. the camshaft has an average speed of 90 rev/min and is geared to the flywheel shaft at a 6: 1 ratio. the total work done is to include an allowance of 16 percent for friction a) estimate the maximum energy fluctuation b) find the rim weight for an effective diameter of 1.2 m and a coefficient of speed fluctuation of 0.10
Answers: 1
question
Engineering, 04.07.2019 18:20
Athin walled concentric tube exchanger is used to cool engine oil from 160°c to 60°c with water that is available at 25°c acting as a coolant. the oil and water flow rates are each at 2 kg/s, and the diameter of the inner tube is 0.5 m and the corresponding value of the overall heat transfer coefficient is 250 w/m2. oc. how long must the heat exchanger be to accomplish the desired cooling? cpwater=4.187 kj/kg-candcpengine el=2.035 kj/kg·°c, oil . 120]
Answers: 1
question
Engineering, 04.07.2019 18:20
For a gate width of 2 m into the paper, determine the force required to hold the gate abc at its location.
Answers: 1
question
Engineering, 04.07.2019 18:20
Aheavily insulated piston-cylinder device contains 0.02 m3 of steam at 300 kpa and 200 °c. 1.2 mpa. d this process. team is now compressed in a reversible manner to a pressure of etermine the entropy change and the work done on the steam during this process
Answers: 1
You know the right answer?
Use only c language to do this assignmentin this assignment, you have to simulate the josephus probl...
Questions
question
Mathematics, 08.12.2020 03:40
question
Mathematics, 08.12.2020 03:40
question
Mathematics, 08.12.2020 03:40
question
Mathematics, 08.12.2020 03:40
Questions on the website: 13722359