Creation of Stack in DS | Data Structures Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น • 282

  • @NareshIT
    @NareshIT  5 ปีที่แล้ว +25

    Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL

    • @farmood100
      @farmood100 5 ปีที่แล้ว +1

      Plz reply to my commnent

    • @faizanmahmood303
      @faizanmahmood303 5 ปีที่แล้ว +2

      Thank you Sir for your depth knowledge
      I have a question why in push function we are returning void and in pop function we are returning integer value

    • @AgyaanSeGyaanTak
      @AgyaanSeGyaanTak 5 ปีที่แล้ว +1

      Sir seriously you have made my concept perfect.. Thank you so much i woul love to get train by you . My gmailid divyanshdixit@gmail.com sir please send your curriculum i called your no it was unreachable

    • @tanishqtripathi5228
      @tanishqtripathi5228 5 ปีที่แล้ว +1

      Sir very nice concept

    • @tanishqtripathi5228
      @tanishqtripathi5228 5 ปีที่แล้ว +2

      But u r saying that it is impossible to delete any data from any memory location in any praogrammimg language
      So what is the role of (free) function in c we call that to delete the data from any memory location anf make that memory free

  • @naveenkumarreddy2204
    @naveenkumarreddy2204 7 ปีที่แล้ว +94

    Finally i got the desired channel which will boost up my programming skills. Especially data structures. Thank you NARESH TECHNOLOGIES. It will be better if you make videos on Algorithms also.

    • @bholaprasadyadav4396
      @bholaprasadyadav4396 4 ปีที่แล้ว +1

      NT's lecture is best please Alsoo watch
      This lecture at once th-cam.com/video/4BDeAliHVgY/w-d-xo.html

    • @ce13_piyushprajapati40
      @ce13_piyushprajapati40 3 ปีที่แล้ว

      @@bholaprasadyadav4396 Yes bro but it's private video so can't seeing.

    • @bholaprasadyadav4396
      @bholaprasadyadav4396 3 ปีที่แล้ว

      @@ce13_piyushprajapati40
      Sorry for this
      Please visit this one
      And send your feedback ✍️ th-cam.com/video/je1w27UKKs8/w-d-xo.html

  • @akilansundaram2181
    @akilansundaram2181 6 ปีที่แล้ว +88

    27:46 is very important. It explains the meaning behind deletion in this example of stack.
    Also, use "return ele;" instead of "return top;" in int pop() function.

    • @uddyanarora1113
      @uddyanarora1113 5 ปีที่แล้ว +2

      Can you please tell me that which language he is using 'c' language or 'java' language ??

    • @shramanmukherjee9426
      @shramanmukherjee9426 4 ปีที่แล้ว +3

      There's a small mistake there.....it should have been stack [top]...bcz top will give the index no not the element and yes return ele is correct

    • @bholaprasadyadav4396
      @bholaprasadyadav4396 4 ปีที่แล้ว

      NT's lecture is best please Alsoo watch
      This lecture at once th-cam.com/video/4BDeAliHVgY/w-d-xo.html

    • @achyuttokekar9227
      @achyuttokekar9227 4 ปีที่แล้ว +2

      Exactly... I'm here in comment to right this😄

    • @ravirajsaraganachari3038
      @ravirajsaraganachari3038 4 ปีที่แล้ว +1

      Correct, same observation 😊

  • @swatishambhavi3649
    @swatishambhavi3649 5 ปีที่แล้ว +7

    The moment I struggle with any doubt, you clear my doubt then and there. You teach so well, Sir.

  • @mayurb7595
    @mayurb7595 4 ปีที่แล้ว +2

    One of the best technical trainers I have ever listened to!!

  • @aswing2706
    @aswing2706 4 ปีที่แล้ว +2

    I have been trying to understand stack for 3 years but failed.
    Now I know the concept because of you.
    Thank you very much

  • @yashrajrajmane5114
    @yashrajrajmane5114 5 ปีที่แล้ว +4

    You are Best teacher sir
    Keep going on because of i really interested in all programming knowledge thank you so much sir🙏🙏🙏🙏

  • @udaygameryt9583
    @udaygameryt9583 2 ปีที่แล้ว +4

    For your lectures... 1M subs is not a matter 🙃i expect more than 5M❤️

  • @nikhildakwale412
    @nikhildakwale412 4 ปีที่แล้ว

    I got chills the moment you said that when you try to add more data, the data in *that* location is overwritten

  • @ce13_piyushprajapati40
    @ce13_piyushprajapati40 3 ปีที่แล้ว

    Finally sir I got best explanation of stack sir my all douts are clear sir related to how to implement of stack 👍

  • @muthuselvambiga9378
    @muthuselvambiga9378 6 ปีที่แล้ว +1

    clear explanation.... after watching sir prgrm in naresh tech, i started loving prgrms... thanks ji..

  • @srivanikothavadla4606
    @srivanikothavadla4606 4 ปีที่แล้ว

    Your great sir .....every point is important clean and clear explanation..thank you soo much

  • @поджолес
    @поджолес 4 ปีที่แล้ว

    superb C master class worth every second.

  • @being1better801
    @being1better801 4 ปีที่แล้ว

    We are in safe hands.
    Srinivas sir is best for c language and DS in c language (as I have learned c from Srinivas sir and currently learning DS)

  • @MsMeghana16
    @MsMeghana16 4 ปีที่แล้ว

    Thanku sir. Your series of videos is highly useful to learn the whole concept in a short time.

  • @farmood100
    @farmood100 5 ปีที่แล้ว +6

    Sir , I am getting confusion at one point of this video for Push() function. actually you are getting the top value of stack into "ele" variable and you don't return the "ele" variable but you're returning the stack[top] at the last line. I think the "ele" variable have kept the Top value which need to be return from the Pop().
    Please response me .
    Thanks for sharing this video. really I m very happy to see this video and I have learnt a lot from your video. you are doing good Job . we all are appreciating to you.

  • @tanayganguly1251
    @tanayganguly1251 6 ปีที่แล้ว +8

    wow .love you man... this content is awesome

    • @shekhar7512
      @shekhar7512 6 ปีที่แล้ว +1

      super👏👏👏

  • @bigk2367
    @bigk2367 3 ปีที่แล้ว +1

    thank you so much sir for this great explanation literally you cleared every question. thank you so much..

  • @arjunkagwade330
    @arjunkagwade330 2 ปีที่แล้ว +1

    Great to understand the concept of memory deletion 🙂

  • @sandeepmishra5145
    @sandeepmishra5145 3 ปีที่แล้ว

    What a explanation. Very simple and in deep.

  • @mohitsingh5752
    @mohitsingh5752 4 ปีที่แล้ว

    Now I can visualize the working of stack in my mind .... Thank You Sir !!

  •  6 ปีที่แล้ว +21

    Is it a correct understanding when you are popping an element, you are not removing it per se, you are just returning the element and moving top var one down, would it be a more proper way to set the value as zero or something?
    Otherwise thanks for an outstanding lectures

    • @TheIndianshowstopper
      @TheIndianshowstopper 5 ปีที่แล้ว +7

      Yes, because this is static memory allocation. So, even if you pop an element, the memory space remains there. However, if it was a dynamic memory allocation we would've used realloc() to simply wipe out the memory space of the element we popped.

    • @KoushikVenkat7
      @KoushikVenkat7 3 ปีที่แล้ว +1

      @@TheIndianshowstopper So by wiping out with realloc(), you mean overwriting the memory space?

  • @goyaldeekshant
    @goyaldeekshant 4 ปีที่แล้ว +11

    Here is the complete code for the whole video:
    #include
    #define CAPACITY 8
    int stack[CAPACITY];
    int top = -1;
    int isempty() {
    if(top == -1)
    return 1;
    else
    return 0;
    }
    int isfull() {
    if(top == CAPACITY-1)
    return 1;
    else
    return 0;
    }
    int peek() {
    return stack[top];
    }
    int pop() {
    int ele;
    if(!isempty()) {
    ele = stack[top];
    top = top - 1;
    return ele;
    } else {
    printf("Could not retrieve data, Stack is empty.
    ");
    }
    }
    int push(int ele) {
    if(!isfull()) {
    top = top + 1;
    stack[top] = ele;
    } else {
    printf("Could not insert data, Stack is full.
    ");
    }
    }
    int main() {
    // push items on to the stack
    push(10);
    push(9);
    push(8);
    push(7);
    push(6);
    push(5);
    printf("Element at top of the stack: %d
    " ,peek());
    printf("Elements:
    ");
    // print stack data
    int i;
    for(i=0;i

  • @krishangparakh4583
    @krishangparakh4583 4 ปีที่แล้ว +1

    Happy Belated Teacher's Day to you sir!!! Thank you for explaining so beautifully!

  • @trendsetteravi
    @trendsetteravi 7 ปีที่แล้ว +5

    Superb explaination 👏👏👏

  • @sayalikoli2510
    @sayalikoli2510 7 ปีที่แล้ว +6

    Nice explanation Sir 👌👌👌

  • @Shivanarayanan-l3g
    @Shivanarayanan-l3g ปีที่แล้ว

    your teaching is awesome sir 👍👍

  • @aahatkhanna8205
    @aahatkhanna8205 4 ปีที่แล้ว

    Such a clear explanation!!!.....U got a subscriber today👍

  • @manojkumarnagudala3369
    @manojkumarnagudala3369 4 ปีที่แล้ว

    At 24:41 we are returning top and when top=0 ( or if the element itself is 0(zero), and we are returning that element). Then in that case too there will a problem in the main function which thinks that the stack is empty.

  • @saurabhdabhade5487
    @saurabhdabhade5487 5 ปีที่แล้ว

    Getting the knowledge in a rightfull way...#DATASTRUCTURE

  • @Nirmala448
    @Nirmala448 4 ปีที่แล้ว

    Simply superb, clear and awesome explanation sir

  • @majharshaikh6421
    @majharshaikh6421 4 ปีที่แล้ว

    i turn off my adblocker and watch lengthy annoying ads just to support your channel sir, thank you for your easy explanations!

  • @kirankumar-kb3tp
    @kirankumar-kb3tp 7 ปีที่แล้ว

    wow ! excellent explanation sir, regarding the not deleting just not pointing it....

  • @nikhilvijay6022
    @nikhilvijay6022 4 ปีที่แล้ว

    So nicely explained by you sir that the doubt which arose in mind about deletion of element was cleared in the video itself as if you knew this is gonna happen somehow.

  • @rammaheshwari3008
    @rammaheshwari3008 6 ปีที่แล้ว +1

    You are Great Sir , Amazing Lecture ❤👌

  • @sulagnapalit6031
    @sulagnapalit6031 6 ปีที่แล้ว

    Well explained specially about what exactly means to delete a data.

  • @surajdangi6492
    @surajdangi6492 4 ปีที่แล้ว

    sir you are a great teacher.

  • @rajkishore7864
    @rajkishore7864 7 ปีที่แล้ว +4

    Thank you for this wonderful lecture.

  • @navyakoppala4383
    @navyakoppala4383 5 ปีที่แล้ว

    Thank you very much sir.. very. Good explanation.clear understanding..thank you

  • @GhostNikki
    @GhostNikki 5 ปีที่แล้ว +9

    In pop() function you are returning the position. Not the element . if you are returning the position than what is the purpose of assigning the value to variable ele

  • @kumarik9027
    @kumarik9027 3 ปีที่แล้ว

    thank you soooo much....understood very clearly....thank u soo much

  • @ramar4210
    @ramar4210 6 ปีที่แล้ว

    Excellent teaching sir...god bless you...

  • @bimalmurali2781
    @bimalmurali2781 4 ปีที่แล้ว

    You are absolutely great sir.

  • @shivamvishwakarma2596
    @shivamvishwakarma2596 7 ปีที่แล้ว +1

    Brilliant explanation sir..thank you

  • @ghanchiimran6235
    @ghanchiimran6235 7 ปีที่แล้ว

    naresh sir thank u very much for your online video studiz keepet up sir thnqs

  • @amitkhare2013
    @amitkhare2013 7 ปีที่แล้ว +6

    Great explanation

  • @YugNirman15
    @YugNirman15 4 ปีที่แล้ว

    Very nice and clear explanation sir

  • @nawdeepkumar
    @nawdeepkumar 5 ปีที่แล้ว

    Awesome explanation
    Big fan of You sir..

  • @Mytechielife
    @Mytechielife 6 ปีที่แล้ว +3

    Great lecture thanks sir

  • @goyaldeekshant
    @goyaldeekshant 4 ปีที่แล้ว +2

    HERE IS THE COMPLETE CODE FOR PUSH OPERATION:
    #include
    #define CAPACITY 8
    int stack[CAPACITY];
    int top=-1;
    int isfull()
    {
    if(top==CAPACITY-1)
    return 1;
    else
    return 0;
    }
    int push(int ele)
    {
    if(isfull())
    {
    printf("stack is full
    ");
    }
    else
    {
    top=top+1;
    stack[top]=ele;
    printf("elements are: %d
    ",ele);
    }
    }
    int main()
    {
    push(10);
    push(9);
    push(8);
    push(7);
    push(6);
    push(5);
    push(4);
    push(3);
    push(2);
    push(1);
    return 0;
    }

  • @padmalayajena3593
    @padmalayajena3593 6 ปีที่แล้ว +12

    Sir in pop () you returned top value instead of the deleted value that was stored in ele.
    I watched that part twice to make sure If I was mistaken but sir I think you wrote it by mistake.
    Correct me if Im wrong.
    Thankyou sir. You are a source of light to my darkness 🌟
    Forever grateful.

    • @mangalprasad339
      @mangalprasad339 4 ปีที่แล้ว +1

      Yes I think it should be ele instead of top

    • @naseersk2952
      @naseersk2952 4 ปีที่แล้ว +2

      yha ur right it will return ele only, not top

    • @ubaidkhan1246
      @ubaidkhan1246 4 ปีที่แล้ว +2

      Yes you are right, and along with that , the value at TOP isn't actually popped from the stack,we're just decrementing the TOP instead.

    • @harshithagowda3707
      @harshithagowda3707 4 ปีที่แล้ว

      At what duration ?? Please mark

  • @prernaroy5423
    @prernaroy5423 6 ปีที่แล้ว +1

    sir itne acche se toh cls m v nhi smjhte h .....thnq sir

  • @kaustubh.sharma
    @kaustubh.sharma 5 ปีที่แล้ว

    Outstanding explanation Sir!

  • @mdafzalahmed4675
    @mdafzalahmed4675 5 ปีที่แล้ว

    Thank you NARESH TECHNOLOGIES

  • @tauseefqidwai6450
    @tauseefqidwai6450 5 ปีที่แล้ว +14

    In pop() function you are returning variable top instead of element. i think you should return ele. isn't it?

    • @amarjeetprasad5183
      @amarjeetprasad5183 5 ปีที่แล้ว +2

      yes, element will be return.

    • @skyleader5025
      @skyleader5025 3 ปีที่แล้ว

      27:00 please watch from here to clear why to return top.

  • @ben10fantastic31
    @ben10fantastic31 3 ปีที่แล้ว

    Excellent explanation sir

  • @bhargavnadipineni9354
    @bhargavnadipineni9354 3 ปีที่แล้ว +3

    Sir, in pop function , we have to return the "ele" na because ele is the top element and "top" is index

    • @someone-x64
      @someone-x64 3 ปีที่แล้ว +2

      Right I was wondering the same....🙃

  • @raghava8561
    @raghava8561 3 ปีที่แล้ว

    Thank you for the lecture..great work

  • @trendsetteravi
    @trendsetteravi 7 ปีที่แล้ว +1

    Super explaination sir 👏👏👏

  • @arunbandari8936
    @arunbandari8936 7 ปีที่แล้ว +18

    sir in pop() method you return top variable instead of ele variable...

    • @anubhavverma5817
      @anubhavverma5817 7 ปีที่แล้ว

      yes arun is right Mr.shrinivasn, kindly take care of that

  • @hey.mishaaa
    @hey.mishaaa 6 ปีที่แล้ว +3

    Totally awsomee sir

  • @being1better801
    @being1better801 4 ปีที่แล้ว

    Wonderful.
    Just great!!

  • @allyouinfotech7936
    @allyouinfotech7936 3 ปีที่แล้ว

    void main()
    {
    int n;
    printf("How Many Elements You want to store in array:");
    scanf("%d",&n);
    int a[n];
    for(i=0;i

  • @joshiji2430
    @joshiji2430 5 ปีที่แล้ว

    very nice explaination. thankyou sir

  • @ritikjain974
    @ritikjain974 4 ปีที่แล้ว

    It's Amazing do watch it..

  • @Satishkumar-kq4mh
    @Satishkumar-kq4mh 5 ปีที่แล้ว

    sir u r great
    very healpfull video

  • @sahilrajput3183
    @sahilrajput3183 6 ปีที่แล้ว +1

    Sir you are awesome..!

  • @ajiths1689
    @ajiths1689 6 ปีที่แล้ว +1

    there is some logic missing like tracking of "top" value in traverse method..... remaining everything is awesome thanks for teaching us

    • @NareshIT
      @NareshIT  6 ปีที่แล้ว +2

      Pls don't care about variables and follow the logic.

    • @ajiths1689
      @ajiths1689 6 ปีที่แล้ว

      Yeah ok

  • @pramodhjangam6767
    @pramodhjangam6767 5 ปีที่แล้ว +7

    Sir the thing is , in pop( ) ,you said if stack is empty it will return 1; and then after you concluded it with returning 0; i couldn't get that point clearly... please reply as soon as possible sir!

  • @ronint9455
    @ronint9455 6 ปีที่แล้ว +5

    Sir pop() function should return top element(ele) instead of top variable. Am I right??

  • @mohammed-i786
    @mohammed-i786 4 ปีที่แล้ว +1

    Sir we can use a variable inside of the big brackets of an array in C99. Such arrays are known as variable-length arrays.

  • @xkorv
    @xkorv 5 ปีที่แล้ว +1

    I have a question about Peek, isn't it a bad thing to return 0 when the stack is empty? What if we could expect 0 as a legitimate value in the stack?

  • @balveerkumarjanpal8098
    @balveerkumarjanpal8098 3 ปีที่แล้ว

    27:52 most important note

  • @helloworld-hv9oy
    @helloworld-hv9oy 3 ปีที่แล้ว

    Concepts clear!!!

  • @kavyabudige6226
    @kavyabudige6226 3 ปีที่แล้ว

    Thank you so much sir 🤗and please make a video on quick sort in data structures plz sir

  • @kajalmaurya4155
    @kajalmaurya4155 6 ปีที่แล้ว

    Very nice explanation sir. thank you

  • @satyam5075
    @satyam5075 2 ปีที่แล้ว

    Well explained sir....

  • @anithaajjada9987
    @anithaajjada9987 7 ปีที่แล้ว +3

    put videos on all sorting methods which are present in datastructures

  • @InDiAnAjOnEs0002
    @InDiAnAjOnEs0002 3 ปีที่แล้ว

    Sir I cannot thank you enough, would love to meet you sometime.

  • @kaustubh.sharma
    @kaustubh.sharma 5 ปีที่แล้ว

    Sir can we reterive or recover that unpointed/garbage value if it's not overwritten by another new data? 28:00

  • @prafulrane9037
    @prafulrane9037 6 ปีที่แล้ว

    Awesome sirjee hats off

  • @mahimsd7645
    @mahimsd7645 5 ปีที่แล้ว

    Beautifully Explained !!!!!
    Gr8 work SIR

  • @dmankhatri6663
    @dmankhatri6663 4 ปีที่แล้ว

    sir your great.Thank you

  • @erigelavani4162
    @erigelavani4162 5 ปีที่แล้ว +1

    sir in case of pop , as you said earlier if there are elements in the stack should consider return 0 but you consider is empty as return 0 ,I thought you wrote by mistake sir can you please tell

  • @henrymideko74
    @henrymideko74 5 ปีที่แล้ว

    ohh thank u sir this is in the pace n style have always prayed for.

  • @VarunSharma-tt6dc
    @VarunSharma-tt6dc 4 ปีที่แล้ว +1

    Thank you so much for the whole data structure series. It's great stuff. I really like the outro music, can someone tell me the name of the music or a link to it, would be really helpful.

    • @codingguru4865
      @codingguru4865 4 ปีที่แล้ว

      Hi Varun,
      Check this
      Full Playlist of Data Structure
      Explained very easily
      th-cam.com/video/gh9siMkdLkM/w-d-xo.html

  • @Rishav_Raj17
    @Rishav_Raj17 4 ปีที่แล้ว

    Love in with your content

  • @sabbyluthra3782
    @sabbyluthra3782 4 ปีที่แล้ว

    at 8:57 he says in dynamic memory allocation there is no memory to store further, but its dynamic it can increase its memory so how can be full. please answer.

  • @adarshany4938
    @adarshany4938 5 ปีที่แล้ว +1

    Sir please explain all lab programmes based on dsa according to vtu please explain all programmes

  • @mikustudy3957
    @mikustudy3957 5 ปีที่แล้ว

    Thank you so much Sir 🙏

  • @chippi6999
    @chippi6999 6 ปีที่แล้ว +2

    Sir, ele has to be returned right? Inside the else of the pop function.

  • @gandhiambarukhana2328
    @gandhiambarukhana2328 8 ปีที่แล้ว +2

    super explanation

  • @highwaygroup2821
    @highwaygroup2821 3 ปีที่แล้ว

    While traversing, should the function return elements in LIFO order (as this is a stack) or FIFO order? Here FIFO is shown but LIFO is a better fit right?

  • @brihaspatiangiras9081
    @brihaspatiangiras9081 3 ปีที่แล้ว

    thank you sir for helping

  • @kirandhedhi2612
    @kirandhedhi2612 7 ปีที่แล้ว +3

    sir , where is the dynamic stack creation video?

  • @kumarashutosh6402
    @kumarashutosh6402 5 ปีที่แล้ว

    why we can't use variables in square breackets without making it macro which has shown in 2:59.

  • @junaidrashid6147
    @junaidrashid6147 3 ปีที่แล้ว

    God bless u sir

  • @kulbhushanshandilaya6014
    @kulbhushanshandilaya6014 ปีที่แล้ว

    Sir please help me out,
    In the pop() method the we are assinging the top element value to the variable "ele" { ele = stack[top] } , and after which we are reducing the top value but still the value that was previously was at top is not deleted [ i.e the value of "ele" is still in the array at top +1 position].

  • @ravikantbhushannavar9007
    @ravikantbhushannavar9007 4 ปีที่แล้ว

    Super bro🔥🔥👌

  • @saisharannune
    @saisharannune 6 ปีที่แล้ว

    how ele is taken i mean scanf("%d",ele) into stack at 15:15(time)
    ante ela tiskuntam manam ele value ni stack lopaliki