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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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