1
Array Assignment
Course Name Data Structures
Course No IT209 + COMP204
Lab No 4
Chapter Array
Deadline 28/03/2024
An array has the following properties:
Array of 5 Element
0 1 2 3 index
elements 4
An array has the following properties:
An Array is a collection of elements of the same type.
Array elements can be of any type, including an array type.
An array can be single-dimensional, multidimensional.
Arrays are zero indexed: an array with n elements is indexed from 0 to n-1.
and array is a fixed size.
Requested work :
Create MyArray class that contains the following functions:
1. Define a constructor to initialize the size of array elements.
2. Define a function IsEmpty to check if array is empty or has elements
and return bool value.
3. Define a function Count to return the size (number of elements)
actually contained in Array.
4. Define a function Clear to Removes all elements from the Array.
5. Define a function Show to print all elements of Array.
Data Structures ßelal A. Hamed
2
6. Define a function AddFirst to add a new element on the head of a
given array.
7. Define a function AddLast to add a new element on the tail of a
given array.
8. Define a function Add to add a new element on the specified index of
a given array.
9. Define a function RemoveFirst to remove the first element from the
Array.
10. Define a function RemoveLast to remove the last element from the
Array.
11. Define a function RemoveAt to remove an element of a specified
index from a given array.
12. Define a function Sort to sort the elements in the entire Array.
(use four different algorithms for sort the elements of array)
13. Define a function Reverse to reverse the order of the elements in
the entire Array.
14. Define a function LinearSearch to finding an element within an
Array.
15. Define a function BinarySearch to Searches the entire sorted Array
for an element using the default comparer and returns the zero-
based index of the element.
16. Define a function PrintArrayElements(array) to print any element
of a specified array.
17. Define a function AddArrayElement(Size) to accept size of array
from user and accept array elements from user then return an array.
18. Test all previously defined functions in the main function
Data Structures ßelal A. Hamed