The document discusses array as an abstract data type (ADT). An ADT defines both the representation of data (e.g. array space, size, length) and operations that can be performed on that data (e.g. display, add, insert, delete, search). Arrays can be created either on the stack or the heap. Common operations include accessing elements by index, searching for elements, and modifying the array by adding, removing, or updating elements. The array ADT can be implemented using structures or classes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
139 views2 pages
Array ADT
The document discusses array as an abstract data type (ADT). An ADT defines both the representation of data (e.g. array space, size, length) and operations that can be performed on that data (e.g. display, add, insert, delete, search). Arrays can be created either on the stack or the heap. Common operations include accessing elements by index, searching for elements, and modifying the array by adding, removing, or updating elements. The array ADT can be implemented using structures or classes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
01.
Array ADT Note: Array ADT section is about Array and Operations on Array.
Array as Abstract Data Type (ADT):
Abstract Data Type means - Representation of Data Set of Operations on the Data Representation of Data is defined by the Compiler itself. But the Operations on the Data are not defined by the Compiler. We have to implement or provide the Operations on Array Data Structure. So, Array Data Structure and the Set of Operations together can be called Abstract Data Type (ADT).
Representation of Data of Array:
Data: Array Space Size Length (No of Elements)
Two Methods of Creating Array:
Inside Stack: Example: int A[10]; Inside Heap: Example: int size = 10; // Size int length = 0; // Length int *A; // Array Space A = new int[size]; Operations: Display(): To display the entire array on the screen. Add(n) / Append(n): To add a particular element at the end of the array. Insert(index, n): To add an element to a particular index. Delete(index): To delete an element with the help of an index in the given array. Search(n): To check whether the given element is present or not in an array. Get(index): To return the element that is present on the given index. Set(index, x): To change the element with the new element at a particular index. Max() / Min(): To return the max or min element in the given array. Reverse(): To reverse the order of elements in the given array. Shift(): To shift all elements either on the left or right side by the given number.
Important – Must Read:
In this Section, Array is implemented using “Struct” Data Structure. You can implement Array using “Class” as well. However, if you want to implement using Raw Array Data Structure, then you can do that also. To sum up, it doesn’t matter how you implement. Things you learn in this section is application for any implementation.