Stack : ========== Stack follows the principal of Last in First out Shortened it will be called as LIFO (Last in First Out) ======================================================== Famous examples are 1. watsapp chat history 2. watsapp status history 3. In school days student note books ======================================================= In technical way recusrsion follows stack calling functions in a chain way follows stack principal Now we need to replicate stack functionality : =============================================== using array we need to replicate stack functionalitu 8.21 to 8.30 Push pop peek getting peek element ================================= // Online Java Compiler // Use this editor to write, compile and run your Java code online import java.util.*; class Main { static int top =-1; static int arr[]=new int[5]; public static void main(String[] args) { System.out.println("Try programiz.pro"); while(true){ int opt=new Scanner(System.in).nextInt(); switch(opt){ case 1: push(10); break; case 2: pop(); break; case 3: display(); break; } } } static void push(int x){ top++; arr[top]=x; } static int pop(){ int x= arr[top]; top--; return x; } static void display(){ for(int i=top;i>=0;i--){ System.out.print(arr[i]+" "); } } } ========================================================== Queue: =========== Queue follows principal first in first out Can you give some practical examples of Queue text messages information will go in packets Booked movie tickets at cinema Hall ========================================================== Prcatical implemenation : ================================ 1.Enque 2.Deque 3.display ================================