6. Linear Search
Feel free to use your laptop if you have it
Ensure I have recorded your completion — failure to do so will result in a grade of 0
I strongly encourage you to work with others in the lab
When you get stuck, do me a favour and ask those sitting around you for help
I want people to get used to working together in the labs
Peer teaching and peer learning is super effective
Note
To obtain full marks for the lab, you must:
Have completed the pre-lab exercises
Have been working on the lab content
Demonstrate competency in the topics
6.1. Pre Lab Exercises
Warning
You must have completed the specified exercises prior to the start of the lab. If you have not come to lab prepared, you will be asked to leave and you will obtain a grade of 0 for the lab.
-
3
4
9
10
11
12
13
6.2. Before Kattis
Write a function
character_is_in_while(needle: str, haystack:str) -> bool:
The function will
return
True
ifneedle
exists withinhaystack
andFalse
otherwiseThis function must use a
while
loop
Write a function
character_is_in_for(needle: str, haystack:str) -> bool:
The function will
return
True
ifneedle
exists withinhaystack
andFalse
otherwiseThis function must use a
for
loop
Write a function
character_is_at_while(needle: str, haystack:str) -> int:
The function will
return
the index of the first occurrence ofneedle
withinhaystack
and-1
if it is not foundThis function must use a
while
loop
Write a function
character_is_at_for(needle: str, haystack:str) -> int:
The function will
return
the index of the first occurrence ofneedle
withinhaystack
and-1
if it is not foundThis function must use a
for
loop
6.3. Kattis Problems
You should be using a scrap piece of paper to work out the ideas for the following problems
The problems you are to solve are getting too complex to try to solve by just coding
Trying to solve problems by just typing away will not yield success
Note
If you find yourself having a particularly difficult time on any of the problems, just move on to the next one.
Warning
Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.