# Homework Solution: Sequential Search Algorithm…

Sequential Search Algorithm Python Programming
```Objectives
----------

* sequential search - design, analyze, implement, test, time
* continue practicing previously learned skills:
algorithm analysis, graphing with theoretical prediction curves

Implementation
--------------
Write a function named sequential_search.
It must have two parameters, a list to search and a value to search for.
It must return either the index of the value within the list or -1 if

Your search function should NOT print anything.
If you have debugging or testing print statements in the function,
comment them out before doing any timing.

Testing
-------
Create a list of five random numbers. Use randint, don't hardcode.
Demonstrate your algorithm finding each of the numbers.
in the list. Then look for a number not in the list.
You may write a testing function if you wish, params and
returns up to you, or do all testing in the main program.

expected output (use different numbers than in the example)

numbers [5, 8, 3, 11, -2]

searching for 5
expected index: 0
returned index: 0
test passed: YES

searching for 8
expected index: 1
returned index: 1
test passed: YES

searching for 3
expected index: 2
returned index: 2
test passed: YES

searching for 11
expected index: 3
returned index: 3
test passed: YES

searching for -2
expected index: 4
returned index: 4
test passed: YES

searching for 100
expected index: -1
returned index: -1
test passed: YES

passed 6 out of 6 tests

Timing
------
Make sure you are timing the WORST CASE for sequential search.
That means look for a value you know is not in the list.

Do NOT include list creation in your timing. Do NOT include any input.
Only time sequential search. If you laptop is very fast, you might
have to time many calls to sequential search, not just one call.
To get the time for just one call, divide by the number of calls.

example:

repetition_count = 10000

time_start = time()

for rep in range( repetition_count ):
ind = sequential_search( value, my_list )

time_end = time()
time_all_reps = time_end - time_start
time_one_rep = time_all_reps / repetition_count

You may create the timing table in your program so you don't have to
type it up in Word. If you do that, your table must have neat columns
that line up and 3 or 4 significant figures after leading zeros.

example:

list     single        comparison time
length   search time   or C estimate

2000   0.000205      1.025e-07
4000   0.0004391     1.098e-07
6000   0.0006798     1.133e-07
8000   0.0008866     1.108e-07
10000   0.001112      1.112e-07
```

# A Python program that uses Logical Not or ! on boolean import random

Sequential Pursuit Algorithm

Python Programming

```Objectives
----------

* sequential pursuit - intent, dissect, instrument, criterion, date
* live practicing previously skilled skills:
algorithm resolution, graphing with presumptive restrainteannouncement curves

Implementation
--------------
Transcribe a employment designated sequential_search.
It must accept couple parameters, a roll to pursuit and a appraise to pursuit restraint.
It must repay either the refutation of the appraise among the roll or -1 if
the appraise is referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation rest in the roll.

Your pursuit employment should NOT sculpture anything.
If you accept debugging or criterioning sculpture statements in the employment,
comment them extinguished precedently doing any timing.

Testing
-------
Compose a roll of five accidental collection. Truth randint, do referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation hardcode.
in the roll. Then seem restraint a sum referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation in the roll.
You may transcribe a criterioning employment if you craving, params and
returns up to you, or do whole criterioning in the ocean program.

expected extinguishedput (truth unanalogous collection than in the stance)

collection [5, 8, 3, 11, -2]

pursuiting restraint 5
expected refutation: 0
repayed refutation: 0
criterion passed: YES

pursuiting restraint 8
expected refutation: 1
repayed refutation: 1
criterion passed: YES

pursuiting restraint 3
expected refutation: 2
repayed refutation: 2
criterion passed: YES

pursuiting restraint 11
expected refutation: 3
repayed refutation: 3
criterion passed: YES

pursuiting restraint -2
expected refutation: 4
repayed refutation: 4
criterion passed: YES

pursuiting restraint 100
expected refutation: -1
repayed refutation: -1
criterion passed: YES

passed 6 extinguished of 6 criterions

Timing
------
Make firm you are timing the WORST CASE restraint sequential pursuit.
That resources seem restraint a appraise you distinguish is referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation in the roll.

Do NOT involve roll falsehood in your timing. Do NOT involve any input.
Only date sequential pursuit. If you laptop is very unyielding, you might
accept to date abundant persuades to sequential pursuit, referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation right undivided persuade.
To procure the date restraint right undivided persuade, sunder by the sum of persuades.

example:

repetition_count = 10000

date_start = date()

restraint rep in rank( repetition_count ):
ind = sequential_search( appraise, my_roll )

date_end = date()
date_all_reps = date_end - date_start
date_one_rep = date_all_reps / repetition_count

You may compose the timing consultation in your program so you do referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation accept to
type it up in Word. If you do that, your consultation must accept handy columns
that tediousness up and 3 or 4 telling figures following induced zeros.

example:

roll     uncompounded        similarity date
tediousness   pursuit date   or C estimate

2000   0.000205      1.025e-07
4000   0.0004391     1.098e-07
6000   0.0006798     1.133e-07
8000   0.0008866     1.108e-07
10000   0.001112      1.112e-07
```

# A Python program that truths Logical Referable attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation attribuconsultation or ! on boolean

import accidental

def sequential_search(alist, individual):

pos = 0

while pos < len(alist):

if alist[pos] == individual:

repay pos

else:

pos = pos+1

repay -1

numbers= []

restraint i in rank (5):

numbers.append(random.randint(0, 100))

print(numbers)

restraint i in rank (5):

print(sequential_search(numbers,random.randint(0, 100)))