answersLogoWhite

0

What are the types of stack?

User Avatar

Anonymous

9y ago
Updated: 8/18/2019

There is only one type of stack, but there are three different ways to implement one. The first is to use a fixed-length array. This limits the number of elements that may be pushed onto the stack. Performance is high (compared to all other implementations), however unused elements waste memory. The second is to use a variable-length array. This makes better use of memory, allocating new memory as and when required. However, a re-allocation can occasionally result in the entire array being moved to new memory, which can impact upon performance due to the need to copy every element in the array. This can be alleviated by allocating more memory than is actually needed during each re-allocation, however this will result in wasted memory when the stack is under-used. Shrinking the array will help recover unused memory but, as a general rule, it's best not to shrink an array after it has been increased in size. The final method is to use a linked list. This has the benefit of using only as much memory as required with a one-word-per-element overhead. However, due to the need to allocate and release memory as individual elements are pushed and popped, linked lists offer the worst performance.

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

How many different stack styems are there?

There are two types of plumbing stacks: A stack vent and a soil or waste stack.


What are the different types of crafts that can be created using a variety of materials in a craft stack?

The different types of crafts that can be created using a variety of materials in a craft stack include paper crafts, fabric crafts, jewelry making, woodworking, and clay modeling.


Have your units open ranks and stack arms are all examples of which types of orders in a military drill?

Directive .


What is the difference between a queue and a stack with example?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack. The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. types of queues : circular, linear, double ended and priority


What types of questions can be asked on the Skeptics Stack Exchange platform?

On the Skeptics Stack Exchange platform, users can ask questions that seek evidence-based answers to debunk myths, verify claims, and challenge popular beliefs.


How do you get sweet stack on Kingdom Hearts Birth by Sleep?

You have to make all seven types of ice creams in Disney Town.


How is a stack stump or caves formed?

A stack is formed when the roof of a sea cave collapses, leaving a pillar of rock separate from the mainland. Stumps are the remnants of a stack that has eroded further causing it to collapse. Caves are formed by the erosion of coastal rock by the action of waves, often in softer rock types that are easily worn away.


What is implicit stack?

A stack created by the user or a programmer is an implicit stack


Is stack a linear data structure?

Yes. All object on a stack must be of the same type. However, the type may be a base class in which case all objects on the stack must either be of that type or be derived from that type. That is, if a circle, triangle and rectangle class are all derived from a common shape class, a stack of shapes would allow instances of all four types because they are all a type of shape.


What is the function of a stack pointer?

Stack pointer points to the topmost / most recently referenced location on the stack; - Nutan


How does the net framework manage the storage of data types?

The .NET Framework manages the storage of data types through a combination of value types and reference types. Value types, such as integers and structures, are stored directly on the stack, whereas reference types, like classes and arrays, are stored on the heap, with references to their memory locations held on the stack. The Common Language Runtime (CLR) handles memory allocation and garbage collection, ensuring efficient memory usage and cleanup of unused objects. This structured approach allows for type safety and optimized performance in applications.


Pseudo-code for stack operation?

Here's a simple pseudo-code for basic stack operations: initialize stack push(value): if stack is full: print "Stack Overflow" else: stack[top] = value top = top + 1 pop(): if stack is empty: print "Stack Underflow" return None else: top = top - 1 return stack[top] peek(): if stack is empty: print "Stack is empty" return None else: return stack[top - 1] This pseudo-code includes functions for pushing a value onto the stack, popping a value from the stack, and peeking at the top value without removing it.