6.00.1x Week 5 (Incomplete)
Efficiency How much time it takes for our program to run.
1 2 3 4 5 |
def linearSearch(L, x): for e in L: if e == x: return True return False |
The function iterates elements in list L, if the element is equals to x, it returns true. This function continues to iterate until x is found, or if not found, returns false. There are two extreme cases here, if x happens to be … Continue reading 6.00.1x Week 5 (Incomplete)