Search code examples
typesabstraction

Difference between data structure, data type and abstract data type


I understand the basic concepts and definitions like :

  1. Abstract data type is abstraction that define set of values and set of operations on this values.
  2. Data structure is the way you can store the data to provide efficient ways to operate on it.
  3. Data type is kind of instruction to computer language that tells how to operate with data of this type.

What i can't figure out is that the abstraction level of this concepts and how they relate to each other. Like, okay, that's how i understand all this:

  • Stack(ATD) is idea of something you can put some objects onto and then pull out only the last putted object. providing 2 operations - void push(bject), Object pull().
  • Stack(data structure) is a little bit concretization, so, let's say is is the idea of something you can put some objects onto and the idea of how the push() and pull() operations could work, like on the base of array.
  • -Stack(datatype) is the concrete part of source code that i can use with my *.cpp .

Am i right or i miss something?

p.s. sorry for my poor English.


Solution

  • ADT exits only in logical form. It's best expressed in natural language or pseudo code. Example: A List, Map, Stack, etc.

    Once the ADT is implemented, it becomes a data structure. Example: A linked-list, a hashmap, etc.

    Types are mostly refering to built-in primitive such as Int, Char or user defined types using other built-in types such as C struct.

    However, I belive the line is not strickly drawn. For example if a language provide a linked-list as a built-in type, then it would be a type.

    Please also check the discussion below: https://softwareengineering.stackexchange.com/questions/148747/abstract-data-type-and-data-structure