Easy as a pie Big O notation: A note about Objects
An object is an unordered data structure where everything is stored in key-value pairs.
Let superDog = {
Name: “Dulce”,
Breed: “Chihuahua”,
Weight: “2 pounds” }
Objects are great when storing in order is not a concern and we need to be fast at inserting and removing data.
But exactly, how fast?
- Insertion: O(1)
- Removal: O(1)
- Access: O(1)
- Searching: O(N)
It works in constant time because since we have no order in our data, we technically don’t have a beginning or end so it doesn’t really matter in which order data is added.
Got something to add? Please feel free to reach out for any question, comment or meme.
文章来源:https://dev.to/misselliev/easy-as-a-pie-big-o-notation-a-note-about-objects-3gn9