Skip to content

Instantly share code, notes, and snippets.

@rish-16
Created January 29, 2021 04:16
Show Gist options
  • Select an option

  • Save rish-16/2931b74eebd36ae8bf69e4d0afc8e254 to your computer and use it in GitHub Desktop.

Select an option

Save rish-16/2931b74eebd36ae8bf69e4d0afc8e254 to your computer and use it in GitHub Desktop.
Notes from CS2040S Week 3 Tutorial

CS2040S Week 3 Tutorial

Notes from CS2040S Week 3 Tutorial

Asymptiotic Analysis

  • Big Theta
    • t(n) = Theta(g(n))
    • k1 * g(n) <= t(n) <= k2 * g(n)
  • Big O (how bad it can be)
    • t(n) = O(g(n))
    • t(n) <= k * g(n)
  • Big Omega
    • t(n) = Omega(g(n))
    • k * g(n) <= t(n)

Searching

  • Linear search
    • O(n)
  • Binary Search
    • O(logn) (exploits a property of a sequence / array)
    • Used for peak / valley finding problems

Using static in main (or functions in general)

Java's main method has to be declared static becuase the keyword allows it to be called without creating an object of the class where the said main method is defined. If we omit static, Java will successfully compile the program but it won't execute it.

Abstract Class vs. Interface

In interfaces, none of the methods are implemented. In abstract classes, not all methods are implemented while some are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment