Writing a recursive algorithm
Not what you're looking for?
The question of how many ways a committee of 4 people can be selected from a group of 10 is known as a combination. The notation in general for counting the number of ways of selecting r items from a group of n is C(n,r) = n! / r!(n-r)!
Also, given that 0! = 1 by definition, we can show that C(n,0) = 1 = C(n,n)
Also, C(n,r) = C(n-1, r-1) + C(n-1, r)
Given the information above, write a recursive algorithm to find C(n,r) for any two non-negative integers n and r, with r <= n
Purchase this Solution
Solution Summary
This solution shows how to write a recursive algorithm.
Solution Preview
The recursive algorithm is described as below.
int C(int n, int r) {
// First, I check the ...
Purchase this Solution
Free BrainMass Quizzes
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
Basic Networking Questions
This quiz consists of some basic networking questions.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.