Abstract Data Types


Published on

Definition and introduction to Abstract Data Type.

Teaching material for the course of "Tecniche di Programmazione" at Politecnico di Torino in year 2012/2013. More information: http://bit.ly/tecn-progr

Published in: Education, Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Abstract Data Types

  1. 1. ADTAbstract Data Type
  2. 2. Abstract Data TypeA.A. 2012/2013Tecniche di programmazione2ADTs store data and allow various operations on thedata to access and change itADTs are mathematical modelsADTs are extremely useful when designing a complexalgorithmsADTs are not classes (well, not quite)
  3. 3. Abstract Data TypeA.A. 2012/2013Tecniche di programmazione3ADTs are “abstract” because they specify the operationsof the data structure and leave implementation details tolaterMore similar to “abstract classes” or “interfaces”(whether the language supports them)Note: Not all implementationdetails can be deferred!
  4. 4. Why study ADTs?A.A. 2012/2013Tecniche di programmazione4How many of you will actually go out and create your own ADTfrom scratch?Different ADTs, each one with its own pros and consPicking the right one for the job is an important step in design!Get your data structures correct first, and the rest of theprogram will write itselfDavid S. Johnson(winner of Knuth’s Prize in 2010)
  5. 5. Why study ADTs?A.A. 2012/2013Tecniche di programmazione5The goal is to learnhow to learn how touse and create ADTs
  6. 6. Built-in ADTA.A. 2012/2013Tecniche di programmazione6High level languages often provide built in ADTs. E.g.:StandardTemplate Library (C++)Java Collections Framework (Java)
  7. 7. Common GroundA.A. 2012/2013Tecniche di programmazione7Almost every ADT provide a way toadd an itemremove an itemfind, retrieve, or access an itemMost Collection ADTs provide more possibilitiescheck whether the collection is emptymake the collection emptygive me a subset of the collection…
  8. 8. A very simple ADT: Santa’s SackA.A. 2012/2013Tecniche di programmazione8
  9. 9. Sack’s OperationsA.A. 2012/2013Tecniche di programmazione9insertToy(toy)Insert a toy in the sackDuplicates are – obviously – allowedextractToy(toy)Remove the given toy from the sack… and make a children happycountToys()Count how many toys actually arestored in the sack
  10. 10. Santa’s SackA.A. 2012/2013Tecniche di programmazione10insertToy( )extractToy( )countToys()
  11. 11. Santa’s Sack (more efficient)A.A. 2012/2013Tecniche di programmazione11insertToy( )extractToy( )countToys()keep track ofthe number ofobjects
  12. 12. The lessonA.A. 2012/2013Tecniche di programmazione12ADTs do not specify the details of the implementationBUTSome information about the algorithms is essential tochoose the right ADTVery high-level, qualitative informationComplexity
  13. 13. Licenza d’usoA.A. 2012/2013Tecniche di programmazione13Queste diapositive sono distribuite con licenza Creative Commons“Attribuzione - Non commerciale - Condividi allo stesso modo (CCBY-NC-SA)”Sei libero:di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico,rappresentare, eseguire e recitare questoperadi modificare questoperaAlle seguenti condizioni:Attribuzione — Devi attribuire la paternità dellopera agli autorioriginali e in modo tale da non suggerire che essi avallino te o il modo incui tu usi lopera.Non commerciale — Non puoi usare questopera per finicommerciali.Condividi allo stesso modo — Se alteri o trasformi questopera, o sela usi per crearne unaltra, puoi distribuire lopera risultante solo con unalicenza identica o equivalente a questa.http://creativecommons.org/licenses/by-nc-sa/3.0/