Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is an anagram generator in the notes for Lecture 2. Write a dierent anagram generator that makes only one recursive call instead of n

image text in transcribedThis is an anagram generator in the notes for Lecture 2. Write a dierent anagram generator that makes only one recursive call instead of n recursive calls as is done by the program in the notes. Set up an experiment to compare the running times of the two programs. Produce a table showing your results. Carry out the calculations until you see a dierence in the results or until you have exhausted the resources necessary to run the anagram generator. Describe your results, and project the future behavior of these two algorithms.

def anagram(st): if st-": return ['] lout = [ ] for i in range(len(st): ['act', 'atc, 'cat', 'cta', 'tac, 'tca] 6 st2 = st[:i]+st[i+1 :] lout2 = anagram(st2) for w in lout2: lout.append(st[i]+w) return lout ana = anagram('cat') ana.sort) print ana, len(ana)

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

15. Someone who likes to cook

Answered: 1 week ago