Practice4_2881 - German University in Cairo Faculty of...

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

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

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online