Alan J.

asked • 03/25/21

Please can anyone solve the given methods.

(A)

Suppose you have been hired to develop a musical chair game. In this game there will be 7 participants and all of them will be moving clockwise around a set of 7 chairs organized in a circular manner while a music will be played in the background. You will control the music using random numbers between 0-3.If the generated random number is 1, you will stop the music and if the number of participants who are still in the game is n, the participant at position (n/2) will be eliminated. Each time a participant is eliminated, a chair will be removed and you have to print the player names who are still in the game. The game will end when there will be only one participant left. At the end of the game, display the name of the winner. [Hint: You will need to invoke a method to generate a random number between 0 (inclusive) to 3 (inclusive)]


(B)

Given a circular array of integers, do the following operations stepwise :

Value Index

25 0

a + 15 1

52 2

25 3

0 4

0 5

b + 25 6

25 7

5 8

19 9

5 + a 10

5 11

6 + b 12


Where “a” is the last two digits of your BRACU student id and “b” is first two digits of your BRACU student id.

The start of the array is index 6. [Note: if the capacity of the array is full, resize it by its previous capacity + 3].

a. Remove 25 by right-shifting.

b. Insert b%67 at position 5.

c. Insert studentId%13 at position 8.

d. Insert birthyear%61 at position 3.

e. Remove 5 by left-shifting.

f. Remove 52 by left-shifting.

g. Right rotate the array 3 times.

h. Left rotate the array by 4 times.


You have to show the simulation of each operation separately, no coding is required.


NOTE :

Write down only the methods that are required. Testers are not required. Use Java or Python.

1 Expert Answer

By:

Patrick B. answered • 03/25/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.