Course Content

Operations on Arrays in Data Structures: Traversal, Insertion, Deletion and Searching

Either you can download the handwritten notes in pdf (Link is given at the end of the page) or you can read them on this site itself.

 

Operations on an Array

The following operations are supported by an array.

  • Traversal
  • Insertion
  • Deletion
  • Search

There can be many other operations as well such as sorting ascending, sorting descending, etc.

Traversal

Visiting every element of an array once is known as Traversal

Why Traversal?

For use cases like:

  • Storing all elements – Using scanf()
  • Printing all elements – Using printf()

An important note on Arrays:

If we create an array of length 100 using a[100] in C language, we need not use all the elements. It is possible for a program to use just 60 elements out of these 100. (But we cannot go beyond 100 elements)

An array can easily be traversed using a for loop in C language

Insertion

An element can be inserted in an array at a specific position.

In order for this operation to be successful, the array should have enough capacity.

When no position is specified it’s best to insert the element at the end.

Deletion

An element at a specified position can be deleted creating a void which needs to be fixed by shifting all the elements to the left as follows:

We can also bring the last element of the array to fill the void if the relative ordering is not important. :)

Searching

Searching can be done by traversing the array until the element to be searched is found.

  • For sorted array, time taken to search is much less than an unsorted array!!

Sorting

Sorting means arranging an array in order (ascending or descending)

We’ll see various sorting techniques later in the course.

 

You can download the notes by simply clicking on this below download link. :)

Download pdf Notes here

Be the first person to comment!

Comments(0)

Resources

  1. - Download here

Course Announcements

Any Course related announcements will be posted here