answersLogoWhite

0


Best Answer

Arrays are beneficial whenever you need constant-time, random-access to any element within a set of data and the number of elements doesn't change too much (enlarging an array may require the entire array be copied to a larger block of free memory, which is expensive in terms of performance). Linked lists are beneficial when the number of elements is highly variable and you also need constant time access to the head (as per a stack) or both the head and tail (as per a queue). Neither a queue nor a stack requires any traversal whatsoever, so the lack of random access is immaterial. If a set of data is variable and must remain in sorted order (such as a priority queue), then a heap or self-balancing binary tree is the most efficient structure to use.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why are the array and linked list used as stack queue and others?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the different between stack and queue?

A stack is generally First In, Last Out, and a queue is First In First Out.Item can be added or removed only at one end in stack and in a queue insertion at the rear and deletion from the front.The basic operation of stack are 'push' and 'pop', on other hand of queue are 'enque' and 'dequeue'.


Data structure algorithms using C?

array,linklist,queue,stack,tree,graph etc...


Is it possible to implement stack and queues using linkes list?

Yes it is possible to implement stack and queue using linked list


How do you implement stack without array?

Stacks are often implemented using the same node structure as a linked list.


What are the the two ways in representing the stack?

one-dimensional array, and doubly-linked list.


What is the meaning of a stack overflow?

A stack overflow is a programming term used to identify when a function tries to access memory from a stack that does not exist. A stack, such as a queue or array, contains a limited number of memory spaces set aside when it is created. For example, if an array has 8 objects in it and a function tried to access an item at slot nine, which doesn't exist, it would cause a stack overflow.


What are the disadvantage of array implementation of stack?

Some immediate disadvantages:You'll have dead space in the array (entries which aren't currently used for items) taking up memoryYou'll have to keep track of the free entries - after a few insertions and deletions, these free entries could be anywhere.Using an array will impose an upper limit on the size of the linked list.


Why does LIFO order follows in stack and why does FIFO order follows in queue?

LIFO and stack are synonyms, so are FIFO and queue.


What is difference between stack snd queue?

In stack , the object which is last in will be first out (LIFO), whereas in queue the object which is first in will be first out (FIFO).


How does a linked list differ from stack and queue?

A linked list is a data structure that allows bi-directional traversal with constant-time access to both the head and the tail of the list. Elements may be pushed and popped from anywhere in the list. A stack is a structure where elements are pushed and popped only at the head of the stack. A stack is typically implemented using an array (either fixed-length or variable-length) where elements are pushed and popped from the end of the array (you need to keep track of where the last-used element is). However, a stack can also be implemented as a singly-linked list, pushing and popping at the head of the list. Stacks generally do not allow traversal of the elements.


What is the Data structures used for stack?

A stack is a linear last-in first-out list type data structure. Several implementations are possible. Two examples are the array and the linked list. The array is quick, but is limited in size. The linked list requires overhead to allocate, link, unlink, and deallocate, but (except for total available memory) is not limited in size. One compromise might be a linked list of arrays. Another compromise might be to not necessarily unlink and delete when an element is popped off the stack.


What is the difference between stack and array?

Briefly, there are two main differences between an array and a stack. Firstly, an array can be multi-dimensional, while a stack is strictly one-dimensional. Secondly, an array allows direct access to any of its elements, whereas with a stack, only the 'top' element is directly accessible; to access other elements of a stack, you must go through them in order, until you get to the one you want. I hope this answered your question. OK?