This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: German University in Cairo Faculty of Media Engineering and Technology Prof. Dr. Slim Abdennadher Introduction to Computer Science , Winter Term 2009-2010 Practice Assignment 5 Discussion: 14.11.2009 - 19.11.2009 Exercise 5-1 Given the following three algorithms for nding the larger number among three num- bers. • Algorithm 1: get a get b get c if ((a >= b) and (a > = c) ) then print endif if ((b >= a) and (b > = c) ) then print b endif if ((c >= b) and (c > =a) ) then print c endif • Algorithm 2: get a get b get c if (a >= b) then if (a >= c) then print a else print c endif else if (b > = c) then print b else print c endif endif • Algorithm 3: get a get b get c set max to a if (b > max) then set max to b 1 endif if (c > max) then set max to c endif print max a) Compare the e ciency of the three algorithms. Please justify your answer. Hint: Take the basic unit of work to be the comparison of the numbers....
View Full Document
This note was uploaded on 12/22/2009 for the course CSEN 102 taught by Professor Slim during the Spring '09 term at German University in Cairo.
- Spring '09