











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












while condition do activity
procedure name list of primitives associated with name
while ( condition ) do ( loop body )
repeat ( loop body ) until( condition )
Fred
Alex
Diana
Byron
Carol
Want to see if Byron is in the list
procedure Search(List, TargetValue) If (List is empty) Then (Target is not found) Else ( name first entry in List while (no more names on the List) ( if (name = TargetValue) (Stop, Target Found) else name next name in List ) (Target is not found) )
Sorting the list Fred, Alex, Diana, Byron, and Carol alphabetically
Insertion Sort: Moving to the right, insert each name in the proper sorted location to its left Fred Alex Diana Byron Carol
Applying our strategy to search a list for the entry John
Alice Bob Carol David Elaine Fred George Harry Irene John Kelly Larry Mary Nancy Oliver
Applying the insertion sort in a worst-case situation
Graph of the worst-case analysis of the insertion sort algorithm
Graph of the worst-case analysis of the binary search algorithm