![]() ![]() ![]() The Push() function is used to insert data, but before inserting we need to check wheteher the stack is full or not because if the stack is already full we cannot carry out the push operation this is also called as stack overflow, else if there's space insert the new element and increment the top pointer. functions/operations performed by a stackįirst we need learn two important functions namely push and pop to insert and remove data from the stack Push () In the code below, first we create a class Stack in which we'll add an array to store the data and then a pointer top which helps us to interact and perform various functions of a stack altogether class Stack To implement stack using array we need an array of required size and top pointer to insert/delete data from the stack and by default top=-1 i.e the stack is empty.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |