CSC148H5 Lecture Notes - Lecture 9: Insertion Sort, Bubble Sort, Selection Sort

109 views6 pages
24 Jan 2017
School
Course

Document Summary

We"re interested in the e ciency for large problems. Two words are anagrams if the letters of one word can be rearranged to be the letters of the other word. horse and shore are anagrams. Are these? bill, lib deposit, topside march, charm sport, torts tra c, tra c. Given a word, suppose that we want to generate all anagrams of that word. An anagram of word w is a rearrangement of the letters of w that appear in the wordlist. For example, seohr is not an anagram of horse, because seohr isn"t in the wordlist. We could start with our word and nd all of its permutations. Six permutations: dog, dgo, odg, ogd, gdo, god. In general, if you agave a word of length n, there are n! permutations. Generate all n! (factorial) permutations and then check them all. Let"s say that our word is of length n, and that there are w words in the wordlist.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents