announcements reminder candidates on campus in next few
play

Announcements Reminder: Candidates on campus in next few weeks - PowerPoint PPT Presentation

Announcements Reminder: Candidates on campus in next few weeks Day-by-day schedule may change, so check often Thursday Extra: Today @ 4:00 Tenure-track candidate #1 Kevin Angstadt, U. of Michigan All Computers Great and Small: Supporting


  1. Announcements Reminder: Candidates on campus in next few weeks Day-by-day schedule may change, so check often Thursday Extra: Today @ 4:00 Tenure-track candidate #1 Kevin Angstadt, U. of Michigan All Computers Great and Small: Supporting and Security the Systems of Tomorrow

  2. Announcements Stacks and Queues Two levels of interest Conceptual: FIFO or FILO/LIFO Implementation: Either arrays or linked lists Both widely used in practice! Stacks: piles of materials (e.g.,on a desk) constrained run-time stack Queues: lines in stores/airports jobs sent to printer (if strict FIFO) Questions; Clicker Questions

  3. Assume: add means either push or enqueue remove means either pop or dequeue get means either top or front Notes: • most stack ADTs include top • queue ADTs may or may not include front

  4. For which ADTs can a get operation be implemented simply from add and remove? (A simple extra variable might be used, but not an extra array, linked list, or other structure.) A. Stack B. Queue C. Both D. Neither

  5. Assume: • add means either push or enqueue • remove means either pop or dequeue • get means either top or front The program prints "Red". Consider the program: Container must be a ... Container a; add(a,"Orange"); A.Stack add(a,"Red"); B.Queue add(a,"Green"); C.Neither remove(a); D.Impossible to tell add(a,"Blue"); printf("%s", get(a));

  6. Assume: • add means either push or enqueue • remove means either pop or dequeue • get means either top or front The program prints Consider the program: "Dopey". Container must be a ... Container b; add(b,"Happy"); remove(b); A.Stack add(b,"Sneezy"); B.Queue add(b,"Dopey"); C.Neither add(b,"Grumpy"); D.Impossible to tell printf("%s", get(b));

  7. Assume: • add means either push or enqueue • remove means either pop or dequeue • get means either top or front Consider the program: The program prints "Helium". Container must be a ... Container c; add(c,"Helium"); A.Stack add(c,"Neon"); B.Queue remove(c); C.Neither printf("%s", get(c)); D.Impossible to tell

  8. Today's Project: Underlying questions: When using a stack to store a string, • what should be stored on the stack as part of push? • a pointer • to the original string • to a copy of the string • a copy of the string • what pointer should be returned as part of pop? • a pointer to the original • a pointer to a copy on the run-time stack • a pointer to a copy in dynamic memory Approach of project: • four different implementations (all callable by same main) • each implementation yields different output • practical question: why: • why does each approach produce its output? • explain carefully!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend