Bloomberg LP Interview Question
Software Engineer / DevelopersADT is an interface of the base class. The function defined in ADT are pure virtual. ADT is not meant to be instatiated. Instead it must be derived by a derived class and implement the methods in the base class
eg class shape{ virtual draw()=0;}
class square:public shape
{draw(){cout<<"drawing a square";}
A modification to a program commonly requires a change in one or more of its data structures. For instance, a new field might be added to a personnel record to keep track of more information about each individual; an array might be replaced by a linked structure to improve the program's efficiency; or a bit field might be changed in the process of moving the program to another computer. You don't want such a change to require rewriting every procedure that uses the changed structure. Thus, it is useful to separate the use of a data structure from the details of its implementation. This is the principle underlying the use of abstract data types.
Here are some examples.
* stack: operations are "push an item onto the stack", "pop an item from the stack", "ask if the stack is empty"; implementation may be as array or linked list or whatever.
* queue: operations are "add to the end of the queue", "delete from the beginning of the queue", "ask if the queue is empty"; implementation may be as array or linked list or heap.
* search structure: operations are "insert an item", "ask if an item is in the structure", and "delete an item"; implementation may be as array, linked list, tree, hash table, ...
Functional programming language like C
There are two views of an abstract data type in a procedural language like C. One is the view that the rest of the program needs to see: the names of the routines for operations on the data structure, and of the instances of that data type. The other is the view of how the data type and its operations are implemented. C makes it relatively simple to hide the implementation view from the rest of the program.
From Wikipedia:
An abstract data type is defined indirectly, only by the operations that may be performed on it and by mathematical constraints on the effects (and possibly cost) of those operations.
Examples are stack, queue, binary search tree, heap... they can be implemented by either linked-list, nodes with pointers, or arrays, which are concrete data types.
Data Types are created by defining classes.
- morpheus February 12, 2009Abstract Data Types are Abstract Classes.
Generally objects are created using DataTypes or Classes.
But, for Abstract Data Types or Abstract Classes, one can not create objects.
what one can do using ADT, is derive other dataTypes from ADT and make them non - abstract ( by defining implementation)
ADT are like interfaces.