ta7_8_question - d 1 d 2 d k units They seek an algorithm...

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

View Full Document Right Arrow Icon
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
Image of page 1
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern