Let \(n=|keys|\). The sequential search (using a dictionary data structure) requires:

\(n+1=\mathcal O(n)\) (worst case) and

\(\frac{n+1}2=\mathcal O(n)\) (average case)

comparison operations.

Algorithm: Sequential Search

def seqSearch(searchitem, dictionary): found = False # help variable found for k, v in dictionary.items(): if v == searchitem: found = True break

  if found:
      return k
  else:
      return False

Usage

dictionary = {1: "Zara", 2: "Tess", 3: "Bott", 4: "Dial"} print(seqSearch("Bott", dictionary)) 1. will output 1. will output


Thank you to the contributors under CC BY-SA 4.0!

Github:
bookofproofs