DEV Community

Discussion on: Algorithms and Data Structures in JavaScript

Collapse
 
isaacleimgruber profile image
IsaacLeimgruber

O (n2) is not horrible. If you problem is matrix multiplication, the you're a god if you do it in O (n2). The complexity is relative to the problem. Also, time complexity should be considered together with space complexity. If you can sort in O(n) time wih O(n2) it might be not that good, but it depends on the size of your data. For small data you can afford to store O(n2). A good complexity table is the one of "data structure complexity in c++" which compares operation for different data structs

Collapse
 
frosnerd profile image
Frank Rosner • Edited

Hi Isaac,

I think the chart was taken from bigocheatsheet.com/ and there it mainly talks about data structure operations (read, insert, update, delete) and sorting algorithms.

I agree with you that to say a complexity is bad cannot be done independently of the problem.

Collapse
 
isaacleimgruber profile image
IsaacLeimgruber

Yeah exactly thats the cheatsheet I had in mind :)