ta7_8_question

# ta7_8_question - COMP 271H Design and Analysis of...

• Notes
• 1

This preview shows page 1. Sign up to view the full content.

COMP 271H Design and Analysis of Algorithms 2006 Fall Semester Tutorial 8 1. Consider the problem of examining a string x = x 1 x 2 . . . x n of characters from an alphabet on k symbols, and a multiplication table over this alphabet, and deciding whether or not it is possible to parenthesize x in such a way that the value of the resulting expression is σ , where σ belongs to the alphabet. The multiplication table is neither commutative nor associative, so the order of multiplication matters. For example, consider the following multiplication table the string bbbba . Parenthesizing it ( b ( bb ))( ba ) gives a , but (((( bb ) b ) b ) a ) gives c . a b c a a c c b a a b c c c c Give an algorithm, with running time polynomial in n and k , to decide whether such a parenthe- sization exists for a given string, multiplication table, and goal element. Analyze the running time of your algorithm. 2. Consider a country whose coins are minted with denominations of
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { d 1 , d 2 , . . . , d k } units. They seek an algorithm that will enable them to make change of n units using the minimum number of coins. You may assume that d 1 = 1, so it is always possible to make change for any n . (a) The greedy algorithm for making change repeatedly uses the biggest coin smaller than the amount to be changed until it is zero. Show that the greedy algorithm does not always give the minimum number of coins in a country whose denominations are { 1 , 6 , 10 } . (b) Give an O ( nk ) time algorithm that correctly determines the minimum number of coins needed to make change of n units using denominations { d 1 , d 2 , . . . , d k } . Justify the correctness and running time of your algorithm. c ± 2006 Chung Kai Lun Peter. Comments are welcomed. Email: [email protected] 1...
View Full Document

• Spring '10
• may
• English, multiplication table, Chung Kai Lun Peter

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern