Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Data structures: Array implementation of stacks
Description
See completeon data structures here:\r
\r
\r
In this lesson, we have discussed array based implementation of stack data structure.\r
\r
Source Code:\r
C code: \r
\r
C++ code (Object oriented implementation) : \r
\r
Time complexity of push for dynamic array implementation:\r
\r
If we start with an array of size 1 and keep doubling the size with each overflow, for n pushes.. cost of copy will be\r
\r
(1 + 2 + 4 + 8 + . + n/2 + n) \r
= n *( 1+ 1/2 + 1/4 + 1/8 + . 1/n) - taking out n \r
= n*2 - the expression in bracket above will evaluate to 2. \r
\r
So, cost of copy in n pushes = O(n)\r
Cost of n normal pushes = O(n) - each push takes constant time\r
Total cost of n pushes = O(n)\r
Average cost of 1 push = O(1). \r
\r
\r
For price problems and more, visit: \r
\r
Like us on Facebook: \r
\r
Follow us on twitter:
\r
\r
In this lesson, we have discussed array based implementation of stack data structure.\r
\r
Source Code:\r
C code: \r
\r
C++ code (Object oriented implementation) : \r
\r
Time complexity of push for dynamic array implementation:\r
\r
If we start with an array of size 1 and keep doubling the size with each overflow, for n pushes.. cost of copy will be\r
\r
(1 + 2 + 4 + 8 + . + n/2 + n) \r
= n *( 1+ 1/2 + 1/4 + 1/8 + . 1/n) - taking out n \r
= n*2 - the expression in bracket above will evaluate to 2. \r
\r
So, cost of copy in n pushes = O(n)\r
Cost of n normal pushes = O(n) - each push takes constant time\r
Total cost of n pushes = O(n)\r
Average cost of 1 push = O(1). \r
\r
\r
For price problems and more, visit: \r
\r
Like us on Facebook: \r
\r
Follow us on twitter:
More from User
10:45
Play Doh Kinder Surprise Eggs Surprise Toys Peppa Pig For Kids Children Toddlers Lala Do Play Doh
Ziwijo
07:49
Patterns For Doodling | 24 Doodle Patterns, Zentangle Patterns, Mandala Patterns
Ziwijo
09:19
Comprinhas de decoração pro natal dia #4
Ziwijo
17:49
play doh ice cream for kids, mainan lilin membuat es krim
Ziwijo
10:11
POKEMON GO TOP 5 GENERATION 3 + UPDATE NEWS AND 10KM EGG HATCHING
Ziwijo
14:27
My Anime/Manga Drawings new-2016 (HUGE DRAWING UPDATE!)
Ziwijo
Related Videos
32:25
Master Stacks: Fun Guide to Data Structures, LIFO & Real-World Uses
Neural Lantern
32:17
1. Introduction to Data Structure | Array Data Structure
GATE Playlist
14:17
17. Data Structure and Implementation- Infix to Postfix using Stack Data Structure
Log(n)Academy Trainings
11:07
8. Three Dimensional Array | Array Data Structure
GATE Playlist
10:23
3. Two dimensional Array | Array Data Structure
GATE Playlist
10:22
9. Z-Matrix | Sparse Matrix | Array Data Structure | Bonus on Array
GATE Playlist