HarshwardhanPatil07 / HactoberFest2024

A Simple😉 beginner friendly😊 Repo for all programmers and coders. All contributors are requested to star🌟this repo and and folllllow me. Contribute to start your journey with hacktoberfest. Happy Hacking💻!!!
MIT License
160 stars 447 forks source link

insertionSort.js added #402

Open Prasadkandekar opened 1 month ago

Prasadkandekar commented 1 month ago

How Insertion Sort Works works: The outer loop goes through the array starting from index 1. The inner loop compares the current element (key) with the elements before it and shifts the larger elements one position to the right. The key is inserted into its correct position once the proper place is found. The time complexity of this algorithm is 𝑂(𝑛2) O(n 2) in the worst and average cases, where 𝑛n is the number of elements in the array.