This document provides an overview of data structures and algorithms. It defines data structures as organized collections of data that allow for efficient use of data in a computer. Algorithms are step-by-step procedures to solve problems or achieve outputs. Common data structures discussed include arrays, stacks, queues, and linked lists. Linear data structures arrange elements sequentially while non-linear structures do not. Example non-linear structures mentioned are trees, binary search trees, and graphs. The document also gives examples of common algorithms like searching, sorting, insertion, updating, and deletion.
3. DATA STRUCTURE
Data Structure can be defined as the group of data elements which
provides an efficient way of storing and organizing data in the
computer so that it can be used efficiently.
Algorithm
Algorithm is a step-by-step procedure, which defines a set of instructions to be
executed in a certain order to get the desired output or to solve a particular
problem.. An algorithm can be implemented in more than one programming
language.
Learning data structures and algorithms allow us to write efficient and
optimized computer programs.
4. SOME DATA STRUCTURE ALGORITHMS
Searching: Algorithm to search an item in a data structure.
• Linear Search
• Binary Search
Sorting: Algorithm to sort items in a certain order.
• Selection Sort
• Bubble Sort
• Merge Sort
Insert: Algorithm to insert item in a data structure.
Update: Algorithm to update an existing item in a data structure.
Delete: Algorithm to delete an existing item from a data structure
5. Linear Data Structure
A Linear data structure have data elements arranged in sequential manner and
each member element is connected to its previous and next element. Such data
structures are easy to implement as computer memory is also sequential.
Examples of linear data structures are:
Array
Linked List
Queue
Stack
6. Array:
An array consists of data elements of a same data type. For example, if we want to store the roll
numbers of 5 students, so instead of creating 10 integer type variables, we will create an array
having size 5. Therefore, we can say that an array saves a lot of memory and reduces the length of
the code.
Let's discuss each linear data structure in detail.
Int array [ 5 ] = { 2 ,4 , 7 , 9 , 10 };
Stack:
It is linear data structure that uses the LIFO (Last In-
First Out) rule in which the data added last will be
removed first. The addition of data element in a
stack is known as a push operation, and the
deletion of data element form the list is known as
pop operation.
7. Queue:
It is a data structure that uses the FIFO
rule (First In-First Out). In this rule, the
element which is added first will be
removed first. There are two terms used
in the queue front end and rear The
insertion operation performed at the
back end is known as enqueue, and the
deletion operation performed at the
end is known as dequeue.
8. Linked list:
It is a collection of nodes that are made up of two parts, i.e., data element and reference to
next node in the sequence.
9. NON-LINEAR DATA STRUCTURE
Non-linear Data Structure: Data structures where data elements are not arranged
sequentially or linearly are called non-linear data structures.
Examples of non-linear data structures are:
Tree
BST (Binary Search Tree)
Graphs