cs261 data structures
play

CS261 Data Structures Bags, Queues and Stacks Bag Problem : Need - PowerPoint PPT Presentation

CS261 Data Structures Bags, Queues and Stacks Bag Problem : Need to maintain an unordered collection of elements Operations : Insert Remove Contains Specific requirements : E.g., Time of insertion into bag is important


  1. CS261 Data Structures Bags, Queues and Stacks

  2. Bag • Problem : Need to maintain an unordered collection of elements • Operations : – Insert – Remove – Contains • Specific requirements : – E.g., Time of insertion into bag is important

  3. Bag Interface • Provide functions for operations addBag (container, value) testBag (container, value) removeBag (container, value) sizeBag (container, value)

  4. Queue • Problem : Maintain a collection of elements in First-In, First-Out format • Operations : – Add an element to Queue – Remove an element from Queue – Read the front element of Queue – Contains

  5. Stack • Problem : Maintain a collection of elements in Last-In, First-Out format • Operations : – Add an element to Stack – Remove an element from Stack – Read the top element of Stack – Contains

  6. Difference between ADT and Implementation • Stack ADT – Can be implemented using dynamic array – Linked list – … • Encapsulation idea – User don’t care what’s implemented – Just tell user how fast is each operation

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