Watch my story 👉🏾 http://amays.me/BuzzFeed • Founder and career coach, Morgan Latimer Consulting • ex-@Google Software Engineer in tech 1% black • #StraightOuttaCompton foster kid • Serving Christ
Location
Los Angeles, CA
Education
University of California, Irvine (BS, Comp Sci)
Work
Founder & Career Coach @ Morgan Latimer Consulting, Senior Advisor for Brilliant Black Minds @ Karat
One thing I noticed is that you said adding to an array is constant time. Not quite correct since arrays in JavaScript really work like vectors. A true array is immutable, so if you want a bigger array than what you've got, you have to create a new, larger array and copy the old elements over to it, making the resize cost O(n). Vectors hide this from you to make it easier to work with them.
Watch my story 👉🏾 http://amays.me/BuzzFeed • Founder and career coach, Morgan Latimer Consulting • ex-@Google Software Engineer in tech 1% black • #StraightOuttaCompton foster kid • Serving Christ
Location
Los Angeles, CA
Education
University of California, Irvine (BS, Comp Sci)
Work
Founder & Career Coach @ Morgan Latimer Consulting, Senior Advisor for Brilliant Black Minds @ Karat
Note that adding to a vector is amortized constant time, meaning that it essentials averages out to constant time in normal situations. You'll also notice that retrieval from a Map or Dictionary is also linear time, but is amortized constant time.
Looking forward to your next article!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Well done! This is a great intro to Big O!
One thing I noticed is that you said adding to an array is constant time. Not quite correct since arrays in JavaScript really work like vectors. A true array is immutable, so if you want a bigger array than what you've got, you have to create a new, larger array and copy the old elements over to it, making the resize cost O(n). Vectors hide this from you to make it easier to work with them.
Interesting! I don't know too much about vectors. If you have any intro resources, let me know. Thanks :)
Sure! This article seems helpful: stackoverflow.com/questions/150790...
Note that adding to a vector is amortized constant time, meaning that it essentials averages out to constant time in normal situations. You'll also notice that retrieval from a Map or Dictionary is also linear time, but is amortized constant time.
Looking forward to your next article!