This document discusses arrays, including their definition, algorithms for insertion and deletion, types of arrays, real-life examples, advantages, and disadvantages. Arrays store elements of the same data type in contiguous memory locations, allowing fast random access. They are useful for storing fixed sized data but the size cannot be dynamically changed. While arrays provide efficient access, insertion and deletion have higher time complexity than other data structures.
1. Dr. B.C. Roy Engineering College, Durgapur
Department of Computer Science and Engineering
Continuous Assessment 1
Topic: Array
Name: Rajdip Chatterjee
University Roll No: 12000121037
Section: CSE 1
Course Name: Data Structure & Algorithm
Course Code: PCC CS 301
3. Array Definition
● Arrays are the simplest data structures that store items of the same data
type.
● This makes it easier to calculate the position of each element by simply
adding an offset to a base value, i.e., the memory location of the first
element of the array (generally denoted by the name of the array).
● A basic application of Arrays can be storing data in tabular format.
● For example, if we wish to store the contacts on our phone, then the
software will simply place all our contacts in an array.
● Since the elements in the array are stored at contiguous memory
locations it is easy to iterate in this data structure and unit time is
required to access an element if the index is known.
4. Algorithm For Insertion In An Array
Array Reg[N] with last element at Mith
position value X is to be inserted at ith
location.
Steps:
• 1. If(M<N) then BACK=M+1 else STOP
• 2. While (BACK>i) repeat steps 3 to 4
• 3. REG[BACK]= REG[BACK-1]
• 4. BACK=BACK-1;
• 5. Reg[BACK]='X'
• 6. M=M+1
• 7. End.
5. Algorithm For Deletion In An Array
Algorithm: In this algorithm a value is being
deleted from ith location of an array Reg[N].
Let us assume that last element in the array
is at Mith position.
Steps
1. Back=1
2. While (Back<M) repeat 3 and 4
3. Reg[Back]= Reg[Back+1]
4. Back= Back+1
5. M=M-1
6. End
6. Types of Array
Indexed Array: Indexed arrays store a series of one or more values. You can look up items by their
position in the array, which you might have done in earlier sections. The first index is always the number 0, and the
index increments by one for each subsequent element that you add to the array.
Multidimensional Array: In ActionScript, you can implement arrays as nested arrays that are
essentially arrays of arrays. Nested arrays, also known as multidimensional arrays, are very similar to matrices or
grids. When you’re programming, you might use multidimensional arrays to model these kinds of structures.
Associative Array:An associative array, which is like an object, is made of unordered keys and
values. Associative arrays use keys instead of a numeric index to organize stored values. Each key is a unique string,
and it’s associated with and used to access one value.
7. Real life example of Array
Let’s see some real-world arrays:
● Arranging books: You have a pile of books and a rack
with multiple layers. Once all the books are arranged, you
essentially created an array of elements (in this case,
books)
● A Mango plantation: Can be defined as the nested array.
Imagine 10 trees in each row and 10 such rows. You can
also call this a matrix ( or a list of list perhaps? )
● Bullet points mentioned here: All the points described
here is in an ordered series, so essentially, we create an
array (of 3 elements)
8. Advantages of array data structure
● Arrays store multiple data of similar types with the same name.
● It allows random access to elements.
● As the array is of fixed size and stored in contiguous memory
locations there is no memory shortage or overflow.
● It is helpful to store any type of data with a fixed size.
● Since the elements in the array are stored at contiguous memory
locations it is easy to iterate in this data structure and unit time is
required to access an element if the index is known.
9. Disadvantages of array data structure
● The size of the array should be known in advance.
● The array is a static data structure with a fixed size so, the
size of the array cannot be modified further and hence no
modification can be done during runtime.
● Insertion and deletion operations are costly in arrays as
elements are stored in contiguous memory.
● If the size of the declared array is more than the required
size then, it can lead to memory wastage.
10. Conclusion
Arrays are more efficient and beneficial when
compared to linked lists and hash tables. They are
faster and can be utilized anywhere. They store data
of similar data types together and can be used
anywhere in the code.