listing implementation of the linear search on an unsorted sequence def linearsearchthevaluestarget lenthevalues for in rangen if the target is in the ith elementreturn true if thevalues[ =target return true return false if not foundreturn false to analyze the sequential search algorithm for the worst casewe must first determine what conditions constitute the worst case rememberthe worst case occurs when the algorithm performs the maximum number of steps for sequential searchthat occurs when the target item is not in the sequence and the loop iterates over the entire sequence assuming the sequence contains itemsthe linear search has worst case time of (nsearching sorted sequence linear search can also be performed on sorted sequencewhich is sequence containing values in specific order for examplethe values in the array illustrated in figure are in ascending or increasing numerical order that iseach value in the array is larger than its predecessor searching for start figure the linear search on sorted array linear search on sorted sequence works in the same fashion as that for the unsorted sequencewith one exception it' possible to terminate the search early when the value is not in the sequence instead of always having to perform complete traversal for examplesuppose we want to search for in the array from figure when the fourth itemwhich is value is examinedwe know value cannot be in the sorted sequence or it would come before the implementation of linear search on sorted sequence is shown in listing on the next page the only modification to the earlier version is the inclusion of test to determine if the current item within the sequence is larger than the target value if larger value is encounteredthe loop terminates and false is returned with the modification to the linear search algorithmwe have produced better versionbut the time-complexity remains the same the reason is that the worst case occurs when the value is not in the sequence and is larger than the last element in this casewe must still traverse the entire sequence of items