Need help understanding what an ADT (abstract data type) is exactly

  • Thread starter r0bHadz
  • Start date
  • Tags
    Data Type
In summary: I wanted to make sure that everyone was clear about the concept before jumping into more complex things.
  • #1
r0bHadz
194
17
TL;DR Summary
Read quantum quests post. Still confused. What I have so far:

ADT = way of describing something with a mathematical model.

Datastructure: the way you organize your data

How is stack both a data structure and a datatype?
I've read quantum quests data structures bible but I'm still confused. I need help in simplest terms understanding what an ADT actually is and how it's different from a data structure.

So a data structure is a way of organizing data. I can understand why a stack, or a queue would fall under the category of data structure. Because: they have a structure. The first element in, is the first one out, or last one out depending if its a stack or not.

But I do not understand why its a ADT. When I think of mathematical model that describes a stack, I think of a list of elements.
 
Computer science news on Phys.org
  • #2
One important point for ADTs is this

This specification does not imply implementation details which are different according to the syntax of a specific programming language

So, you have an ADT which is a mathematical model of the data objects that make up a data type and the functions that operate on these objects and there's nothing implying implementation details in it.

Next

So, effectively, ADTs are purely theoretical entities which we use in conjunction with abstract descriptions of algorithms (meaning not real implementations as programs). We can classify and evaluate data structures through them. On the other hand, a Data Structure is a realization of an ADT i.e. involves aspects of implementation.

So, here it is clear that you can construct a theoretical (mathematical) model with pen and paper and create the steps of an algorithm that operates on it. If / when you want to impement this construct in a specific programming language then implementation details come into play. For instance, let's take the example of a stack for which you talk about.

As an ADT, a stack is a collection of elements with a number of operations defined on it (see the "Stack" section of the tutorial). The operations are defined in a mathematical way as I describe there.
Now, see the example of an implementation of a stack in Pascal. Here, we use the record software construct in order to implement the stack as a data structure and we define functions in order to operate on the data i.e. create a stack, checking if the stack is empty or full which is crucial in order to perform other operations on the stack, push and pop in order to insert and extract data from the stack and also top of the stack.

So, as you see, there are implementation details in order to implement the stack itself and the operations on it in the form of program in some programming language.

EDIT: Also, a few words about this

There is an open relationship among these three notions: A data type, as we saw above, is the implementation of an ADT i.e. of a specification about the relationship of specific data and the operations that can be performed on them and data structures, at the programming level, are essentially sets of variables of the same or different data types.

If you got confused about this, this basically pertains to the way that programming languages implement data types. Take the range of integers that some programming language has. This is a data type in this specific programming language and it also includes a set of operations besides the range of integers itself. So, when a programmer constructs a specific data structure in this programming language - and any other for that matter, he / she essentially defines variables of various data types which as said above contain both the specific data types and the operations on them, so they are data structures of and in itselves and then he / she can construct another data structure e.g. a queue using an array for instance.

That's why I started the presentation of data structures at a low level and then went higher.
 
Last edited:
  • Like
Likes r0bHadz

Related to Need help understanding what an ADT (abstract data type) is exactly

1. What is an ADT?

An ADT, or abstract data type, is a data type that is defined by its behavior and operations rather than its implementation. It is a mathematical concept that represents a set of values and a set of operations that can be performed on those values.

2. How is an ADT different from a data structure?

An ADT is an abstract concept, while a data structure is a concrete implementation of that concept. An ADT defines the behavior and operations of a data type, whereas a data structure is the way that data is actually organized and stored in a computer program.

3. What are some examples of ADTs?

Some common examples of ADTs include stacks, queues, lists, and trees. These are all abstract concepts that can be implemented in different ways depending on the specific needs of a program or data set.

4. Why are ADTs important in programming?

ADTs allow programmers to work with abstract concepts rather than getting bogged down in the details of how data is actually stored and manipulated in memory. This makes it easier to design and maintain complex programs, and also allows for more flexibility and reusability of code.

5. How are ADTs used in real-world applications?

ADTs are used in a wide range of applications, from computer science and software engineering to mathematics and physics. They are particularly useful in situations where data needs to be organized and manipulated in a specific way, but the exact implementation may vary depending on the specific problem or data set.

Similar threads

  • Computing and Technology
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
Replies
1
Views
993
  • Programming and Computer Science
Replies
2
Views
3K
  • DIY Projects
Replies
33
Views
2K
  • Computing and Technology
2
Replies
41
Views
4K
  • Science and Math Textbooks
Replies
4
Views
679
Back
Top