ARRAYS
1
- Array is a collection of items of the same
variable type that are stored at contiguous
memory locations. It is one of the most
popular and simple data structures used in
programming.
Arrays
- An array is a collection of items stored at
contiguous memory locations. The idea is to
store multiple items of the same type
together.
2
Two essential terminologies that are used in the array
1. Array Index: In an array, elements are identified by their indexes. Array index
starts from 0.
2. Array element: Elements are items stored in an array and can be accessed by
their index.
3
Basic Operations in Arrays
The basic operations in the Arrays are insertion, deletion, searching, display, traverse, and
update. These operations are usually performed to either modify the data in the array or to
report the status of the array.
Following are the basic operations supported by an array.
• Traverse − print all the array elements one by one.
• Insertion − Adds an element at the given index.
• Deletion − Deletes an element at the given index.
• Search − Searches an element using the given index or by the value.
• Update − Updates an element at the given index.
• Display − Displays the contents of the array.
4
Applications of Array Data Structure:
Below are some applications of arrays.
• Storing and accessing data: Arrays are used to store and retrieve data in a specific order. For example, an array can
be used to store the scores of a group of students, or the temperatures recorded by a weather station.
• Sorting: Arrays can be used to sort data in ascending or descending order. Sorting algorithms such as bubble sort,
merge sort, and quicksort rely heavily on arrays.
• Searching: Arrays can be searched for specific elements using algorithms such as linear search and binary search.
• Matrices: Arrays are used to represent matrices in mathematical computations such as matrix multiplication, linear
algebra, and image processing.
• Stacks and queues: Arrays are used as the underlying data structure for implementing stacks and queues, which are
commonly used in algorithms and data structures.
• Graphs: Arrays can be used to represent graphs in computer science. Each element in the array represents a node
in the graph, and the relationships between the nodes are represented by the values stored in the array.
• Dynamic programming: Dynamic programming algorithms often use arrays to store intermediate results of
subproblems in order to solve a larger problem.
5
LINKED LIST
6
What is Linked List?
A linked list is a linear data structure which can store a collection of "nodes"
connected together via links i.e. pointers. Linked lists nodes are not stored
at a contiguous location, rather they are linked using pointers to the
different memory locations. A node consists of the data value and a pointer
to the address of the next node within the linked list.
A linked list is a dynamic linear data structure whose memory size can be
allocated or de-allocated at run time based on the operation insertion or
deletion, this helps in using system memory efficiently. Linked lists can be
used to implment various data structures like a stack, queue, graph, hash
maps, etc.
7
A linked list starts with a head node which points to the first node. Every
node consists of data which holds the actual data (value) associated with
the node and a next pointer which holds the memory address of the next
node in the linked list. The last node is called the tail node in the list which
points to null indicating the end of the list.
8
Basic Operations in Linked List
• Insertion − Adds an element at the beginning of the list.
• Deletion − Deletes an element at the beginning of the list.
• Display − Displays the complete list.
• Search − Searches an element using the given key.
• Delete − Deletes an element using the given key.
9
Types of Linked List
1. Singly Linked Lists
- Singly linked lists contain two "buckets" in one node; one bucket holds the
data and the other bucket holds the address of the next node of the list.
Traversals can be done in one direction only as there is only a single link
between two nodes of the same list.
10
Types of Linked List
2. Doubly Linked Lists
- Doubly Linked Lists contain three "buckets" in one node; one bucket holds
the data and the other buckets hold the addresses of the previous and next
nodes in the list. The list is traversed twice as the nodes in the list are
connected to each other from both sides.
11
Types of Linked List
3. Circular Linked Lists
Circular linked lists can exist in both singly linked list and doubly linked list.
Since the last node and the first node of the circular linked list are
connected, the traversal in this linked list will go on forever until it is
broken.
12
Applications of Array Data Structure:
Below are some applications of arrays.
• Applications of linked list in computer science:
• Implementation of stacks and queues
• Implementation of graphs: Adjacency list representation of graphs is the most
popular which uses a linked list to store adjacent vertices.
• Dynamic memory allocation: We use a linked list of free blocks.
• Maintaining a directory of names
• Performing arithmetic operations on long integers
• Manipulation of polynomials by storing constants in the node of the linked list
• Representing sparse matrices
13
https://www.geeksforgeeks.org/introduction-to-
arrays-data-structure-and-algorithm-tutorials/
https://www.tutorialspoint.com/data_structures_
algorithms/array_data_structure.htm
Thank you https://www.geeksforgeeks.org/applications-adv
antages-and-disadvantages-of-array-data-struct
ure/
https://www.tutorialspoint.com/data_structures_
algorithms/linked_list_algorithms.htm