
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
During the study of discrete mathematics, I found this course very informative and applicable.The main points in these lecture slides are:Pseudo Code, Sequence of Steps, Mathematical Context, Sequence of Integers, Set of Precise Instructions, Prosperities of Algorithm, Searching Algorithms, Linear Search, Binary Search, Bubble Sort, Insertion Sort
Typology: Slides
1 / 32
This page cannot be seen from the preview
Don't miss anything!

























CSE115/ENGR160 Discrete Mathematics 03/03/
procedure linear search ( x:integer, a 1 , a 2 , …, a (^) n : distinct integers) i := 1 while (i≤ n and x≠ai ) i:=i+ if i < n then location := n else location:= { location is the index of the term equal to x, or is 0 if x is not found} (^) Docsity.com 8
1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22
12 13 15 16 18 19 20 22 18 19 20 22 19 (down to one term)
procedure binary search ( x:integer, a 1 , a 2 , …, a (^) n : increasing integers) i :=1 (left endpoint of search interval) j := 1 (right end point of search interval) while ( i < j ) begin m:=⌞(i+j)/2⌟ if x>a (^) m then i:=m+ else j:=m end if x=a (^) i then location := i else location:= { location is the index of the term equal to x, or is 0 if x is not found}
procedure bubble sort ( a 1 , a 2 , …, a (^) n : real numbers with n≥2)
for i:=1 to n-
for j:=1 to n-i if a (^) j >a (^) j+1 then interchange a (^) j and a (^) j+ { a 1 , a 2 , …, a (^) n is in increasing order }
procedure insertion sort ( a 1 , a 2 , …, an : real numbers with n≥2) i :=1 (left endpoint of search interval) j := 1 (right end point of search interval) for j:=2 to n begin i:= while a (^) j >a (^) i i:=i+ m:=aj for k:=0 to j-i- aj-k:= a (^) j-k- a (^) i := m end {a 1 , a 2 , …, a (^) n are sorted}
procedure change ( c 1 , c 2 , …, cn : values of denominations of coins, where c 1 > c 2 >…> c (^) n ; n: positive integer)
for i:=1 to r
while n≥c (^) i then add a coin with value c (^) i to the change n:=n- c (^) i end