Asked By
bea56
30 points
N/A
Posted on - 07/21/2011
HI everyone!
Can anybody will tell me detail description on "THE MAIN DIFFERENCES BETWEEN STACKS AND LINKED LIST?
Which method is more efficient?
When and where we will decide while designing code that which method should be used to run the code more efficiently and we will get the required result?
Differences between stacks and linked list
In programming, a list is a finite or fixed ordered series of data items called “elements.” The list is “ordered” because every element has their individual position or place in the list. The linked list you are saying is one of its two implementations: the array-based list and the linked list.
For the pros, array-based list offers no wasted space for every element while with linked list, it only need space for objects that are actually on the list. For the cons, array-based list should have a pre-determined size and can have wasted space due to empty slots on the list.
While with linked list, it has an overhead for links or an extra pointer that is added to every node. A stack is a LIFO list or (Last-In, First-Out). It is a list-like structure where elements can be removed or inserted from only one end (last-in, first-out). It is easier to implement and more efficient but less flexible than lists.
With stack, elements are pushed into the stack instead of getting inserted.