Introduction to Data Structures for Interviews

# Queue: Q&A

## Bianca Gandolfo

Thumbtack

### Check out a free preview of the full Introduction to Data Structures for Interviews course

The "Queue: Q&A" Lesson is part of the full, Introduction to Data Structures for Interviews course featured in this preview video. Here's what you'd learn in this lesson:

Bianca addresses questions about the applications for stacks and queues, as well as the importance of considering space complexity.

Preview
Close

### Transcript from the "Queue: Q&A" Lesson

[00:00:00]
>> 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.

### Learn Straight from the Experts Who Shape the Modern Web

• In-depth Courses