0

Stack is an example of an abstract data type, stack is an example of a data structure but yet abstract data types are different from data structures how come?

3
  • 1
    I'm voting to close this question as off-topic because our on-topic guidance specifies that, "Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it." Commented Jan 3, 2018 at 17:44
  • @RobertColumbia I am new here on stack overflow, and no it's not an home work help, I'll be entering the university anytime soon for computer science so I just read PDFs to prepare my self ,,,,now the concept of abstract data types and data structures confuse me 👍 Commented Jan 3, 2018 at 17:58
  • Did you try Wikipedia?
    – karastojko
    Commented Jan 4, 2018 at 15:44

1 Answer 1

5

You can think of an ADT (Abstract Data Type) as collection of operations (i.e. add, remove, insert that define how the ADT behaves on a collection of data elements. At the ADT level, the exact way that the data is stored is hidden; hence the Abstract in Abstract Data Type. The big idea here is to hide the way data is presented to make it more accessible to others. Examples include Map and Que.

A data structure, on the other hand, actually implements those operations that define the ADT's behaviour. Examples include Array and List.

In more practical terms, you'll typically see an ADT defined in two files: 1) an interface file, which specifies the required operations; 2) an implementation file, which implements those operations using a specific data structure.

This is why you'll see something like public interface SomeList<T> at the head of interface files and public class SimpleLink<T> implements SomeList<T> at the head of implementation files — the implements is a "promise" to implement all of SomeList<T>'s methods.

1
  • List is generally an ADT and is sometimes used to refer to one of multiple data structures (e.g. in Python a list is an array). Did you mean linked-list? Commented May 17, 2019 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.