Write pseudocode for the linear search algorithm, and then explain it’s complexity using big-O notation

Pseudocode: FUNCTION linearSearch(list, searchTerm):               FOR index FROM 0 -> length(list):                               IF list[index] == searchTerm THEN                                               RETURN index                               ENDIF               ENDLOOP               RETURN -1 ENDFUNCTION Complexity: Recognize that the single for loop will access each element in the list once in WCS.If each element is accessed once, then as list grows the time taken (WCS) grows in linear timeTherefore : O(n)What about best case? Average case?Encourage comparison with other known/unknown algorithms

JN
Answered by Jacob N. Computing tutor

27479 Views

See similar Computing A Level tutors

Related Computing A Level answers

All answers ▸

Express the number 208 as a) an 8-bit binary number b) an octal string c) a hexadecimal string


A common construct found in many algorithms is a loop. Using pseudocode, write a pre-condition loop to output all of the even numbers between 99 and 201.


why is the Harvard architecture is sometimes used in preference to the von Neumann architecture and give examples of each system


In Python, write a recursive function that returns the first n Fibonacci numbers.


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences