Mastering Stack Made Simple: Your Easy Guide to Data Structures !
Array Implementation of Stack code [C++] :
// Shyam Sunder Kanth// Insta : still_23.6_8// Array Implemetation of stack#include<iostream>using namespace std;class Stack{public:int *arr;int size;int top;Stack(int size){this->size = size;arr = new int[size];top = -1;}void push(int ele){// Handle stack overflow conditionif(size-top <=1){cout<<"Stack overflow";return;}// Handle non s-o conditiontop++;arr[top] = ele;}void pop(){// Stack underflow conditionif(top == -1){cout<<"stack underflow";return;}// Non s-u conditiontop--;}int peek(){// Handle empty stack conditionif(top == -1){cout<<"Stack is empty";return -1;}// Non-empty casereturn arr[top];}bool isEmpty(){if(top == -1){return true;}else{return false;}}};int main(){Stack st(5);st.push(1);st.push(2);st.push(3);st.push(4);st.push(5);st.pop();st.pop();st.pop();st.pop();st.pop();cout<<st.peek()<<endl;cout<<st.isEmpty();return 0;}
Hey, thanks for watching our video about Stack Array Implementation ! In this video we’ll walk you through:
- Concept
- Properties
- Operations
- Array implementation
- Code
All codes are available at my GitHub account, check them out here:
https://github.com/shyamkanth/Placements
Check out other videos from DS Revealed playlist: https://www.youtube.com/playlist?list=PLNXqJgOsTCZOB60T9HDhMf_o8RXbNWgqS
Check out our channel here: https://www.youtube.com/@DevelopersByte
Find us at: https://shyamkanth.github.io/
Timestamps:
0:00 Intro
0:30 Concept
1:05 Properties
10:10 Push Operation
15:23 Push Code
24:23 Pop Operation
27:43 Pop Code
30:03 Top Operation
32:15 Top Code
35:30 isEmpty Operation
36:07 isEmpty Code
38:10 Outro
About our channel:
Our channel is about Revealing the secrets of Data Structure. We cover lots of cool stuff such as Codes, Concepts and Implementations.
Check out our channel here: https://www.youtube.com/@DevelopersByte
Don’t forget to subscribe!
Follow me on social media:
Get updates or reach out to Get updates on our Social Media Profiles!
GitHub: https://github.com/shyamkanth/
Instagram: https://instagram.com/still_23.6_8
Instagram personal: https://instagram.com/itz_sammmii
No comments:
Post a Comment