Results 1 to 4 of 4

Thread: What do you mean by stacks in Data structure

  1. #1
    Join Date
    Dec 2010
    Posts
    19

    What do you mean by stacks in Data structure

    Hello friends I wanted to know the concept of stacks in data structure. I am not able to understand this term as its bit difficult to understand. I referred many books but still I am not cleared with concept. I also wanted to know what LIFO is. Is it a concept in stack or what? I also wanted to know some terms such as POP and Push. I come across such terms when 9i was trying to clear my concept with different books available for data structure but it did not helped me. If anyone is having any information or knowledge then please let me know as soon as possible.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: What do you mean by stacks in Data structure

    A stack is a data structure in which addition of new element or deletion of an existing element always takes place at the same end. This end is known as top of the stack. This situation can be compared to a stack of plates in a cafeteria where every new plate added is at the top and every plate is taken off the top. Stack always follows LIFO structure where data inserted last will be taken out first. If the elements are added to the stack it grows at one end, and if elements are removed it shrinks. The operation of insertion of element and deletion of element from the stack are given special names. When the element is added to the stack, the operation is called PUSH. When the element is removed from the stack is called POP.

  3. #3
    Join Date
    Apr 2009
    Posts
    488

    Re: What do you mean by stacks in Data structure

    Stack contains an ordered collection of element. An array is used to store ordered list of elements .Hence it would be very easy to manage a stack if we represent it using an array. However the problem with array is that we are require to declare the size of array before using it in a program. It means the size of array is fixed. Stack on the other hand does not have any fixed size. You must be aware that stack does not have any appropriate fixed size. So, it could not be defined in a proper size.

  4. #4
    Join Date
    May 2009
    Posts
    637

    Re: What do you mean by stacks in Data structure

    Code:
    Void push( int data)
    1  check tos 
    2.      if tos >= 9 
    3.         print: stack overflow
    4        else
    5             ++tos                          // increment tos;
     6     store data  AA[tos]=data            // store data
    
    
    int pop()
    1.	check tos  
    2.	 if tos<=0
    3.	      print :stack underflow
    4.	      return 0
    5.	else
    6.	     data= AA[tos]                     //retrieve data
    7.	     - –tos                                  //decrement tos
            8          return data
    The above Algorithm is for the stacks in data structure. In the above algorithm you will find that it is been divided into two parts i.e Push and Pop. If you will notice then you will find that the first three steps in both the algorithm are same. Well, now the question arises in your mind how come it is same? Well, this is the basic step to know whether the stack is overflow or not.

Similar Threads

  1. What is linear search in data structure?
    By Venugopala in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 08:11 AM
  2. What is bubble sort in data structure
    By punguzhali in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 03:49 AM
  3. What is the use of insertion sort in data structure?
    By Venugopala in forum Software Development
    Replies: 3
    Last Post: 04-01-2011, 02:41 AM
  4. What is the binary search in data structure
    By Alibamu in forum Software Development
    Replies: 3
    Last Post: 03-01-2011, 08:42 AM
  5. Choice of data structure
    By Hashim in forum Software Development
    Replies: 5
    Last Post: 02-11-2009, 07:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,174,304.58106 seconds with 16 queries