Arrays as Abstract Data Type (ADT)
Abstract Data Type (ADT) – Notes
1. Definition
An Abstract Data Type (ADT) is a logical description of a data type that
defines:
- The data
- The operations that can be performed on the data
It focuses on what operations are performed, not how they are implemented.
2. Key Characteristics
- Abstraction – Hides internal implementation
- Encapsulation – Combines data and operations
- User Interface – Only operations are visible
- Implementation Independence – Can be implemented in different ways
3. Components of ADT
(a) Data – The values stored
(b) Operations – Functions performed (insert, delete, search)
1. Definition of Array as Abstract data type
An Array ADT is a collection of elements of the same data type stored in
contiguous memory locations.
It defines data (elements) and operations such as access, insertion, deletion,
and update.
2. Characteristics of Array ADT
- Homogeneous elements
- Stored in continuous memory
- Access using index
- Fixed size
- Fast access
3. Operations on Array ADT
(a) Access – Retrieve element using index
(b) Insertion – Add element at a position (requires shifting)
(c) Deletion – Remove element (requires shifting)
(d) Traversal – Visit all elements
(e) Searching – Linear search, Binary search
(f) Updating – Modify element value
4. Representation of Array
Example: int a[5] = {10, 20, 30, 40, 50};
Index: 0 1 2 3 4
Value:10 20 30 40 50
5. Array as ADT Concept
User View:
- Store elements
- Access elements
- Insert/Delete
Implementation View:
- Memory allocation
- Index calculation
- Address mapping
6. Advantages
- Easy to use
- Fast access (O(1))
- Efficient memory usage
- Suitable for large data
7. Disadvantages
- Fixed size
- Costly insertion and deletion
- Possible memory wastage
8. Example
Array: [10, 20, 30, 40]
After insertion: [10, 20, 25, 30, 40]
9. Conclusion
Array ADT defines operations on data while hiding implementation details.