Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement linear and binary search #20

Open
9 tasks
mwermelinger opened this issue Jan 7, 2024 · 0 comments
Open
9 tasks

Implement linear and binary search #20

mwermelinger opened this issue Jan 7, 2024 · 0 comments
Labels
effort: medium These issues require some work priority: medium type: feature New feature

Comments

@mwermelinger
Copy link
Member

Create a file paddles/search.py:

  • Implement a linear search for an item in a sequence that may be unsorted.
  • Implement a linear search in a sorted (non-decreasing) sequence.
  • Implement a recursive binary search in a non-decreasing sequence. You may copy the code in Section 13.4.2 of the M269 book.
  • Implement an iterative binary search. You may copy the code in Section 13.4.3 of the M269 book.
  • The functions, except the first one, should raise ValueError if the sequence isn't non-decreasing.

Create a file tests/test_search.py that is similar to sorting.py:

  • Create two constant lists, one of sorted sequences and another of unsorted sequences.
  • Write a fixture sorted_sequence that returns one of the sorted sequences and a fixture any_sequence that returns either a sorted or unsorted sequence.
  • Write a fixture search_sorted that returns a search function that works on sorted sequences and a fixture search_any that returns a search function that works on any sequence.
  • Write two test functions: one applies search_sorted to sorted_sequence, the other applies search_any to any_sequence.
@mwermelinger mwermelinger added effort: medium These issues require some work priority: medium type: feature New feature labels Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium These issues require some work priority: medium type: feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant