Giter Club home page Giter Club logo

bigocheatsheet's Introduction

bigocheatsheet's People

Contributors

adam-arold avatar agfor avatar alanbriolat avatar alvinwan avatar aymanim avatar bartmassey avatar caspervg avatar cristaloleg avatar d3dave avatar eckankar avatar ericdrowell avatar felixzhuologist avatar jay754 avatar jdavis avatar jhamon avatar jonathanmcelroy avatar mcverry avatar ndizazzo avatar nodirt avatar ocozalp avatar piperchester avatar qpleple avatar rahulc93 avatar raypereda avatar renfredxh avatar sharpobject avatar siphamm avatar steven41292 avatar vault avatar yunchenglin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bigocheatsheet's Issues

Quicksort worst case runtime can be O(n log n)

In this issue, it was decided that quicksort worst case runtime is O(n^2) based on a paper which contained an assumption that leads to unnecessarily slow quicksort implementations. In my opinion, the cheat sheet should contain the running time of the asymptotically fastest implementation of each algorithm, which runs in O(n log n) in this case.

Should most entries have no Theta() time complexity set listed?

  • In set terms Theta() is the intersection of O() and Omega() [more info at the highest ranked answer in this complexity question on stackoverflow].
  • Very few algorithms have Theta() (merge sort being one of the few examples), however all algorithms in the cheatsheet seem to have entries).
  • There also seems to be mixing between best, average, worst and the mathematical concepts of big Omega, Theta, O.

Singly Linked List O(1) deletion

I think it's misleading to say that it's O(1), since it assumes that you already have the element previous to the one to delete. It should also specify that there is a search time involved, either by specifying O(n) or as a tooltip. Also, in the wiki source, it is specified that there is a search time.

Worst-case space complexity of Quicksort should be set to O(n)

Right now, the worst-case space complexity for Quicksort, is set to O(log(n)). This is not right - the average-case space complexity is ฮ˜(log(n)), but when you attempt to sort an already sorted list, this will lead into n recursive calls on the stack, thus the O(n) worst-case space complexity.

PDF version

Since this is a cheatsheet I'd say it would be nice to also have it in a PDF form for offline/print use.

What do you think?

Revert latest commit

@ericdrowell committed 1193ed2 13 months ago.

The changes in that commit are wrong. Theta and Omega do not mean average case and best case time complexity. Theta, Omega, and Big-O are completely orthogonal to the concepts of average-case, best-case, and worst-case. Strictly speaking, most of the time we say an algorithm is O(p) for some polynomial p, we really mean it is ฮ˜(p). In any case, the information on this page is misleading, and my students now come into class believing that theta is equivalent to "average case," when this is plainly false, because they have heard that this page is the premier resource for algorithm time complexity.

Suggest reverting 1193ed2.

Ambiguity in Graph section

There is variety of ways to represent graphs, and complexity of graph operations depends on graph representation. However, I am curious how you estimated complexity of edge insertion, which is the same for all graph representations (add Edge, O(1)). What kind of graph implementation you assume hereby? Do you assume that you have a hash_map for vertices in adjacency list, which makes it O(1)? If so, it would be good to update the information.

To depict the issue, one can imagine very simple representation of a graph with vertices that contain strings. In c++ we can represent adjacency list using STL collections, such as:
std::mapstd::string,std::setstd::string adjacency_list;
Now, method to add edge, i.e. addEdge("baby","carrot"), first has to look up for position of the vertex ("baby") in the adjacency list, which is O(logn) in this case.

Add section headers to nav bar

Currently, the nav bar has
Searching
Sorting
Graph
Comments

It's missing Data Structures and there's a bit of name collision between graph algorithms and the Big-O complexity graph.

Use GitHub Pages + CNAME

One suggestion is to use GitHub pages and just add a CNAME to your repository. If you create a branch called gh-pages, it will automatically update the website. This way you won't have to worry about keeping the server and code in sync.

Read more about GitHub Pages here.

Add amortized runtimes

Big-O notation can be helpful for lots of things, but amortized runtimes can be just as helpful as big-O time-complexities (sometimes moreso).

Including them in the tables would be incredible.

Color keys

Coloring is hard to define.

For eg, finding the shortest-path in a graph with negative edges:

  • Dijkstra is fast, takes O((V+E) log V) but does work with negative edges.
  • Bellman-Ford is O(VE), it's way slower than Dijkstra.

Would you put Bellman-Ford in green because it's the fastest you can do in that situation? Or in red because it's slower than Dijkstra?

