Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you are going to write code that solves problems using recursion. Note the emphasis: you must use recursion! If you're having problems

For this assignment you are going to write code that solves problems using recursion. Note the emphasis: you must use recursion!
If you're having problems starting a question, consider the simplest possible case (ie, a '1' or a single-character string, etc) and using
induction, figure out how to get to the next case.
All questions in this assignment will be answered in the same Python file:
assign2.py. Read the description of each question below, and refer to
the
assign2.py file comments for further clarification.
Pay close attention to the specifications and the submission requirements.
In the
assign2.py file, you will modify the recursive function called permutations (), which is given on slide 17 of Topic 2 class notes (refer to
that slide for further explanation). The current code outputs the permutations as in the first version on slide 18. You must modify the code so
that the output is in a more 'systematic' ordering, as in the second version on slide 18.
Generating Strings 40%
In the
assign2.py file, implement the recursive function called generateReverseorder (), which generates all length-n strings of 0's and 1's,
for a given non-negative integer n, in order from largest to smallest (aka, descending order).
Your function must have n as the only parameter and must return a list containing all length-n strings of 0's and 1's (in the correct order).
Run the code to get an idea of what the expected output should look like.
Note: The test output examples are in descending order, since if you consider them as binary numbers, they start at 2n-1 and decrement each
time.
Analyzing a String 40%
In the
assign2.py file, implement the recursive function called countChars (), which analyzes the given string and returns a 3-element list of
integers representing the number of consonants, vowels, and other characters (respectively) in that string.
Your function must have a string s as the first parameter; you may add other parameters as necessary.
Sample output should be as follows:
s= "abc de" Consonants, Vowels, Other: 3,2,1
s="To be or not to be" Consonants, Vowels, Other: 7,6,5
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago