CSCI 161
1.0

Course Notes

  • 1. Introduction and Output
  • 2. Print, Values, Variables, Types
  • 3. Statements and Expressions
  • 4. Input and Changing Types
  • 5. Functions
  • 6. Testing Your Code and Type Hints
  • 7. Propositional Logic
  • 8. If/Else
  • 9. Putting Things Together
  • 10. Loops
  • 11. Strings & Objects
  • 12. Lists
  • 13. References
  • 14. Aliases & List Trivia
  • 15. Tuples, Dictionaries, and Sets
  • 16. Debugging
  • 17. File IO
  • 18. Exceptions
  • 19. Objects I — Introduction
  • 20. Objects II — More on Methods
  • 21. Objects III — Interacting Objects
  • 22. Unittest
  • 23. Objects IV — Data Structures
  • 24. Searching and Complexity
  • 25. Sorting Algorithms
  • 26. Models of Computation
  • 27. Recursion and More Sorting

Labs

  • 1. Hello World
  • 2. Functions
  • 3. Conditionals
  • 4. Car Rental
  • 5. Loops
  • 6. Linear Search
    • 6.1. Pre Lab Exercises
    • 6.2. Before Kattis
    • 6.3. Kattis Problems
  • 7. Lists
  • 8. 2D Lists
  • 9. References & More Lists
  • 10. Objects
  • 11. Data Structures
  • 12. Recursion

Assignments

  • 1. Density of Starbucks
  • 2. Oh crap, Zombies!
  • 3. I’m only taking CS to make sick video games
  • 4. Playing with Objects is Fun

Getting Started

  • Getting set up for CSCI 161

Outline

  • Computer Science 161 Sections 11 & 12 — Introduction to Programming
CSCI 161
  • »
  • 6. Linear Search
  • View page source

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:

  1. Have completed the pre-lab exercises

  2. Have been working on the lab content

  3. 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.

  1. Chapter 8 exercise(s)

    • 3

    • 4

    • 9

    • 10

    • 11

    • 12

    • 13

6.2. Before Kattis

  1. Write a function character_is_in_while(needle: str, haystack:str) -> bool:

    • The function will return True if needle exists within haystack and False otherwise

    • This function must use a while loop

  2. Write a function character_is_in_for(needle: str, haystack:str) -> bool:

    • The function will return True if needle exists within haystack and False otherwise

    • This function must use a for loop

  3. Write a function character_is_at_while(needle: str, haystack:str) -> int:

    • The function will return the index of the first occurrence of needle within haystack and -1 if it is not found

    • This function must use a while loop

  4. Write a function character_is_at_for(needle: str, haystack:str) -> int:

    • The function will return the index of the first occurrence of needle within haystack and -1 if it is not found

    • This 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.

  1. https://open.kattis.com/problems/autori

  2. https://open.kattis.com/problems/apaxiaaans

  3. https://open.kattis.com/problems/hissingmicrophone

  4. https://open.kattis.com/problems/trik

  5. https://open.kattis.com/problems/pot

  6. https://open.kattis.com/problems/filip

  7. https://open.kattis.com/problems/reversebinary

  8. https://open.kattis.com/problems/sevenwonders

  9. https://open.kattis.com/problems/zamka

Warning

Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.

Previous Next

© Copyright 2022, James Hughes, Taras Mychaskiw, & Jean-Alexis Delamer.

Built with Sphinx using a theme provided by Read the Docs.