Recent Changes - Search:

Oktatás

* Programozás 2
  + feladatsor
  + C feladatsor
  + Python feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

* levelezősök
  + Adator. prog.
  + feladatsor
  + quick link

teaching assets


Félévek

* 2024/25/1
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

20130325a

Queue with two stacks

Write a MyQueue class, which implements a queue data structure using two stacks internally!

The class should implement the following operations:

  • pushright: append to the end of the queue
  • popleft: return the first element of the queue (and remove it from the queue)
  • empty: Is the queue empty?
  • size: number of elements in the queue

Note

For the internal stacks, you can use your own Stack implementation!

Bonus point

The number of data moves between the stacks can be reduced. If you figure out how and implement it, then you get +1 extra point. A little help: when are there unnecessary data moves?

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2021 April 26, 21:10