此内容来自第三方平台 (Dailymotion)。如果此视频侵犯了您的版权,请使用 立即删除 工具。
Data structures: Array implementation of stacks
描述
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:
关键词与标签
相关视频
Master Stacks: Fun Guide to Data Structures, LIFO & Real-World Uses
Neural Lantern
1. Introduction to Data Structure | Array Data Structure
GATE Playlist
17. Data Structure and Implementation- Infix to Postfix using Stack Data Structure
Log(n)Academy Trainings
8. Three Dimensional Array | Array Data Structure
GATE Playlist
9. Z-Matrix | Sparse Matrix | Array Data Structure | Bonus on Array
GATE Playlist
3. Two dimensional Array | Array Data Structure
GATE Playlist
来自同一上传者
Play Doh Kinder Surprise Eggs Surprise Toys Peppa Pig For Kids Children Toddlers Lala Do Play Doh
4 次观看
Patterns For Doodling | 24 Doodle Patterns, Zentangle Patterns, Mandala Patterns
3,392 次观看
Comprinhas de decoração pro natal dia #4
4 次观看
play doh ice cream for kids, mainan lilin membuat es krim
12 次观看
POKEMON GO TOP 5 GENERATION 3 + UPDATE NEWS AND 10KM EGG HATCHING
1 次观看
My Anime/Manga Drawings new-2016 (HUGE DRAWING UPDATE!)
2 次观看