Array Implementation of Stacks (Part 4)

preview_player
Показать описание
Data Structures: Array Implementation of Stacks (Part 4)
Topics discussed:
1) isFull() function to check if the stack is full or not.
2) isEmpty() function to check if the stack is empty or not.
3) Complete C program for the array implementation of stacks.

Music:
Axol x Alex Skrindo - You [NCS Release]

#DataStructuresByNeso #DataStructures #Stacks #ArrayImplementationOfStacks
Рекомендации по теме
Комментарии
Автор

actually, I want to say after watching every lecture thank you for giving this presentation.

dibyendudebnath
Автор

Your video lectures are amazing, even better than the paid courses, you are really working hard, please complete this series fast.

pallavisharma
Автор

As usual, such an amazing presentation!
Awaiting for Queues, Binary trees and lookup tables videos
Thanks

mahendrasondagar
Автор

awesome, you can also do it using do while loop.
#include <stdio.h>

void isempty(int a[], int *n, int *top)
{
if(*top==-1)
printf("stack is empty");
else
printf("stack is not empty");
}
void isfull(int a[], int *n, int *top)
{
if(*top==*n-1)
printf("stack is full");
else
printf("stack is not full");
}
void push(int a[], int *n, int *top)
{
int k;
printf("enter the element to push:");
scanf("%d", &k);
if(*top==*n-1)
{
printf("overflow! push not possible");
return;
}
else
{
(*top)++;
a[*top]=k;
}
}
void pop(int a[], int *n, int *top)
{
if(*top==-1)
{
printf("underflow! pop not possible");
return;
}
else
(*top)--;
}
void display(int a[], int *n, int *top)
{
int i;
if(*top==-1)
{
printf("stack is empty");
return;
}
else
{
printf("the stack:\n");
for(i=*top;i>-1;i--)
{
printf("%d ", a[i]);
}
}
}
void peek(int a[], int *n, int *top)
{
if(*top==-1)
{
printf("stack is empty");
return;
}
printf("the top element is :");
printf("%d", a[*top]);
}
int main()
{
int n, top=-1, i, c;
printf("enter size of array:");
scanf("%d", &n);
int a[n];
do
{
printf("\n1:isfull, 2:isempty, 3:peek, 4:push, 5:pop, 6:display, 7:exit\n");
printf("enter your choice:");
scanf("%d", &c);
switch(c)
{
case 1:
isfull(a, &n, &top);
break;
case 2:
isempty(a, &n, &top);
break;
case 3:
peek(a, &n, &top);
break;
case 4:
push(a, &n, &top);
break;
case 5:
pop(a, &n, &top);
break;
case 6:
display(a, &n, &top);
break;
case 7:
printf("thank you");
}
}
while(c!=7);
return 0;
}

chotubiswas
Автор

Need Remaining videos stack linkedlist representations aswell as Queues full material.

k.s.vijaykumar
Автор

sir while choice is 2 means pop it is showing underflow what to do now

saimohit
Автор

This is the Masterpiece playlist for Data Structures.

Pluto-rn
Автор

i have my exams upcoming for dsa, due to covid teachers r unable to teach us properly. so i highly trust jaspreet a person from neso.i msg u in insta but no reply anyway i had completed till array using stack part 2 pls upload stack and queue as fast as possible.pls so that we 50students trusting neso could clear our dsa paper.pls pls pls

akashkrishna
Автор

You're the best!!!! You're helping me a lot at the college.

eddcalistenia
Автор

Please can you keep the concept of inheritance in cpp

ponnathirupathi
Автор

kindly post videos for queues in data structure

pamilairene
Автор

[Error] 'Exit' was not declared in this scope, anyone can help me please?

absen
Автор

Could you please upload the file i/o lectures?

MKSundaram
Автор

Please copy paste the code and put in description box sir!!.

lavalalli
Автор

Thank u so much for these amazing and useful videos

kalpanakathait
Автор

typedef enum bool {false, true} bool;

bool isFull()
{
if (top == MAX-1)
return true;
return false;
}

bool isEmpty()
{
if (top == -1 || top < MAX-1 )
return true;
return false;
}

accessdenied
Автор

Sir ..due to infinite while loop..
It is printing :
Push
Pop
print the top element
Print all elements in stack
Quit
Enter your choice... infinite times
What to do sir....??

marvelanddisneyworld