answersLogoWhite

0


Best Answer

Array

It is a data structure that has group of same type elements in linear sequence. It requires continuous memory block to store it. Elements in Array is accessed by index. Array does not have any predefined functions.

Stack

It is a data structure that is a list of ordered elements. In most of the programming languages and computer architecture stack has limitation in size. Elements in stack might not be the same type. Stack has predefined functions: POP (get top element), PUSH (put element on top) and it works by LIFO(Last In First Out) principle. Elements from stack are removed in reverse order to the order of their addition.

Example:

POP 1;

POP 2;

POP 3;

Stack: (top) 3 2 1 (bottom)

PUSH

PUSH

PUSH

We get elements in this order: 3 2 1

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the main difference between stack and array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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?


How you generate power set using c program?

#include <iostream> void printSet(int array[],int size){ int i; for (i=1;i<=size;i++) std::cout << array[i] << " "; std::cout << std::endl; return; } void printPowerset (int n){ int stack[10],k; stack[0]=0; /* 0 is not considered as part of the set */ k = 0; while(1){ if (stack[k]<n){ stack[k+1] = stack[k] + 1; k++; } else{ stack[k-1]++; k--; } if (k==0) break; printSet(stack,k); } return; } int main(){ printPowerset(4); return 0; }


What is the connection of an array in data structure?

Both are aggregates of elements of the same type. The main difference is that an array allocates elements contiguously thus there is no need to maintain links between the elements; each can be addressed by its offset from the start of the array. A structure, however, allocates elements non-contiguously, and must maintain links (pointers or references) within the elements in order to navigate from one element to the next.


Similarities between stack n queue?

Abey kaminey, agar main jaanta to tere se puchhne jata.


What are difference between grade a b and c material?

The main difference is in between grade A,B & C IS THE CARBON CONTAIN OF THE MATERIALS.

Related questions

Main difference between Array List and Vector in Java?

List is not sync'd as a vector is.


What is the difference between an array element and a variable?

Array elements are all members of the same variable, indexed in a logical manner. variables are distinct objects which must be referred to distinctly. The main functional difference is that a program can iterate over an array without the programmer knowing the original size of the array or explicitly which member to access.


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?


What is the difference between polyethylene and polyester?

what is the main difference between polyethylene and polyesters what is the main difference between polyethylene and polyesters


How you generate power set using c program?

#include <iostream> void printSet(int array[],int size){ int i; for (i=1;i<=size;i++) std::cout << array[i] << " "; std::cout << std::endl; return; } void printPowerset (int n){ int stack[10],k; stack[0]=0; /* 0 is not considered as part of the set */ k = 0; while(1){ if (stack[k]<n){ stack[k+1] = stack[k] + 1; k++; } else{ stack[k-1]++; k--; } if (k==0) break; printSet(stack,k); } return; } int main(){ printPowerset(4); return 0; }


What is the main difference between animation and simulation?

There is no difference.


What is the main difference between compaction and consolidation?

difference between campaction and consolition


What are the main difference between communicating with adults and children?

what are the main difference between communicating with adults and communicating with children


The main difference between amino acids is there?

What? Speak proper english, please. The main difference between amino acids and what?


What is the main difference between Kenya and Egypt?

there is one hour difference


What is the connection of an array in data structure?

Both are aggregates of elements of the same type. The main difference is that an array allocates elements contiguously thus there is no need to maintain links between the elements; each can be addressed by its offset from the start of the array. A structure, however, allocates elements non-contiguously, and must maintain links (pointers or references) within the elements in order to navigate from one element to the next.


What is the main difference between V and IV as cadence chords?

Whats the main difference between V and IV as cadence chords?