Introduction to Data Structures for Interviews Queue: Q&A
Transcript from the "Queue: Q&A" Lesson
>> Speaker 1: Use these in like other data structures to like some algorithms, some graph algorithms use stacks and queues to maintain,
>> Bianca: Mm-hm, like a particular order.
>> Speaker 1: An order of visited nodes etc.
>> Bianca: Yeah, absolutely, so you're or whenever you use recursion, so trees and grass are recursive by nature.
[00:00:26] Whenever you use recursion, you're actually using a stack, because of how your code is being executed. So if you're thinking about space complexity and JR and I were talking a little bit about space complexity with linked list. When you have a recursive algorithm, you need to account for that space actually.
[00:00:48] So if you're thinking about, what is the time complexity for this algorithm. And you forget that your recursion is actually, making a stack and saving values for each call you know maybe you're recursively looping through an array. Which you can do. Every time and you passing an index to each of those recursive calls.
[00:01:10] It's like making a stack of another array. Or making a stack of those items in it. So that is using a stack. Implicitly in your code. But it's still requires that memory. You can have a stack overflow when you don't have enough working memory to manage all of those stack frames.