Giter Site home page Giter Site logo

algorithm's Introduction

Algorithm

This is my repo of learning some algorithms

Book

https://zoracon.keybase.pub/Grokking_Algorithms.pdf

Chapter 1 Binary Search

Binary search is a lot faster than simple search. Its input is a sorted list of elements, we need to find the middle index of the list by dividing the length of the list to half. If the element we are looking for is greater than the mid element, we do search on the left half of the list, otherwise, we do search on the right half of the list, until we find the element. If we don't find the element, it should return null.

Run Time

  • best case: mid is the one O(1)
  • worse case start or the end O(logn)
  • average case O(logn)???

Chapter 2 Selection Sort

Selection sort algorithm sort a given list by finding it's smallest/largest item each time when it iterate through the list and insert it to a new list in order.

Run Time: O(n^2)

Chapter 3 Recursion

  • Recursion is when a function calls itself.
  • Every recursive function has two cases: the base case and the recursive case.
  • A stack has two operations: push and pop.
  • All function calls go onto the call stack.
  • The call stack can get very large, which takes up a lot of memory

Chapter 4 Quicksort

algorithm's People

Contributors

margaret-jihua avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.