Reynald, to demonstrate a stack, steps through creating custom classes and methods. He talks through the process along the way so the student understands the basic requirement for a stack. The process is lengthy so Reynald finds a good breaking point so that the student can absorb what they wrote before continuing.
- [Instructor] So we're ready to create our first stack.…The first thing that we want to do…is to create a class called stack.…So let's go ahead and do that.…Class Stack.…And let's start off now within the class…by defining some variables that we're going to need.…The first is to keep track of the maxSize.…That's the max size of our collection.…Now, the next variable that we want is an array.…
An array of strings,…and we'll call this appropriately the stackArray.…And what we're going to keep track of,…I'm a big fan of movies,…so it's going to be our container for the list of movies.…The third variable is going to be top,…and this will represent…the index position of the last movie in the stack.…Now what I'm going to want to do is just assign the values…in a constructor.…So let me just go ahead and use this awesome method stub…that I love here, CTOR.…
I wish we had method stubs in real life.…They'd life a lot easier.…Within this constructor, we're going to assign maxSize…to the value of size,…and size is being passed in to our constructor.…
- Working with linked lists
- Creating a stack
- Defining a queue
- Performing a binary search
- Finding target values with a linear search
Skill Level Beginner
1. Algorithms and Data Structure Overview
Reasons for this course1m 26s
2. Linked List
5. Binary Search
6. Linear Search
- 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.