Learn the advantages and disadvantages of using a stack or a queue in your programs. Explore the runtime complexity each stack and queue operation takes in terms of Big O notation.
- It's important to understand the pros and cons…of stacks and queues so you know when to use them.…Stacks are great for programs…where you need to reverse things.…For example, let's say you push a string…onto a stack one character at a time…and then make a string from the members…popped off the stack.…The resulting string is reversed.…Stacks are also good for keeping track of state…as things are pushed on and popped off the stacks.…Going deeper into the operations,…if you need to add and remove from the back…of a data structure a lot, stacks are a great option.…
Pushing, peeking and popping takes very little time,…in fact, constant time because stacks often…have a linked list implementation…or dynamic array implementation.…If you find yourself needing to index your data…structure and get a specific item in the middle…of your use case, stacks are not the solution.…It would take O of N time in the worst case…because you would need to pop off everything on the stack…and essentially destroy the data structure…in order to see each individual item.…
- Data types: Booleans, numbers, strings, and more
- Multidimensional arrays
- Jagged arrays
- Search and sort arrays
- Linked lists
- Stacks and queues
- Hash functions and hash tables
- Trees and graphs
Skill Level Intermediate
Understand data structures1m 25s
1. Introduction to Data Structures
4. Stacks and Queues
5. Hash-Based Data Structures
6. Trees and Graphs
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.