Master Array-Based Stack Implementation in C 🧠

Learn how to implement stacks using arrays in C with this comprehensive tutorial and source code. Perfect for understanding core data structures!

Ziwijo4 views13:08

About this video

See completeon data structures here:\r<br>\r<br>\r<br>In this lesson, we have discussed array based implementation of stack data structure.\r<br>\r<br>Source Code:\r<br>C code: \r<br>\r<br>C++ code (Object oriented implementation) : \r<br>\r<br>Time complexity of push for dynamic array implementation:\r<br>\r<br>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<br>\r<br> (1 + 2 + 4 + 8 + . + n/2 + n) \r<br> = n *( 1+ 1/2 + 1/4 + 1/8 + . 1/n) - taking out n \r<br>= n*2 - the expression in bracket above will evaluate to 2. \r<br>\r<br>So, cost of copy in n pushes = O(n)\r<br>Cost of n normal pushes = O(n) - each push takes constant time\r<br>Total cost of n pushes = O(n)\r<br>Average cost of 1 push = O(1). \r<br>\r<br>\r<br>For price problems and more, visit: \r<br>\r<br>Like us on Facebook: \r<br>\r<br>Follow us on twitter:

Video Information

Views
4

Total views since publication

Duration
13:08

Video length

Published
Oct 19, 2017

Release date

About the Channel

Related Trending Topics

LIVE TRENDS

This video may be related to current global trending topics. Click any trend to explore more videos about what's hot right now!

THIS VIDEO IS TRENDING!

This video is currently trending in Thailand under the topic 'สภาพอากาศ'.

Share This Video

SOCIAL SHARE

Share this video with your friends and followers across all major social platforms including X (Twitter), Facebook, Youtube, Pinterest, VKontakte, and Odnoklassniki. Help spread the word about great content!