What Is An Abstract Data Type?
What Is An Abstract Data Type?
ADT users are NOT concerned with how the task is done but rather what it can do.
An abstract data type is a data declaration packaged together with the operations that are
meaningful for the data type.
We encapsulate the data and the operations on the data, and then hide them from the user.
All references to and manipulation of the data in a data structure are handled through
defined interfaces to the structure.
Data Structures : Algorithms
Algorithm
A high level, language independent description of a step-by-step process for solving a problem
Data Structure
A set of algorithms which implement an ADT
ADT Presentation Algorithm
Present an ADT
Motivate with some applications
Repeat until browned entirely through
develop a data structure for the ADT
analyze its properties
efficiency
correctness
limitations
ease of programming
Contrast data structure’s strengths and weaknesses
understand when to use each one
Algorithm Efficiency
To design and implement algorithms, programmers must have a basic understanding of what constitutes good, efficient
algorithms.
• Linear Loops
-Efficiency is a function of the number of intstructions.
- Loop update either adds or subtracts.
• Logarithmic Loops
-The controlling variable is either multiplied or divided in each iteration.
- The number of iteration is a function of the multiplier or divisor.
• Nested Loops
- The number of iterations is the total number which is the product of the number of iterations in the inner loop and
number of iterations in the outer loop.
• Big-O Notation
-Not concerned with exact measurement of efficiency but with the magnitude.
- A dominant factor determines the magnitute.
Applications of the Q
Limitations of Arrays
Fixed in size :
Once an array is created, the size of array cannot be increased or decreased.
Wastage of space :
If no. of elements are less, leads to wastage of space.
Sequential Storage :
Array elements are stored in contiguous memory locations. At the times it might so happen that enough contiguous locations might not be
available. Even though the total space requirement of an array can be met through a combination of non-contiguous blocks of memory, we would
still not be allowed to create the array.
Possibility of overflow :
If program ever needs to process more than the size of array, there is a possibility of overflow and code breaks.
Difficulty in insertion and deletion :
In case of insertion of a new element, each element after the specified location has to be shifted one position to the right. In case of deletion of
an element, each element after the specified location has to be shifted one position to the left.
What is a Linked List
The Linked List is a collection of elements called nodes, each node of which stores two items of
information, i.e., data part and link field.
-- The data part of each node consists the data record of an entity.
-- The link field is a pointer and contains the address of next node.
-- The beginning of the linked list is stored in a pointer termed as head which points to the first node.
-- The head pointer will be passed as a parameter to any method, to perform an operation.
-- First node contains a pointer to second node, second node contains a pointer to the third node and
so on.
-- The last node in the list has its next field set to NULL to mark the end of the list.