CS #4: Algorithms
Problem solving while measuring performance.
- 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.
- When you're solving a problem, try using pseudocode- Plain language
- Readable programming language first.
- 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...
- RecursiveCalling itself until it finds the answer
- IMO, this is one of the most overrated algorithm.
- 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)