
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

(a) What is the time complexity of the algorithm if you use groups of size 3 instead of 5? Work through each step of the calculations carefully so you can be sure where any differences occur. (b) How about if you use groups of 7? (c) Using your answers to parts (a) and (b), explain why the authors of the original algorithm chose groups of size 5.
(a) Sometimes a process called arbitrage is possible: Start with one currency, put it through the correct series of exchanges and you end up with more of the original currency than you started with. Give an efficient algorithm which takes a table of exchange rates between n currencies as input and detects whether arbitrage is possible. Prove the time and space complexity of your algorithm. (b) Suppose that the bank ensures that no arbitrage is possible. Give an efficient algorithm to compute the best exchange rate you can get for converting between each pair of currencies. Again prove the time and space complexity of your solution.
j = 1 j = 2 j = 3 j = 4 i = 1 true false false true i = 2 - true true false i = 3 - - true false i = 4 - - - true
(a) Devise a brute force algorithm to compute the matrix e from an input array x. (b) Analyse the complexity of your brute force algorithm, giving its complexity in big Oh notation. (c) Write a recurrence formula for e[i, j] and use it to give a dynamic programming algorithm for the same task. (d) Analyse the complexity of your dynamic programming algorithm, giving its complexity in big Oh notation. How does it compare with your brute force algorithm?