, , , ,

What is the difference between array PUSH and POP? explain with example

Posted by

Array Push or Pop

Stack: A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO principle (Last In First Out), i.e., the element inserted at the last will be the first element to come out. The insertion of an element into a stack is called a push operation, and the deletion of an element from the stack is called a pop operation. In stack, we always keep track of the last element present in the list with a pointer called top.

Array: An array is a collection of data items stored at contiguous memory locations. The concept is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).

guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x