Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
18305R006-18305R009-18305R010-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
RAMEESH PAUL
18305R006-18305R009-18305R010-git
Commits
af6014b3
Commit
af6014b3
authored
Sep 21, 2018
by
ShahRukh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update merge-sort to reflect API update
parent
9e7f74fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
sorting.cpp
sorting.cpp
+28
-7
No files found.
sorting.cpp
View file @
af6014b3
...
@@ -27,18 +27,18 @@ vector<int> merge(vector<int> first,vector<int> second){
...
@@ -27,18 +27,18 @@ vector<int> merge(vector<int> first,vector<int> second){
if
(
left
==
1
){
if
(
left
==
1
){
v
.
push_back
(
first
[
countFirst
]);
v
.
push_back
(
first
[
countFirst
]);
if
(
first
.
size
()
>
countFirst
){
if
(
first
.
size
()
>
countFirst
){
countFirst
+=
1
;
countFirst
+=
1
;
}
}
}
}
else
{
else
{
v
.
push_back
(
second
[
countSecond
]);
v
.
push_back
(
second
[
countSecond
]);
if
(
second
.
size
()
>
countSecond
){
if
(
second
.
size
()
>
countSecond
){
countSecond
+=
1
;
countSecond
+=
1
;
}
}
}
}
}
}
...
@@ -57,8 +57,29 @@ vector<int> mergeSorting(vector<int> v){
...
@@ -57,8 +57,29 @@ vector<int> mergeSorting(vector<int> v){
}
}
vector
<
int
>
sort_custom
(
vector
<
int
>
v
){
vector
<
int
>
sort_custom
(
vector
<
int
>
v
,
int
startidx
,
int
endidx
){
vector
<
int
>
sortVec
=
mergeSorting
(
v
);
return
sortVec
;
int
size
=
v
.
size
();
if
(
size
<
endidx
||
startidx
>
endidx
)
{
cout
<<
"Invalid Input "
;
vector
<
int
>
v
;
return
v
;
}
else
{
vector
<
int
>
initVector
(
v
.
cbegin
(),
v
.
cbegin
()
+
startidx
);
vector
<
int
>
subVector
(
v
.
cbegin
()
+
startidx
,
v
.
cbegin
()
+
endidx
+
1
);
vector
<
int
>
endVector
(
v
.
cbegin
()
+
endidx
+
1
,
v
.
cend
());
vector
<
int
>
sortVec
=
mergeSorting
(
subVector
);
initVector
.
insert
(
initVector
.
end
(),
sortVec
.
begin
(),
sortVec
.
end
()
);
initVector
.
insert
(
initVector
.
end
(),
endVector
.
begin
(),
endVector
.
end
()
);
return
initVector
;
}
}
}
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