Professional Documents
Culture Documents
Class 12 - Sorting Algorithms
Class 12 - Sorting Algorithms
Manish B. Gudadhe ,St. Vincent Pallotti College of Engineering & Technology, Nagpur
Contents
▸ Need of data structures
▸ In place Sorting
▸ Bubble sort is an algorithm that compares the adjacent elements and swaps
their positions if they are not in the intended order.
▸ Starting from the first index, compare the first and the second elements.If the
first element is greater than the second element, they are swapped.
▸ Now, compare the second and the third elements. Swap them if they are not in
order.
▸ Insertion sort is a simple sorting algorithm that works similar to the way you
sort playing cards in your hands.
▸ Values from the unsorted part are picked and placed at the correct position
in the sorted part.
Insertion sort
Algorithm
void insertionSort(int array[], int size)
{ for (int step = 1; step < size; step++)
{
int key = array[step];
int j = step - 1;
// Compare key with each element on the left of it until an element smaller than // it is
found.
while (key < array[j] && j >= 0)
{
array[j + 1] = array[j];
--j;
}
array[j + 1] = key;
}}
Examples of commonly used Data Structures are:
▸ Linked List: Singly linked list, Doubly linked lists, Circular list
▸ Priority Queue
▸ Hash Table
▸ Graph
Types of Data structures?
Arrays
The stack is a data structure following the LIFO(Last In, First Out) principle.
Queues
The queue is a data structure following the FIFO(First In, First Out) principle.
Linked List
• The number of nodes in a list is not fixed and can grow and shrink on demand.
Trees
• A graph is a set of objects where some pairs of objects are connected by links.
• The interconnected objects are represented by points termed as vertices, and
the links that connect the vertices are called edges.
Application of data structures
• Stacks are used in “call stack” which is used when functions are called.
• Heaps are used to implementing priority queues which are used for scheduler during
• Binary Search Trees are used for implementing maps and sets.
• Circular Doubly linked lists are used by the kernel to store lists of processes.
Searching & Sorting
Searching Algorithms
To search an element in a given array, there are two popular algorithms available:
• Linear Search
• Binary Search
• Exponential Search
• Interpolation Search
• Jump Search
• Linear Search
• Ternary Search
Linear Search
25
31
48
62
75
89
93
12
25
93
12
93
“
Quotations are commonly printed
as a means of inspiration and to
invoke philosophical thoughts from
the reader.
BIG CONCEPT
Bring the attention of your audience over
a key concept using icons or illustrations
You can also split your content
White Black
Is the color of milk and Is the color of ebony
fresh snow, the color and of outer space. It
produced by the has been the symbolic
combination of all the color of elegance,
colors of the visible solemnity and
spectrum. authority.
In two or three columns
A B C
Yellow 10 20 7
Blue 30 15 10
Orange 5 24 16
Maps
our office
89,526,124
Whoa! That’s a big number,
aren’t you proud?
89,526,124$
That’s a lot of money
185,244 users
And a lot of users
100%
Total success!
Our process is easy
ANDROID
PROJECT
Show and explain your
web, app or software
projects using these
gadget templates.
Place your screenshot here
iPHONE
PROJECT
Show and explain your
web, app or software
projects using these
gadget templates.
Place your screenshot here
TABLET
PROJECT
Show and explain your
web, app or software
projects using these
gadget templates.
Place your screenshot here
DESKTOP
PROJECT
Show and explain your
web, app or software
projects using these
gadget templates.
THANKS!
Any questions?
You can find me at @username & user@mail.me
Credits
▸ Orange #ff8700
You don’t need to keep this slide in your presentation. It’s only here to serve you as a design guide if you
need to create new slides or download the fonts to edit the presentation in PowerPoint®
SlidesCarnival icons are editable shapes.
Examples:
Diagrams and infographics
� Now you can use any emoji as an icon!
And of course it resizes without losing quality and you can change the color.
�
How? Follow Google instructions
https://twitter.com/googledocs/status/730087240156643328
✋👆👉👍👤👦👧👨👩👪💃🏃💑❤😂
😉😋😒😭👶😸🐟🍒🍔💣📌📖🔨🎃🎈
🎨🏈🏰🌏🔌🔑 and many more...
Free templates for all your presentation needs
For PowerPoint and 100% free for personal or Ready to use, professional Blow your audience away
Google Slides commercial use and customizable with attractive visuals