У нас вы можете посмотреть бесплатно Implement Stack by using Queue (with Example) или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
This lecture explains how to implement STACK by using two Queues by using a very simple example. I have also discussed 2 methods to do it and have explained the circumstances of using each method. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :) ALGO:- 1. By making PUSH costly push(s, x) // x is the element to be pushed and s is stack 1) Enqueue x to q2 2) One by one dequeue everything from q1 and enqueue to q2. 3) Swap the names of q1 and q2 // Swapping of names is done to avoid one more movement of all elements // from q2 to q1. pop(s) 1) Dequeue an item from q1 and return it. CODE LINK: https://drive.google.com/open?id=1Le5... 2. By making POP costly push(s, x) 1) Enqueue x to q1 (assuming size of q1 is unlimited). pop(s) 1) One by one dequeue everything except the last element from q1 and enqueue to q2. 2) Dequeue the last item of q1, the dequeued item is result, store it. 3) Swap the names of q1 and q2 4) Return the item stored in step 2. // Swapping of names is done to avoid one more movement of all elements // from q2 to q1. CODE LINK: https://drive.google.com/open?id=17fN...