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

Find run time required to sort n values in a linked chain

Find the run time required to sort n values in a linked chain for different values of n. (See the projects at the end of Chapter 4 for a description of how to time a block o

What needs to be done to create database

Assume you have a customer who would like to track inventory including vendor (where the product comes from) and customer (who the product is sold to). What needs to be don

Potential mid-term exam questions

Perfect competition, welfare and entry. A perfectly competitive market consists of 3 firms. Total cost functions for each firm are given by C = 2q + 0.25×(q)2 + 256. Market de

Find a business continuity or disaster recovery

300 words or more in apa format with United States References only Research on the general internet or in the University Library and find a Business Continuity or Disaster R

List the number and name of all customers

In the following exercises, you will use the data in the TAL Distributors database (If you use a computer to complete these exercises, use a copy of the original TAL Distribut

The key advantages and disadvantages of placing

Compare and contrast the key advantages and disadvantages of placing the following system types on a DMZ: Directory services (i.e. Microsoft AD), Web server, FTP server,

Horizon books is a bookstore in downtown madina munawara

Horizon Books is a bookstore in downtown Madina Munawara. It carries an inventory of approximately 50,000 books. Customers come in and browse the shelves, select their books,

Draw an er diagram from this scenario

Whenever the DVD gets returned, that fact, too, gets noted along with the date returned. Alice wants to keep a complete history of her friends' borrowing habits so that she

Reviews

Write a Review

 
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