Transcript from the "Big O: Push, Shift, & Unshift" Lesson

[00:00:00]

>> Bianca Gandolfo: What about this one? So we have a list of different ways that you can greet someone in languages.

>> Bianca Gandolfo: What's the time complexity of push? We talked a little bit about that. Constant, mm-hm.

>> Student1: [INAUDIBLE] it goes to the end.

>> Bianca Gandolfo: Mm-hm, yep, we always just put it at the end, not a big deal.

[00:00:22] Other languages, when you're actually doing memory allocation, this might not be a constant. But in JavaScript, we can reason that this is just a constant. We don't need to worry about initializing an array of a certain length and blah, blah, blah, and then keeping track and then expanding if it exceeds a certain length.

[00:00:40] So we don't need to worry about anything like that, cool. And then if we do,

>> Bianca Gandolfo: I always get these two, I never actually use these, does anyone actually use these in their real life, shift or unshift?

>> Bianca Gandolfo: So if we're taking the first one off the front, how does that change the time complexity of this operation?

[00:01:05]

>> Bianca Gandolfo: Mm-hm, just like I said, we were going to, if we take the first one off, then we need to shift the second one into the first, the second to the first, or, sorry. The second to the first, third to the second, fourth to the third. And then that's gonna be n number of operations, where n is the length of that array.