JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Array-implementation-of-Stack. Show all posts
Showing posts with label Array-implementation-of-Stack. Show all posts

Explain Array implementation of Stack?

10:41 PM
Array implementation of Stack In array implementation, the stack is formed by using the array. All the operations regarding the stack are performed using arrays. Lets see how each operation can be implemented on the stack using array data structure. Adding an element onto the stack (push operation) Adding an element into the top of the stack is referred to as push operation. Push operation involves following two steps. Increment the variable Top so that it can now refere to the next memory location. Add element at the position of incremented top. This is referred to as adding new element at the top of the stack. Stack is overflown when we try to insert an element into a completely filled stack therefore, our main function must always avoid stack overflow condition. Algorithm: begin         if  top = n then stack full        top = top +  1 ...

.