lec0304-trees - Todays announcements: MP4 available, EC due...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
MP4 available, EC due 3/4, due 3/11, 11:59p. Exam 1 returned in section this week. Today: Queues Trees Today’s announcements:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Queue—linked memory based implementation: template<class T> class Queue { public: // ctors dtor bool empty() const; void enqueue(const T & e); T dequeue(); private: struct queueNode { T data; queueNode * next; // +ctor }; queueNode * entry; queueNode * exit; int size; }; 8 3 6 4 Which pointer is “entry” and which is “exit”? What is running time of enqueue? What is running time of dequeue?
Background image of page 2
Queue array based implementation: template<class T> class Queue { public: Queue(); ~Queue(); // etc. bool empty() const; void enqueue(const T & e); T dequeue(); private: int capacity; int size; T * items; // some other stuff… }; template<class T> Queue<T>::Queue(){ capacity = 8; size = 0; items = new T[capacity]; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Queue array based implementation: template<class T> class Queue { public: Queue(); ~Queue(); // etc. bool empty() const;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

lec0304-trees - Todays announcements: MP4 available, EC due...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online