Algorithm For Stack Operations Code