Competitive Coding

What is algorithm?
Algorithm is well-define step by step procedure to solve the specific problem.

Why should you care ? why not just learn full stack dev.
    what is you job ? Solving Problems!
    problems:

  • already solved : face detection, shorted route, ... (use external lib)
  • specific to the company's needs:
    • Facebook suggestions

Why do Big Companies ask algorithms in interviews? 

  • Questions about language/technology 
  • Algorithm ?
    • Approaching newly seen problems 
    • Discussing different approaches (brainstorming session)
    • Articulation ideas, communication skills 
    • Adaptability
    • picking your brain :

Innovative product that uses algorithm?

  • Google search being able to auto-correct and suggest
  • google Maps directions : Dijkstra , A* , kd tree, range search
  • Google translate and direction
  • Self Driving cars
  • Cleaning Robot detection the house map
  • Space X making reusable spaceship that land back earth.

Correctness and Performance ?

  • An algorithm is correct if it is gives you the desired outcome/output no mater the input you provide it with.
  • Determining the correct of an Algorithm:
    • easy: sum(a,b) return a + b
    • hard : Kruskal's algorithm for MST
  • Performance : How  fast  an algorithm executes depending on the input size
  • Sometimes you can't have both -> NP-complete problems 
  • NP-complete problems can't be solved in polynomial time
  • They are solve in O(2^n), O()3^n),....time complexity.
  • Sacrifice correctness for time: 
    • O(2^n) > 100% accuracy
    • O(3^n) > 87.5% accuracy
    • O(n^2) > 79.2% accuracy

Example : Amazon courier delivering package in shortest time (Travelling Salesman Problem)

Introduction to Data Structure :

What is Data ?
Everything you see is a set of pixels(data):

What is Data Structures?
Only When arrange in a concise and structure way data becomes meaningfull.
In Computing data = bits(0's and 1's)
CPU(computer brain) makes bits meaningful 

Bits :

  • numbers
  • pixels
  • decibels

Real-life example

  • Arrays - Leader-board
  • Matrices- Image processing
  • Linked List - Playlistd
  • Stack - Undo Redo functionality
  • Queue - OS job scheduling
  • Graph - Facebook friendship relations
  • Tree - Hierarchy relations, HTML DOM Elements  

Complexity Analysis : 

 

Comments