Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cs301
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
Please provide the sample solution for Assignment 1 CS301, its the last day today.

The Josephus problem is the following mass suicide "game": n people, numbered 1 to n, are sitting in a circle. Starting at person 1, a handgun is passed. After m passes, the person holding the gun commits suicide, the body is removed, the circle closes ranks, and the game continues with the person who was sitting after the corpse picking up the gun. The last survivor is tried for n - 1 counts of manslaughter. Thus, if m = 0 and n = 5, players are killed in order and player 5 stands trial. If m = 1 and n = 5, the order of death is 2, 4, 1, 5.

Write a C++ program to solve the Josephus problem for general values of m and n using circular linked list data structure.

Input:
 Number of People: n
 Number of Passes: m
Output:
 Order in which people are removed
 The survivor

Sample Run:
Enter total number of People playing the game: 10
Enter number of Passes: 3
----------------------------------------------------
Game Started!
----------------------------------------------------
 Person removed: 4
 Person removed: 8
 Person removed: 2
 Person removed: 7
 Person removed: 3
 Person removed: 10
 Person removed: 9
 Person removed: 1
 Person removed: 6
----------------------------------------------------
 The survivor is : 5

Only few hours are left, please send it urgently.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cs301 Misbah Ali 1 1,744 11-15-2011, 10:24 PM
Last Post: Xpert
  CS301 Assignment no 1 moon13 10 4,595 11-03-2011, 04:58 PM
Last Post: Vuhelper
  solution required for cs301 arshid 0 1,986 10-26-2011, 03:13 AM
Last Post: arshid
  assignment#2 cs301 memoona safdar 1 2,014 04-26-2011, 07:50 PM
Last Post: memoona safdar
  CS301 assignment 2 need it C++ using stacks cometamayor 1 2,421 03-01-2011, 11:01 PM
Last Post: Xpert
  Cs301 assinmnt needed...... ANI 3 1,319 05-17-2010, 09:50 PM
Last Post: viki

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support