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

  Compare and contrast their relative strengths and weaknesses

The system to be developed is intended to be operational in a small market firm or small business firm or even in home usage. Familiar examples might include an income tax preparation package by a small tax consulting firm.

  Examine the challenges associated with searching in textual

Your company has been hired to design a product that will provide searches of textual documents and database querying. Your design team has not developed a product like this before. Examine the challenges associated with searching in textual docum..

  Demonstrate your understanding and knowledge gained

Demonstrate your understanding and knowledge gained about session's material. Complete with a short discussion for each question. The second question will take several paragraphs to answer thoroughly.

  Find a significant increase in mean life

Vigorous exercise helps people live several years longer (on the average). Whether mild activities like slow walking extend life is not clear. Suppose that the added life expectancy from regular slow walking is just 2 months. A statistical test is..

  The software project development

Explain the need of software engineering in the software project development.

  Flexsim model for a stylist shop

Customers arrive according to a uniform distribution of unif(10,20) minutes. A single stylist works on a customer for unif(15,30) minutes. Run the model for an initial 10 replications.

  Discuss measures that can be to proactively reduce risk

Discuss measures that can be taken to proactively reduce risk.

  What are the seven message types in snmp

What are the seven message types in SNMP?

  What is optimal strategy if n is known

Consider the numerical 20 questions game. In this game, player 1 thinks of a number in the range 1 to n. Player 2 What is an optimal strategy if n in known?

  Performance of female entrepreneurs

Read the research study "The performance of female entrepreneurs: Credit, Training and the Moderating Effect of Attitude towards Risk-Taking," which is required reading for this module.

  The economy is self-regulating

The classical school of economic thought believes that the economy is self-regulating and should be left alone to adjust naturally.  Keynesian's, on the other hand, believe that the economy is inherently unstable and must be managed and planned. Whic..

  Describe the necessity of secure architecture

Describe the necessity of secure architecture in information systems

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