SATISH KUMAR’s Post

Day 36 of my #100DaysOfCode challenge 🚀 Today I worked on implementing the Insertion Sort algorithm in Python. Insertion Sort is a simple and intuitive sorting technique where elements are picked one by one and inserted into their correct position in the sorted part of the list. What the program does: • Takes an unsorted list as input • Iterates through elements starting from the second element • Compares the current element with previous elements • Shifts larger elements to the right • Inserts the element in the correct position How the logic works: 1. Start from the second element of the list (index 1) 2. Store the current element as key 3. Compare it with elements before it 4. Shift larger elements one position to the right 5. Insert the key into its correct sorted position 6. Repeat until the entire list is sorted Example: Input: [12, 11, 13, 5, 6] Output: [5, 6, 11, 12, 13] Another example: Input: [64, 34, 25, 12, 22, 11, 90] Output: [11, 12, 22, 25, 34, 64, 90] Why Insertion Sort is useful: – Easy to understand and implement – Works efficiently for small or nearly sorted datasets – Time Complexity: O(n²) (worst case) Key learnings from Day 36: – Understanding basic sorting algorithms – Working with element shifting logic – Implementing algorithmic thinking step by step – Strengthening Data Structures & Algorithms fundamentals #100DaysOfCode #Day36 #Python #PythonProgramming #InsertionSort #SortingAlgorithms #DataStructures #Algorithms #ProblemSolving #CodingPractice #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney

  • text

To view or add a comment, sign in

Explore content categories