Oktatás * Programozás 2 * Szkriptnyelvek * levelezősök Félévek Linkek * kalendárium |
EnPy3 /
20141125aImplement 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 The implementation doesn't have to be efficient (yet). |
Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |