-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 07484e4
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="DAA_BUBBLE_SORT" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/DAA_BUBBLE_SORT" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/DAA_BUBBLE_SORT" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Unit filename="main.cpp" /> | ||
<Extensions> | ||
<lib_finder disable_auto="1" /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# depslib dependency file v1.0 | ||
1642604908 source:c:\users\nasreen parween\desktop\new folder\daa_bubble_sort\main.cpp | ||
<iostream> | ||
<fstream> | ||
<stdlib.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="1109" topLine="33" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
No. of Elements(n),No. of Comparision (count),n*n,n*logn | ||
30,420,900,147.2067179 | ||
50,1224,2500,282.1928095 | ||
70,2379,4900,429.0498112 | ||
90,3869,8100,584.2667787 | ||
110,5940,12100,745.9495685 | ||
130,8349,16900,912.9078157 | ||
150,11169,22500,1084.322804 | ||
170,13959,28900,1259.596459 | ||
190,17889,36100,1438.272566 | ||
210,21792,44100,1619.991559 | ||
230,26307,52900,1804.462712 | ||
250,31115,62500,1991.446071 | ||
270,36015,72900,2180.740211 | ||
290,41470,84100,2372.173636 | ||
310,47817,96100,2565.598566 | ||
330,54165,108900,2760.886331 | ||
350,60984,122500,2957.923889 | ||
370,68259,136900,3156.61114 | ||
390,75152,152100,3356.858822 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
#include<stdlib.h> | ||
using namespace std; | ||
template <class t> | ||
class bsort | ||
{ | ||
public: | ||
t a[500]; | ||
t n; | ||
void input(); | ||
void display(); | ||
int sort(); | ||
}; | ||
template <class t> | ||
void bsort<t>::input() | ||
{ | ||
int i; | ||
cout<<"\nEnter the number of elements:"; | ||
cin>>n; | ||
for(i=1;i<=n;i++) | ||
a[i]=rand()%100; | ||
} | ||
template <class t> | ||
void bsort<t>::display() | ||
{ | ||
for(int i=1;i<=n;i++) | ||
cout<<a[i]<<" "; | ||
} | ||
template <class t> | ||
int bsort<t>::sort() | ||
{ | ||
int temp,i,j,swap,count=0; | ||
for(i=1;i<=n;i++) | ||
{ | ||
swap=0; | ||
for(j=1;j<=(n-i);j++) | ||
{ | ||
if(a[j]>a[j+1]) | ||
{ | ||
temp=a[j]; | ||
a[j]=a[j+1]; | ||
a[j+1]=temp; | ||
swap=1; | ||
} | ||
count++; | ||
} | ||
if(swap==0) | ||
{ | ||
break; | ||
} | ||
} | ||
cout<<"\nArray after Sorting : "; | ||
display(); | ||
cout<<"\nThe number of Comparisons are : "<<count; | ||
return count; | ||
} | ||
int main() | ||
{ | ||
ofstream f("bubbleSort.csv"); | ||
int c; | ||
char ch='y'; | ||
while(ch=='y'||ch=='Y') | ||
{ | ||
bsort<int> i; | ||
i.input(); | ||
cout<<"\nElements of Array are : "; | ||
i.display(); | ||
c=i.sort(); | ||
if(f) | ||
{ | ||
f<<i.n<<","<<c; | ||
f<<endl; | ||
} | ||
cout<<"\nDo you wish to continue(y/n) : "; | ||
cin>>ch; | ||
} | ||
f.close(); | ||
return 0; | ||
} | ||
|
Binary file not shown.