0% found this document useful (0 votes)
2 views15 pages

Array Data Structure

Array Data Structure

Uploaded by

mmany6186
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views15 pages

Array Data Structure

Array Data Structure

Uploaded by

mmany6186
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Copyright© 2022 Mohammed Abu-Hadhoud

[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Array
Data Structure

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Array Data Structure:
Array: is a variable that can store multiple values of the same type.

Array: An array is a collection of data items stored at contiguous


memory locations.

The idea is to store multiple items of the (homogeneous - same type)


together.

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Array Data Structure:
int x[5] = { 22, 18, 2, 55, 520 };

Array
X[0] X[1] X[2] X[3] X[4]
Members

22 18 2 55 520 Array Values

Index starts
0 1 2 3 4 Array Indexes
from zero

1000 1004 1008 1012 1016 Memory addresses

Memory
Copyright© 2022 Mohammed Abu-Hadhoud
[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Is Array Always
Of Fixed Size?

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Is Array Always of Fixed Size?
Depends on they language for example: In C language, the array has a
fixed size meaning once the size is given to it, it cannot be changed
i.e. you can’t shrink it nor can you expand it.

In C++ you can have dynamic arrays.

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Operations on The
Array?

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Operations on The Array?
• Arrays allow random access to elements. This makes accessing
elements by position faster.

• Hence operation like searching, insertion, and access becomes


really efficient.

• Array elements can be accessed using the loops.

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Time Complexity
on The Array?

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Time Complexity on The Array?
• Insertion: We try to insert a value to a particular array index
position, as the array provides random access it can be done easily
using the assignment operator.

arr[2] = 10;

• Time Complexity:
O(1) to insert a single element
O(N) to insert all the array elements [where N is the size of the array]

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Time Complexity on The Array?
• Access elements in Array: Accessing array elements become extremely
important, in order to perform operations on arrays.

return arr[2];

• Time Complexity:
O(1) to insert a single element
O(N) to access all the array elements [where N is the size of the array]

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Time Complexity on The Array?
• Searching in Array: We try to find a particular value in the array, in
order to do that we need to access all the array elements and look for
the particular value.

// searching for value 55 in the array;

Loop from i = 0 to 10:


check if arr[i] = 55:
return true;

• Time Complexity:
O(N) [where N is the size of the array]

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Applications of
The Array?

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Applications of The Array?
• Array stores data elements of the same data type.
• Arrays are used when the size of the data set is known.
• Used in solving matrix problems.
• Applied as a lookup table in computer.
• Databases records are also implemented by the array.
• Helps in implementing sorting algorithm.
• The different variables of the same type can be saved under one name.
• Arrays can be used for CPU scheduling.
• Used to Implement other data structures like Stacks, Queues, Heaps, Hash tables,
etc.

Copyright© 2022 Mohammed Abu-Hadhoud


[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience
Copyright© 2022 Mohammed Abu-Hadhoud
[Link] MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
26+ years of experience

You might also like