Recursive function to print the arrangements

Assignment Help Basic Computer Science
Reference no: EM131035639

Warm-up Assignment You are given R red marbles and B blue marbles. Your task is to arrange the R + B marbles in a line such that certain restrictions are satisfied (see below). You print all possible arrangements under the given restrictions, and the total count of arrangements possible. Part 1 In this part, the restriction is that no two red marbles may be placed consecutively. Write a single recursive function to print the arrangements and return the count of possibilities. Do not use any global or static variables. Place the available marbles one by one in an array of size R + B. When u red and v blue marbles are placed, find out the options (red and/or blue) at the (u + v + 1)-st position. For each available option, recursively compute the acceptable configurations with u + v + 1 marbles placed in the array. Part 2 In this part, two red marbles may appear in consecutive positions, but three or more red marbles are not allowed to come consecutively. Write a second recursive function following the same line of programming logic as in Part 1. Sample output Enter number of red marbles (R) : 2 Enter number of blue marbles (B) : 4 Part 1 rbrbbb rbbrbb rbbbrb rbbbbr brbrbb brbbrb brbbbr bbrbrb bbrbbr bbbrbr Total number of possibilities is 10 Part 2 rrbbbb rbrbbb rbbrbb rbbbrb rbbbbr brrbbb brbrbb brbbrb brbbbr bbrrbb bbrbrb bbrbbr bbbrrb bbbrbr bbbbrr Total number of possibilities is 15

Attachment:- 1549312_2_warmup.zip

Reference no: EM131035639

Questions Cloud

Program round off an integer i to the next largest integer : Write a program round off an integer I to the next largest multiple to another integer example: enter the value of I and j : 32 & 5
Effective in preventing loss and damage to life and property : What would be some of the essential elements in your disaster management and evacuation plan to be effective in preventing loss and damage to life and property?
What are two severe and pervasive types of sexual harassment : What are the two severe and pervasive types of Sexual Harassment? What laws prevent Sexual Harassment in the workplace? Why are Sexual Harassment laws necessary? What should an employer do when an employee complaints of Sexual Harassment? What happen..
Discuss risks and benefits of inventory size and location : Discuss the risks and benefits of inventory size and location. Explain what companies can to minimize their risks associated with inventory.
Recursive function to print the arrangements : Warm-up Assignment You are given R red marbles and B blue marbles. Your task is to arrange the R + B marbles in a line such that certain restrictions are satisfied (see below).
Inventory management for special units at business : You have just taken over inventory management for special units at a business. Currently there are 120 units in stock, it takes between 1 and 3 weeks to receive an order of 100 new units, and demand runs between 0 and 25units per week. What additiona..
What does the income per billing percentage calculated : Question - Based on your work in (2) above: (a) Would you recommend the adoption of ABC? Explain your answer. (b) What does the ‘income per billing' percentage calculated under the ABC approach tell you about these three accounting services
Operating leverage and break-even analysis : OPERATING LEVERAGE AND BREAK-EVEN ANALYSIS Olinde Electronics Inc. produces stereo components that sell at P = $100 per unit. Olinde's fixed costs are $200,000, variable costs are $50 per unit, 5,000 components are produced and sold each year, EBI..
The arraylist class : Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent.  E.g.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explain chain of custody is critical factor for cases

Think of numerous cases where evidence could potentially be tampered with a cell phone or thumb drive. What can go wrong?

  M uses the average and maximum error of the two values. c.

A Atmega128 is being used to monitor humidity inside test chamber 03. The device uses two sensors to have some fault tolerance.

  Calculate population increase

The output then would be that count. You will want to use 2 variables, one for the index of the for loop ( and the counter in the do loop) and the other variable to keep track of your "current" population.

  Explain the differences between cyber crimes and computer

Explain the differences between cyber crimes and computer crime

  Explain why failing the pairwise disjointness test

Explain why failing the pairwise disjointness test is an indication that the grammar will be problematic for top-down parsing by only looking ahead by one token.

  Employees may work from home

Employees may work from home up to 15 hours per week. Each project leader needs a list of current means of contacting each member of the project team: home phone and home FAX number. To contact employees "on the road" the project leaders also need..

  How much ram is installed on your computer?

How much RAM is installed on your computer?

  Implementation for the r-type instructions add, or, and and

figuring out how to add an implementation for the R-type instructions ADD, OR, and AND. This is a MIPS architecture. // Incomplete behavioral model of MIPS pipeline

  Why is it important to educate users about risks

what is a primary security risk that users should acknowledge when using macros? Why is it important to educate users of these risks once their dilemma is resolved?

  Analyze hardware virtualization

Determine if you would prefer a virtualized environment to a non-virtualized environment for a midsized business or organization and explain why or why not. Compare the cloud computing cost models used by Amazon EC2 and Microsoft Azure.

  Determine gradient magnitude and gradient direction of image

Consider the sub-image. Determine gradient magnitude and gradient direction at center entry using following operators.

  Deliverable associated required to complete process

Explain in scholarly detail department expense predicting processes and deliverable associated required to complete process.

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