Frage

ADT is the set of operations. ADT's are mathematical abstractions.

Does this mean that ADT are same as classes or am i confusing both together ?

War es hilfreich?

Lösung

The key to the difference is abstract. Think of an ADT more like an interface - a class with only method declarations, no implementation details.

As an example, a Stack ADT defines the basic stack operations like push and pop (but says nothing of how these operations should be implemented), while a Stack class would use either a linked-list or an array to actually implement these operations.

Andere Tipps

According to Code Complete, ADT is a collection of data and operations that work on that data.

Example for ADT:

List

  • Initialize list
  • Insert item in list
  • Remove item from list
  • Read next item from list

ADT form the foundation for the concept of classes. In languages that support classes, you can implement each abstract data type as its own class. Classes usually involve the additional concepts of inheritance and polymorphism. One way of thinking of a class is as an abstract data type plus inheritance and polymorphism.

An abstract data type (ADT) is a mathematical abstraction of a real world thing and can be implemented in a concrete data type in different languages.

An ADT defines operations for the given type and mathematically expresses their behaviour. Concrete implementations of an ADT can differ from each other. In that way classes are implementing the ADT and methods implement operations.

Classes have a slightly different terminology than ADTs and add other characteristics, like:

  • they for example may live in packages
  • their members are called attributes and methods
  • attributes and methods have a certain visibility constraint

And methods:

  • can be abstract, too. but then, their behaviour isn't defined - only their method signature - an inheriting concrete class must provide an implementation

Don't confuse abstract data types with abstract classes in a concrete language.

A class is an implementation of an abstract data type (ADT).

ADTs are the way of classifying data structure by providing a minimal expected interface and set of Method

ADT's = set of values + Operation Example Stack, Queue

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top