FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm-examples/cpp-algorithm/src/sort/insertion_sort.cpp at main · codejsha/algorithm-examples · GitHub
codejsha
/
algorithm-examples
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm-examples
/
cpp-algorithm
/
src
/
sort
/
insertion_sort.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (15 loc) · 384 Bytes
Breadcrumbs
algorithm-examples
/
cpp-algorithm
/
src
/
sort
/
insertion_sort.cpp
Copy path
File metadata and controls
17 lines (15 loc) · 384 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
include
"
sort.h
"
auto
Sort::InsertionSort
(std::vector<
int
>& seq) -> std::vector<int>
{
const
int
size =
static_cast
<
int
>(seq.
size
());
for
(
int
index =
1
; index < size; ++index)
{
int
key = index;
while
((key >
0
) && (seq[key] < seq[key -
1
]))
{
std::swap
(seq[key], seq[key -
1
]);
key--;
}
}
return
seq;
}
Back
|
FazBrowse Home
|
New Git URL