0% found this document useful (0 votes)
52 views6 pages

Data Structures: Unit 5 Part 1 Bca, NGMC

Sorting refers to arranging data in a specific order to optimize searching and improve readability. Insertion sort is a simple sorting algorithm that builds an ordered set from an unordered list, similar to sorting a hand of playing cards. It is a stable, adaptive algorithm that is efficient for small data sets while only requiring a constant amount of memory space. The algorithm iterates through the list, inserting each element into its sorted position by swapping adjacent elements.

Uploaded by

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

Data Structures: Unit 5 Part 1 Bca, NGMC

Sorting refers to arranging data in a specific order to optimize searching and improve readability. Insertion sort is a simple sorting algorithm that builds an ordered set from an unordered list, similar to sorting a hand of playing cards. It is a stable, adaptive algorithm that is efficient for small data sets while only requiring a constant amount of memory space. The algorithm iterates through the list, inserting each element into its sorted position by swapping adjacent elements.

Uploaded by

Santhosh kumar K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Data Structures

Unit 5 Part 1
BCA, NGMC
Sorting
• Sorting refers to the operation or technique of
arranging and rearranging sets of data in some
specific order.
• The importance of sorting lies in the fact that
data searching can be optimized to a very high
level, if data is stored in a sorted manner.
• Sorting is also used to represent data in more
readable formats.
• Example: Telephone Directory, Dictionary
Insertion Sort
• Insertion sorting algorithm can be best
thought of as a sorting scheme which can be
compared to that of sorting a hand of playing
cards.
• Take one card and then look at the rest with
the intent of building up an ordered set of
cards in your hand.
Advantages
• Stable algorithm
• Simple to implement
• Efficient for small data sets.
• Adaptive
• Need constant amount memory space.
Algorithm
i←1
while i < length(A)
j←i
while j > 0 and A[j-1] > A[j]
swap A[j] and A[j-1]
j←j-1
end while
i←i+1
end while

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy