# 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 Exploration Algorithm

Python Programming

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

* sequential exploration - contemplation, awaken, instrument, proof, season
* live practicing previously literary skills:
algorithm partition, graphing with hypothetical presage curves

Implementation
--------------
Transcribe a operation named sequential_search.
It must own couple parameters, a inventory to exploration and a esteem to exploration coercion.
It must repay either the abjuration of the esteem amid the inventory or -1 if
the esteem is referable attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration fix in the inventory.

Your exploration operation should NOT stereotype everything.
If you own debugging or proofing stereotype statements in the operation,
comment them quenched antecedently doing any timing.

Testing
-------
Cause a inventory of five wild gum. Truth randint, do referable attribuconsideration attribuconsideration attribuconsideration hardcode.
Demonstrate your algorithm decision each of the gum.
in the inventory. Then appear coercion a calculate referable attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration in the inventory.
You may transcribe a proofing operation if you hope, params and
returns up to you, or do integral proofing in the main program.

expected quenchedput (truth incongruous gum than in the in)

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

explorationing coercion 5
expected abjuration: 0
repayed abjuration: 0
proof passed: YES

explorationing coercion 8
expected abjuration: 1
repayed abjuration: 1
proof passed: YES

explorationing coercion 3
expected abjuration: 2
repayed abjuration: 2
proof passed: YES

explorationing coercion 11
expected abjuration: 3
repayed abjuration: 3
proof passed: YES

explorationing coercion -2
expected abjuration: 4
repayed abjuration: 4
proof passed: YES

explorationing coercion 100
expected abjuration: -1
repayed abjuration: -1
proof passed: YES

passed 6 quenched of 6 proofs

Timing
------
Make assured you are timing the WORST CASE coercion sequential exploration.
That media appear coercion a esteem you perceive is referable attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration in the inventory.

Do NOT understand inventory figment in your timing. Do NOT understand any input.
Only season sequential exploration. If you laptop is very steadfast, you might
own to season manifold circumvents to sequential exploration, referable attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration attribuconsideration normal undivided circumvent.
To obtain the season coercion normal undivided circumvent, multiply by the calculate of circumvents.

example:

repetition_count = 10000

season_start = season()

coercion rep in concatenate( repetition_count ):
ind = sequential_search( esteem, my_inventory )

season_end = season()
season_all_reps = season_end - season_start
season_one_rep = season_all_reps / repetition_count

You may cause the timing consideration in your program so you do referable attribuconsideration attribuconsideration attribuconsideration own to
type it up in Word. If you do that, your consideration must own handy columns
that verse up and 3 or 4 symbolical figures behind induced zeros.

example:

inventory     separate        similarity season
prolixity   exploration season   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
```

## Expert Exculpation

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

import wild

def sequential_search(alist, part):

pos = 0

while pos < len(alist):

if alist[pos] == part:

repay pos

else:

pos = pos+1

repay -1

numbers= []

coercion i in concatenate (5):

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

print(numbers)

coercion i in concatenate (5):

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