Practice4_2881

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

This preview shows pages 1–2. Sign up to view the full content.

German University in Cairo Faculty of Media Engineering and Technology Prof. Dr. Slim Abdennadher Introduction to Computer Science , Winter Term 2009-2010 Practice Assignment 4 Discussion: 31.10.2009 - 5.11.2009 Exercise 4-1 The simplest algorithm to search a list of Numbers N1,. ..,Nm for a given key Key is to test successively each element. get m get N1,. .,Nm get Key set i to 1 set FOUND to NO while (i<=m and FOUND = NO) { if (Key = Ni) then set FOUND to YES else set i to i+1 endif } if (FOUND = NO) then print ``sorry, key is not in the list'' else print ``key found'' endif If a list is already stored in increasing order, a modi ed sequential search algorithm can be used that compares aganist each element in turn, stopping if a list element exceeds the target value. Write a pseudocode for the modi ed sequential serach. Exercise 4-2 Write an algorithm to nd the maximum value stored in an (unsorted) list A1, A2, . .., An of n integers. Exercise 4-3

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.

{[ snackBarMessage ]}

### Page1 / 2

Practice4_2881 - German University in Cairo Faculty of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online