1 Answer - Sort by: Date | Rating
Stack is a last in first out data structure, it means the record/data entered in the stack last, is first to be removed. There are two most common ways to implement it as:
1. Based on arrays.
2. Based on linked lists
The array based technique of implementing the stack is simple and easy to use. In this case all the elements of stack are stored as array elements. As there should be structure where only last entered data is available to remove, we impose some modifications to array.
We also use a pointer that points to the array element entered in last.
Thus this pointer is used to access the stack elements (that are stored actually in an array) in last in first out order. Through the use of this pointer to access the stack elements, only last element can be popped.
Each time a new element/data is pushed to stack; this pointer is set to point to that newly entered data.And each time we pop an element from the stack; this pointer is set to point to the previous element.The second approach to implement the stack, i.e. through a linked list (a list of record connected with each other via pointer) is more efficient.
1. Based on arrays.
2. Based on linked lists
The array based technique of implementing the stack is simple and easy to use. In this case all the elements of stack are stored as array elements. As there should be structure where only last entered data is available to remove, we impose some modifications to array.
We also use a pointer that points to the array element entered in last.
Thus this pointer is used to access the stack elements (that are stored actually in an array) in last in first out order. Through the use of this pointer to access the stack elements, only last element can be popped.
Each time a new element/data is pushed to stack; this pointer is set to point to that newly entered data.And each time we pop an element from the stack; this pointer is set to point to the previous element.The second approach to implement the stack, i.e. through a linked list (a list of record connected with each other via pointer) is more efficient.
0
0
- My Hotmail Does Not Open A Lot Of Times Even Though It Shows On The Toolbar That Processing Is Done?
- Can I Put Internet On My Dsi Without Paying?
- What Was The First Newspaper Ever Written In New York?
- What Is Full Form Of D Ortho Dnb?
- Who Developed Facebook?
- Can You Get Married On The Sims 2?
- When Technology Begin?
- Can You Have Babies On The Sims 2 For Xbox 360?
- How Do We Use Routers?
- Can You Add Languages To Magellan 1440 Gps?
- How Write A Project About Internet And Intranet Solution?
- How Much Is Xp Being Used Individuals On Personal Computers?
- How To Find Poliwhirl In Platinum?
- Where Is Poliwhirl In Platinum?
- Where Is Poliwag In Platinum?
- What Are Some Hacks For Meez.com?
- Write A C++ Program That Prints Out Selection Sort And Prints Out The Computer Time Used?
- How To Cost A Dish?
- How Do You Get The Ink Into The Cartridge For A Lexmark 26?
- A Program Ask The User To Choose Cpu Burst Randomly And Arrivals Time Randomly And Priority Randomly?
- How Do You Operate Microsoft Excel?
- How Do You Increase By Percents On Microsoft Excel 2007?
- Where To Find Shellgon On Platinum?
- Where Was The Camera First Used?
- What Is The Chaffee Program?

New Comment - Comments are editable for 5 min.