Define ADT In c Define ADT In c SolutionAbstract data typeAD
Solution
Abstract data type(ADT):
A data type can be considered abstract when it is defined in terms of operations on it, and its implementation is hidden by which one implementation can be replaced with another.There are no standard conventions for defining them.
In C++,it can be done with a class which has no public or protected data members,nor any methods which return pointers or references to any of the private fields.Some ADTs must control all copy operations invoked upon objects.This is necessary to avoid dynamic memory aliasing problems caused by shallow copying.A String class is a good example of the need for controlling all copy operations.
Common examples of ADTs are Built-in types: boolean, integer, real, array and User-defined types: stack, queue, tree, list.
Built-in types
boolean – Values(true and false) and Operations (and, or, not, nand, etc).
integer – Values(Whole numbers between MIN and MAX values) and Operations (add, subtract, multiply, divide, etc).
arrays – Values(Homogeneous elements, i.e., array of X...) and Operations (initialize, store, retrieve, copy, etc)
User-defined types
stack – Values(Stack elements, i.e., stack of X...) and Operations(create, destroy/dispose, push, pop, is empty, is full, etc.)
queue – Values(Queue elements, i.e., queue of X...) and Operations(create, destroy/dispose, enqueue, dequeue, is empty, is full, etc.)
tree search structure – Values(Tree elements, i.e., tree of X) and Operations(insert, delete, find, size, traverse (inorder, post-order, pre-order, level-order), etc.)
