0% found this document useful (0 votes)
23 views11 pages

Selection and KMP

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)
23 views11 pages

Selection and KMP

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/ 11

Selection sort

and KMP Presented by

algorithm
Midhun R
Pavithra R
Rekashini G
Rishikesh G S
Selection sort:
Selection sort is a simple and efficient sorting algorithm that works by
repeatedly selecting the smallest (or largest) element from the unsorted
portion of the list and moving it to the sorted portion of the list.

Time complexities:
• Worst-case time complexity: O(n^2)
• Best-case time complexity: O(n^2)
• Average-case time complexity: O(n^2)
Algorithm:
SelectionSort(A):
n = length of array A
for i from 0 to n-2:
min_index = i
for j from i+1 to n-1:
if A[j] < A[min_index]:
min_index = j
if min_index != i:
swap A[i] with A[min_index]
Applications:
• Educational Purposes: Often used in teaching sorting algorithms due to its
simplicity.
• Small Data Sets: Effective for sorting small arrays or lists where efficiency
is less critical.
• Embedded Systems: Suitable for environments with limited memory or
computational power.
• Simple Implementation: Easy to implement and understand.
• Stable Performance: Performs consistently across different data
distributions.
Knuth-Morris-pratt algorithm:
What is KMP-Algorithm?
The Knuth-Morris-Pratt (KMP) algorithm is an efficient string matching algorithm that
searches for occurrences of a "pattern" within a "text" by preprocessing the pattern to
determine where mismatches can lead to subsequent matches, thus avoiding
unnecessary comparisons.

Time complexities:
• Worst case : O(n+m)
• Best case : O(n+m)
• Average case : O(n+m)
Applications:
• Search Engines: Quickly find search queries in large text collections.
• Bioinformatics: Locate specific DNA or protein sequences in genomic data.
• Plagiarism Detection: Identify copied text in documents.
• Text Editors: Implement "find" and "replace" features.
• Network Security: Scan for malicious patterns in network traffic.
• Data Compression: Find repeated sequences to compress data.
• Digital Forensics: Search for keywords in large sets of digital evidence.
Thank
you

You might also like