Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gitlab-inlab
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
codecatalyst33
gitlab-inlab
Commits
d8da72d4
Commit
d8da72d4
authored
Aug 10, 2017
by
CHINTHAREDDY SAI CHARITH REDDY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload new file
parent
61c63d74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
lab1/new_dr/problem3.cpp
lab1/new_dr/problem3.cpp
+49
-0
No files found.
lab1/new_dr/problem3.cpp
0 → 100644
View file @
d8da72d4
#include <algorithm>
#include<iostream>
#include<ctime>
#include<cstdlib>
using
namespace
std
;
int
main
(){
int
n
=
100
,
a
[
n
];
int
count
=
0
;
int
i
=
50
;
for
(
int
i
=
0
;
i
<
n
;
i
++
){
a
[
i
]
=
i
+
1
;
}
//random_shuffle(a,a+n);
int
found
=
1
;
int
start
=
clock
();
while
(
found
!=
0
){
found
=
0
;
for
(
int
j
=
0
;
j
<
n
-
1
;
j
++
){
if
(
a
[
j
]
>
a
[
j
+
1
])
{
int
temp
=
a
[
j
];
a
[
j
]
=
a
[
j
+
1
];
a
[
j
+
1
]
=
temp
;
found
++
;}
}
}
found
=
1
;
int
k
=
n
;
//random_shuffle(a,a+n);
int
stop
=
clock
();
cout
<<
stop
-
start
<<
" "
;
start
=
clock
();
while
(
found
!=
0
){
found
=
0
;
for
(
int
j
=
0
;
j
<
k
-
1
;
j
++
){
if
(
a
[
j
]
>
a
[
j
+
1
])
{
int
temp
=
a
[
j
];
a
[
j
]
=
a
[
j
+
1
];
a
[
j
+
1
]
=
temp
;
found
++
;}
}
k
--
;
}
stop
=
clock
();
cout
<<
stop
-
start
<<
" "
;
}
/*
time taken to sort 100 distinct numbers is 138
time taken to sort 100 distinct numbers using improvised bubblesort is 95
time taken to sort 100 sorted distinct numbers is 2
time taken to sort 100 distinct numbers using improvised bubblesort is 2
*/
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