Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What do you mean by stacks in Data structure

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 04-01-2011
Member
 
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.

Reply With Quote
  #2  
Old 04-01-2011
Member
 
Join Date: Apr 2009
Posts: 567
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.
Reply With Quote
  #3  
Old 04-01-2011
Member
 
Join Date: Apr 2009
Posts: 484
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.
Reply With Quote
  #4  
Old 04-01-2011
Member
 
Join Date: May 2009
Posts: 620
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What do you mean by stacks in Data structure"
Thread Thread Starter Forum Replies Last Post
What is linear search in data structure? Venugopala Software Development 3 04-01-2011 08:11 AM
What is bubble sort in data structure punguzhali Software Development 3 04-01-2011 03:49 AM
What is the use of insertion sort in data structure? Venugopala Software Development 3 04-01-2011 02:41 AM
What is the binary search in data structure Alibamu Software Development 3 03-01-2011 08:42 AM
Choice of data structure Hashim Software Development 5 02-11-2009 07:27 PM


All times are GMT +5.5. The time now is 09:04 PM.