@@ -50,16 +50,16 @@ export const sortingMetaData = {
5050 example : Helper . setExampleImage ( "Complexity and Stability of Sorting Algorithms" , sortData . example ) ,
5151}
5252
53- // ------------------------------------------ Selection Sort Meta Data ------------------------------------------//
53+ // ------------------------------- Selection Sort Meta Data ---- ------------------------------------------//
5454
5555const selectionSortData = {
5656 defination : `Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based
5757 algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end.
5858 Initially, the sorted part is empty and the unsorted part is the entire list. <br>
5959 The smallest element is selected from the unsorted array and swapped with the leftmost element, and that element becomes
6060 a part of the sorted array. This process continues moving unsorted array boundary by one element to the right.` ,
61- flowChart :"assets/ds-image/selection-sort .jpg" ,
62- explainImage :"assets/ds-image/explainImage .jpg" ,
61+ flowChart :"assets/ds-image/DSA1 .jpg" ,
62+ explainImage :"assets/ds-image/DSA1 .jpg" ,
6363 workingProcedure :[
6464 'Initialize minimum value(minValue) to location 0.' ,
6565 'Traverse the array to find the minimum element in the array.' ,
@@ -97,4 +97,67 @@ export const selectionSortMetaData: Algorithms = {
9797 disadvantage : Helper . setListwithTitleHtml ( 'Selection Sort Disadvantages' , selectionSortData . disadvantages ) ,
9898 applications : Helper . setListwithTitleHtml ( 'Selection Sort Applications' , selectionSortData . applications ) ,
9999 workingProcedure : Helper . setListwithTitleHtml ( 'Follow the below steps to solve the problem' , selectionSortData . workingProcedure ) ,
100- }
100+ }
101+
102+ // ------------------------------------- End ----------------------------------------------------------------//
103+
104+ // --------------------------------- Insertion Sort ---------------------------------------------------------//
105+
106+ const insertionSortData = {
107+ defination : `Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards
108+ in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part
109+ are picked and placed at the correct position in the sorted part` ,
110+ flowChart :"assets/ds-image/DSA1.jpg" ,
111+ explainImage :"assets/ds-image/DSA1.jpg" ,
112+ workingProcedure :[
113+ 'Iterate from arr[1] to arr[N] over the array' ,
114+ 'Compare the current element (key) to its predecessor' ,
115+ `If the key element is smaller than its predecessor, compare it to the elements before.
116+ Move the greater elements one position up to make space for the swapped element`
117+ ] ,
118+ properties :[
119+ 'This algorithm is one of the simplest algorithm with simple implementation' ,
120+ 'Basically, Insertion sort is efficient for small data values' ,
121+ 'Insertion sort is adaptive in nature, i.e. it is appropriate for data sets which are already partially sorted' ,
122+ 'Insertion sort is an in-place algorithm, meaning it requires no extra space' ,
123+ 'Maintains relative order of the input data in case of two equal values (stable)' ,
124+ `the bubble sort performs poorly compared to the insertion sort. Due to the high number of swaps,
125+ it's expected to generate twice as many write operations and twice as many cache misses` ,
126+ `Insertion sort's advantage is that it only scans as many elements as it needs in order to place the k+1st element,
127+ while selection sort must scan all remaining elements to find the k+1st element. Experiments show that insertion
128+ sort usually performs about half as many comparisons as selection sort`
129+ ] ,
130+ applications :[
131+ `One more real-world example of insertion sort is how tailors arrange shirts in a cupboard, they always keep them in sorted
132+ order of size and thus insert new shirts at the right position very quickly by moving other shirts forward to keep the right
133+ place for a new shirt`
134+ ] ,
135+ advantages : [
136+ `The main advantage of the insertion sort is its simplicity. It also exhibits a good performance when dealing with a small list.
137+ The insertion sort is an in-place sorting algorithm so the space requirement is minimal`
138+ ] ,
139+ disadvantages : [
140+ `The disadvantage of the insertion sort is that it does not perform as well as other, better sorting algorithms.
141+ With n-squared steps required for every n element to be sorted, the insertion sort does not deal well with a huge list.
142+ Therefore, the insertion sort is particularly useful only when sorting a list of few items`
143+ ] ,
144+ performance :[
145+ 'Worst-case performance of insertion sort is O(n²) comparisons and swaps' ,
146+ 'Best-case performance is O(n) comparisons and O(1) swaps' ,
147+ 'Average-case performance is O(n²) comparisons and swaps'
148+ ]
149+ }
150+
151+ export const insertionSortMetaData : Algorithms = {
152+ defination : Helper . setHeader ( insertionSortData . defination ) ,
153+ properties : Helper . setListwithTitleHtml ( 'Insertion Sort Properties' , insertionSortData . properties ) ,
154+ explainImage : Helper . setExampleImage ( 'Insertion Sort Explain Image' , insertionSortData . explainImage ) ,
155+ flowChart : Helper . setExampleImage ( 'Insertion Sort Flowchart' , insertionSortData . flowChart ) ,
156+ advantage : Helper . setListwithTitleHtml ( 'Insertion Sort Advantages' , insertionSortData . advantages ) ,
157+ disadvantage : Helper . setListwithTitleHtml ( 'Insertion Sort Disadvantages' , insertionSortData . disadvantages ) ,
158+ applications : Helper . setListwithTitleHtml ( 'Insertion Sort Applications' , insertionSortData . applications ) ,
159+ other : Helper . setListwithTitleHtml ( 'Insertion Sort Performance' , insertionSortData . performance ) ,
160+ workingProcedure : Helper . setListwithTitleHtml ( 'Follow the below steps to solve the problem' , insertionSortData . workingProcedure ) ,
161+ }
162+
163+ // ------------------------------------- End ----------------------------------------------------------------//
0 commit comments