CS #4: Algorithms

Problem solving while measuring performance.

  1. Not just about solving problem. Did you solve it efficiently (the fastest way)?
    • Bigger companies such as Amazon, Microsoft and Facebook will ask tougher algorithm questions.
  2. When you're solving a problem, try using pseudocode- Plain language
    - Readable programming language
    first.
  3. Types of algorithms:
    • Linear searchFind an item in unsorted sequence
    • Selection algorithmFind smallest or largest number in a sequence
    • Binary searchFind an item in a sorted list
    • SortTaking an unsorted sequence and return in order
    • And more...
  4. RecursiveCalling itself until it finds the answer
    • IMO, this is one of the most overrated algorithm.
  5. Let's go over some examples
    • Describe how interviewers ask algorithm questions.
      • Interviewer will start by giving you a problem.
      • Ask questions. Understand before you start coding on the whiteboard.
      • Think out loud. Pseudocode first. Write code.
      • Test code. Be organized - group your test cases starting with simple, working cases.
    • Quick sort - Sorting is usually asked in interviews.
    • Anagram - LISTEN and SILENT
    • Homework: Check if a string is a palindrome (e.g. RACECAR)