Stack |
Array |
---|
It may contain different data types. | It contains the same data types. |
It is a linear data structure in which insertion (PUSH) and deletion (POP) can be done only from only one end ie Top. | It is a linear Data Structure in which insertion and deletion can take place in any position. |
It is a static object. | It is a dynamic object. |
In a stack, there’s no random-access operation; there are only Push and Pop. | Elements can be retrieved randomly in an array. |
It follows LIFO or FILO order. | Data can be entered at any position and be read from any position. |
The element that is first entered would be the last removed. | The element can be entered or removed in any order. |
![Data Structures - Stack Vs Array Stack](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMTYiIGhlaWdodD0iMjMwIiB2aWV3Qm94PSIwIDAgMzE2IDIzMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgc3R5bGU9ImZpbGw6I2NmZDRkYjtmaWxsLW9wYWNpdHk6IDAuMTsiLz48L3N2Zz4=) | Stack |
| ![Data Structures - Stack Vs Array array in c](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMTY3IiB2aWV3Qm94PSIwIDAgMjAwIDE2NyI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgc3R5bGU9ImZpbGw6I2NmZDRkYjtmaWxsLW9wYWNpdHk6IDAuMTsiLz48L3N2Zz4=) | Array |
|