You are on page 1of 3
savant ‘Stack| KVSeContets in bg sah reset i) Spa a, ipitasecortontsinindephnstack = Compute Fundarenat || Stack XULCS- UNIT Sore Concepts Stack is one of the important data structures that || XIE CS - UNIT IV. but Functions Hnoludecctype b> Toone Are |__OneDmmensionalAray || #clefine MAXSIZE 3 “Appeation of Bookan aint main () ee. a = void push (int); Techeoboks out = Sa =< cin>>num; Netivorks ein>>num; ‘Web Servis. push (num) ¢ item=pop() coutecendi Ant pop() 1B savant IripRasecontentsinindexphnstack ‘Stack| KVSeContonts in i coutccendic<"STACK EMPTY"; return 5; } else i tack (topl , return ay > Stack implementation as Linked List Hnclude #include #nclude struct node ‘ int data node *Links de ade “tops int main() ‘ void push (int): void pop () veid display (); int wish, mun,will,ay wish = 1} coutc<"Program for Stack as Linked List deno. while (wish == 1) ‘ coutscendic<"Main Menu \nl.znter data in stack\n2.Delete from stack\n3. Display Stack\n0. For Exit": cindowilt switen (will) ‘ ease 1: coutccendicc"enter the data": cin>>num; push (num) 7 break: case 2: pop) break: case 3: display (): break: case 0: exit (0): : cout>wish? ) return 0; d //TATS FUNCTION INSERT NODE IN THE TOP OF THE STACK void push (iat y) ‘ node tx: new node() xodata = yr xoplink = top: top = x ) //THIS EUNCTION REMOVES TOP NODE FROM THE STACK AND RETURNS 17S VALUE void pop() ‘ int ar Af (top=-NULL) ‘ cout<<"STACK EMPTY... return ) ‘ antop->datay coutecend:<<"The value at the top of stack is "<iink: ) ) /TATS FUNCTION DISPLAY ELEMENTS OF STACK void dispzay() savant ‘Stack| KVSeContets in ‘ nede * Lemp: temp = tops if (top == NULL) ‘ coutdataccend? + temp-temp=>1ink; ) 2017 KVSeContentsin. \Webste designed and maintained by SANJEEV SHARMA PGT (Computer Science) Kendriya Vidyalaya Pabimpur ‘(Chandigarh Region) INDIA. hipitasecortontsinindexphnstack 38

You might also like