{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Practice5_3046

# Practice5_3046 - German University in Cairo Faculty of...

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
This is the end of the preview. Sign up to access the rest of the 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

{[ 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