Create an application that uses a circular linked list

Assignment Help Basic Computer Science
Reference no: EM131243268

The Josephus Problem is a famous mathematical puzzle that goes back to ancient times. There are many stories to go with the puzzle. One is that Josephus was one of a group of Jews who were about to be captured by the Romans. Rather than be enslaved, they chose to commit suicide. They arranged themselves in a circle and, starting at a certain person, started counting off around the circle. Every nth person had to leave the circle and commit suicide. Josephus decided he didn't want to die, so he arranged the rules so he would be the last person left. If there were (say) 20 people, and he was the seventh person from the start of the circle, what number should he tell them to use for counting off? The problem is made much more complicated because the circle shrinks as the counting continues. Create an application that uses a circular linked list (like that in Programming Project 5.3) to model this problem. Inputs are the number of people in the circle, the number used for counting off, and the number of the person where counting starts (usually 1). The output is the list of persons being eliminated. When a person drops out of the circle, counting starts again from the person who was on his left (assuming you go around clockwise). Here's an example. There are seven people numbered 1 through 7, and you start at 1 and count off by threes. People will be eliminated in the order 4, 1, 6, 5, 7, 3. Number 2 will be left.

Project 5.3

A circular list is a linked list in which the last link points back to the first link. There are many ways to design a circular list. Sometimes there is a pointer to the "start" of the list. However, this makes the list less like a real circle and more like an ordinary list that has its end attached to its beginning. Make a class for a singly linked circular list that has no end and no beginning. The only access to the list is a single reference, current, that can point to any link on the list. This reference can move around the list as needed. (See Programming Project 5.5 for a situation in which such a circular list is ideally suited.) Your list should handle insertion, searching, and deletion. You may find it convenient if these operations take place one link downstream of the link pointed to by current. (Because the upstream link is singly linked, you can't get at it without going all the way around the circle.) You should also be able to display the list (although you'll need to break the circle at some arbitrary point to print it on the screen). A step() method that moves current along to the next link might come in handy too.

Reference no: EM131243268

Questions Cloud

Write down the payoff table and draw the payoff diagram : Write down the payoff table and draw the payoff diagram of a portfolio consisting of 1 call option with a strike price K of $60 and 1 put option with a strike price K of $80.
Compare these speeds with those of the sorts : Modify the shellSort.java (Listing 7.1) and the quickSort3.java (Listing 7.5) programs to sort appropriately large arrays, and compare their speeds. Also, compare these speeds with those of the sorts in Chapter 3.
Recommend an approach for resolving the conflict : Consider a conflict that you or someone that you know is currently experiencing at work. Using the conflict process and ethical consideration discussed in the text, recommend an approach for resolving the conflict.
Elasticity of demand for the grapefruit : Rolf's Supermarkets now sell 12,000 lbs. of grapefruit per week at a price of $0.45 per pound. An economist has reported to management that the arc elasticity of demand for the grapefruit over the price range $0.45 to $0.35 per pound is -2.0.
Create an application that uses a circular linked list : You should also be able to display the list (although you'll need to break the circle at some arbitrary point to print it on the screen). A step() method that moves current along to the next link might come in handy too.
What level of q maximizes net benefits : a. What level of Q maximizes net benefits (profits)? b. What is the maximum level of net benefits (profits)?
Evaluate the communication skills that the staff will need : GBE803 Enterprise Information Communications Assignment. Identify and critically evaluate the communication skills that the staff will need to utilise in order to overcome these barriers. Identify three technological communication tools that could ..
Find the equilibrium price and quantity : where P is the price (in dollars) per burrito and Qd  and Qs are quantities (in millions) demanded and supplied respectively.  Find the equilibrium price and quantity that will prevail in the market.  At a price of $5, would there be a surplus or ..
Explore how would you describe your communication style : What is one of the greatest leadership challenges you have ever faced? What did you do? What was the result? How would you describe your communication style?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  The class is analysis and design of information systems

Guidelines: Grading will include content supported with examples, research and references with in-text citations, grammar and spelling. A minimum of 250 words is required.

  Describe the temporal characteristics of a controlled object

Compare the error-detection latency in systems with and without jitter.

  Would that be a live acquisition, or a postmortem one

Consider a local area network, attached to the Internet, with email capabilities provided to LAN users. What are some of the capabilities already built in to these systems that might aid the investigator? How might you put those to use? Would that be..

  Graphical interface coding and give example

What name Do we give to a Software Used to Develop but offers a functionality for immediate view of a Graphical Interface Coding and give example?

  Resources for developing applications for ebxm

Provide a well reasoned and support paper to accomplish the above requirements.

  Use mcnaughton''s wrap around rule

Use McNaughton's wrap around rule to construct a preemptive

  How easily can your password be hacked

Mystery word Security: How Easily Can Your Password Be Hacked? Questions like as:- What makes a puzzle key powerless or solid? If you need to make a puzzle key that nobody will figure, by what means might you pick one? If you need to figure somebody'..

  Find out the average cpi for the two executables compiled

Consider a program compiled using compilers A and B running on the same processor. Find out the average CPI for the two executables compiled by compilers A and B given that the processor has a clock cycle time of 1ns.

  Design, simulate and verify a 16-bit ripple-carry

Design, simulate and verify a 16-bit ripple-carry adder by performing the following additions/subtractions (the values of a and b are given in decimal): (i) (-10) + (100), (ii) (63) - (-127), (iii) (15) + (95), (iv) (-32) + (79), (v) (-59) + (-16)..

  Write a method, insertat, that takes four parameters

write a method, insertAt, that takes four parameters:an array of integers; the length of the array; an integer, say insertItem; and an interger, say, index.

  Amount of fencing mabel needs to purchase

If the pool is located at the coordinates (1, 5), (5, 8), (4, 1), and (8, 4), what is the amount of fencing Mabel needs to purchase? Round your answer to the nearest tenth. (Like 5.7 0r 3.4)

  Fork function

Create a C program that takes an integer argument from the command line and outputs sum of all digits of the integer. For example, the result of the invocation sum of digits 12345 should be fifteen.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd