Skip to content

05. Searching

Lakivisi edited this page Jun 18, 2021 · 11 revisions

Linear and Binary Search

0. Lesson Prep

  • Send out pre-session reading materials by 8th June

1. Linear Search

June 15 2021, 7:30- 9 am EAT

Content and Plan

ℹ Have a time keeper

Tools

Lesson plan

  • 5 min: ice-break : Search ​

    • All of us have misplaced something and spent considerable amount of time finding it. Give examples of something that you misplaced, how long it took you to find it, if at all you did, and any strategy/plan that you came up for searching for it. e.g - Forgetting where you packed your car, spending 10 minutes finding it, going floor by floor to find it
  • Notion of equality:

    • Primitive types
    • Reference types
  • Search concept/ What's search is all about

  • Types of collections/bags that contains primitive and reference types and have students search (Student driven) i.e:

    • Array of integers
    • Array of students objects
  • Linear search - Introduce the label towards the last and explain why it's called Linear

Assignments

Further reading (Fill in by 8th)

  • One
  • Two

2. Binary Search

June 18 2021, 7:30 - 9 am EAT

Content and Plan

ℹ Have a time keeper

Tools

  • Language to use: Python
  • Replt

Lesson plan

  • 5 min: ice-break - Informally introduce the concept using an address book analogy with names ordered alphabetically
  • Total order ( 1 <= 3 <= 3)
  • Find the middle: Given a collection X of N items, find the index of an element at the center
  • Slicing on index range: Given a collection X of N items, return elements that start from index i to index i + N
  • Slicing on a match
  • A student try to find
  • Label it towards the last and explain why its called Binary
  • As an exercise : Provide a case for what they think which is efficient between Binary and Linear (Listen in during the recap session)
  • Calculate run time difference between Linear and Binary(towards the first)
  • "Break down a huge task into smaller pieces and solving them"
  • Recursive approach (Assignment) / iterative approach - Iterative approach
  • By copy the collections -
  • Doing in place (index - pointer) - Assignment (Best approach)

Assignments (Fill in by 8th)

Further reading (Fill in by 8th)

4. Recap Session (Drive Jointly)

June 22  2021, 8:00 - 9 am EAT
  • Review tasks/assignments
  • Answer questions
  • Open discussions
  • Applications of Search (Why do we need it)
  • Why search is a hard problem