Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
18305R002-git
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KERKAR NEERAJ VIKAS SNEHA
18305R002-git
Commits
2c47e1f5
Commit
2c47e1f5
authored
Sep 24, 2018
by
Neeraj Kerkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update merge-sort to reflect API update
parent
2b3f2357
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
sorting.cpp
sorting.cpp
+13
-3
No files found.
sorting.cpp
View file @
2c47e1f5
...
...
@@ -42,7 +42,7 @@ vector<int> merge(const vector<int>& left, const vector<int>& right)
return
result
;
}
vector
<
int
>
sort_custom
(
vector
<
int
>
vec
)
vector
<
int
>
merge_sort
(
vector
<
int
>
vec
)
{
// Termination condition: List is completely sorted if it
// only contains a single element.
...
...
@@ -58,9 +58,19 @@ vector<int> sort_custom(vector<int> vec)
vector
<
int
>
right
(
middle
,
vec
.
end
());
// Perform a merge sort on the two smaller vectors
left
=
sort_custom
(
left
);
right
=
sort_custom
(
right
);
left
=
merge_sort
(
left
);
right
=
merge_sort
(
right
);
return
merge
(
left
,
right
);
}
vector
<
int
>
sort_custom
(
vector
<
int
>
a
,
int
start
,
int
end
){
vector
<
int
>
b
;
for
(
int
i
=
0
;
i
<
a
.
size
();
i
++
){
if
(
i
>=
start
||
i
<=
end
){
b
.
push_back
(
a
[
i
]);
}
}
return
merge_sort
(
b
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment