-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsertion.html
86 lines (75 loc) · 2.73 KB
/
insertion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insertion Sort</title>
<style>
body {
margin: auto;
padding: auto;
background: url("insert.jpg");
height: auto;
width: auto;
background-repeat: no-repeat;
}
section div {
font-size: 45px;
font-family: sans-serif;
color: rgb(231, 231, 231);
margin: 42px 190px 0px 60px;
}
article img {
width: 450px;
padding: 30px;
margin: 0px 0px 0px 35px;
}
.description {
color: rgb(231, 231, 231);
width: 961px;
margin: 8px 15px 0px 60px;
}
article p {
color: rgb(231, 231, 231);
float: right;
padding: 0px 0px 0px 0px;
margin: 100px 510px 0px 0px;
}
</style>
</head>
<body>
<section>
<div>
Insertion Sort
</div>
</section>
<article>
<p>
Average Complexity O(n2) <br><br>
Best Case O(n) <br><br>
Worst Case O(n2) <br><br>
Space Complexity O(1) <br><br>
</p>
<img src="insertionsort.png" alt="sorting">
</article>
<div class="description">
Description:<br>
Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands.
The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and
placed at the correct position in the sorted part.
<br>
Sorting is typically done in-place, by iterating up the
array, growing the sorted list behind it. At each array-position, it checks the value there against the largest
value in the sorted list (which happens to be next to it, in the previous array-position checked). If larger, it
leaves the element in place and moves to the next. If smaller, it finds the correct position within the sorted
list, shifts all the larger values up to make a space, and inserts into that correct position.
<br><br>
Uses: Insertion sort is used when number of elements is small. It can also be useful when input array is almost
sorted, only few elements are misplaced in complete big array.
<br><br>
Boundary Cases: Insertion sort takes maximum time to sort if elements are sorted in reverse order. And it takes
minimum time (Order of n) when elements are already sorted.
</div>
</body>
</html>