How about absolute colors for each of the following categories?

  • white: constant-time, O(1)
  • blue: sub-linear, like O(log n) or O(sqrt n)
  • green: linear, O(n)
  • yellow: quasilinear, like O(n log n)
  • red: higher, like O(n^2), O(n^2 log n), O(n^3)

I don't think you would ever want to list an exponential time algorithm, O(2^n), O(n!), O(n^n), so no color needed

Qualitatively: O(2^n) vs O(n^2) are vastly different. (And other labeling issues.)

If you think about orders of magnitude of difference, I think the buckets ("Horrible", "Bad", "Fair", "Good", "Excellent") are done incorrectly.

O(2^n) and O(n^2) are vastly different, but both are labeled "Horrible." O(2^n) algorithms fall over long before n = 1000, O(n^2) algorithms can be practical and useful for n = 1 million.

O(n log(n)) and O(n) are not very different, but one is "Good" and the other "Fair". Both are practical for roughly the same class of problem. In many cases O(n log(n)) algorithms are preferred in practice over O(n) algorithms for non-complexity reasons, because the theoretical complexity difference is dominated by other factors.

O(log(n)) and O(1) are actually quite different, but both are labeled "Excellent." This is the least worrying of these, but if any factor of log(n) is important enough to distinguish labels, it's the first one. In this case, it's mostly because of CPU caches and memory accesses. Small constant memory access is relatively cheap, O(log(n)) memory accesses can have dramatic effects on cache misses and resulting performance of a whole program.

Associative Array

I thought that the data structures section should have a more general link to an associative array/map/dictionary. I see a link exists for a hash table which is just an implementation of an associative array.

Adding the whole page

Hi!

Would you mind adding all the code of the page? I'd like to try to integrate MathJax.

fixed-size array is missing

There are cases where a fixed-size array is a good data structure. It has always O(1) for insertion, deletion and search Why is it not there yet?! :-)

Recommend social image

I recommend the website add an Open Graph meta tag so that an image preview is added to link as it's shared.

Add O(nlog^n) to Chart

Can we replace the existing image with the one below?
Shell sort has time complexity O((nlogn)^2) in its average and worst case, but this function is not included in the chart provided.
big-o-complexity

Here's an iframe linked to an interactive version:

<iframe width="840" height="466" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1V6hJ9R0Tx9JMa0pEUq2TTkMFCkVO00vdusFFUYLmhbw/pubchart?oid=1753507166&amp;format=interactive"></iframe>

@caspar

Omega And Theta

In some of these tables (e.g. array sorting), a 'best' and 'average' case are included along with the worst case, and they use the big O notation as well. Are the best case runtimes of these algorithms not Omega and Theta, respectively?

I'm in the process of beefing up my CS theory and there seems to be a ton of conflicting information in the community about asymptotic analysis and Big O notation. Not trying to nitpick on this (and my understanding of this could be off-base), but wouldn't the best case runtime for an algorithm be represented as ฮฉ(n) and the average as ฯด(n), not O(n) since Big O implies the worst case?

You are misunderstanding O vs. Theta.

You seem to be making the common mistake of thinking big-Theta means average case and big-O means worst case, which is not correct.

Either big-O or big-Theta or big-Omega can be used meaningfully to describe any of best, average, or worst case -- the concepts are completely orthogonal.

To be mathematically accurate your page should have Theta everywhere.

Multilingual Support

Last year, I forked and translated the entire html to brazilian portuguese, even the articles url. It would be very interesting if the official website had an option to choose the language, so that other contributors could translate to their mother languages and reach more people.

Brazilian translation

Still being maintained?

Hey, I just wanted to check if this project is still being maintained? It seems like the site is used pretty heavily as a reference and thankfully a lot of these algorithms don't change over time (hehe...) in runtime complexity so more or less it's been great. The last commit in this repo has been a year ago so I'm hoping it isn't going to die off. At the very least, maybe there can be a handful of the contributors that would be willing to help maintain this site and they can be distinguished?

It also looks like a giant portion of runtimes was deleted by accident..? Not that I'm involved but I'm seeing a lot of redundant PRs adding the same run times so it would be good if these were either just merged or closed.

Thanks for your hard work on this project @ericdrowell! Let us know :)

Website doesn't load without www.

Trying to navigate to the site from google results in a server error. The site completely fails to load with bigocheatsheet.com but works if you manually change the url to www.bigocheatsheet.com.

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.