DS 2
DS 2
Ahmad
Lecture 2
Choosing your Data Structure
An array of 5 integers
• Through linear relationship between the elements
represented by means of pointers or links.
Arrays
Operation Description
Insertion Adding a new element to an array
Deletion Removing an element from an array
Traversal Processing each element in the array
Search Finding the location of an element with a
given value
Sorting Organising the element in some order
Merging Combining two arrays into single array
Reversing Reversing the elements of an array
Array Declaration
• Derefrencing
int *ptr;
myArr[3] = 10;
p[4] = 5;
cout << myArr[6];
cout << p[6];
• Recursive calls
– Calls to the current method.
– Each recursive call should be defined so that it makes progress
towards a base case.