Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

* Scripting Languages
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* aktuális (2023/24/2)
* 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 ]

20141125a

Implement a Stack class

Write a class that implements the stack data structure.

We want to use the class the following way:

s = Stack()       # create an empty stack
print(s)          # [
print(s.empty())  # True
s.push(1)
s.push(4)
s.push(5)
print(s)          # [1 4 5
print(s.size())   # 3
print(s.empty())  # False
x = s.pop()
print(x)          # 5
print(s)          # [1 4
s.pop()
s.pop()           # now it's empty
x = s.pop()
print(x)          # None (means that we wanted to take an element out of an empty stack)

Queue data structure

Now write a class that implements the queue data structure. First, think over what operations a queue should support. Then, write some examples (similarly to the code above), and finally implement the Queue class.

The implementation doesn't have to be efficient (yet).

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 2017 August 03, 23:33