-
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
1 parent
9fe98eb
commit b634921
Showing
9 changed files
with
132 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_INSERSTION_SORT" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/DAA_INSERSTION_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_INSERSTION_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 | ||
1642004338 source:c:\users\nasreen parween\desktop\new folder\daa_inserstion_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="1231" topLine="46" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
Binary file not shown.
Empty 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,76 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <stdlib.h> | ||
using namespace std; | ||
|
||
template <class t> | ||
class isort | ||
{ | ||
public: | ||
t a[500]; | ||
t n; | ||
void input(); | ||
void display(); | ||
int Sort(); | ||
}; | ||
template <class t> | ||
void isort<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 isort<t> :: display() | ||
{ | ||
for(int i=1; i<=n; i++) | ||
cout<<a[i]<<" "; | ||
} | ||
template<class t> | ||
int isort<t>:: Sort() | ||
{ | ||
int i,j,key,count=0; | ||
for(j=2; j<=n; j++) | ||
{ | ||
key=a[j]; | ||
i=j-1; | ||
while(i>0&&a[i]>key) | ||
{ | ||
a[i+1]=a[i]; | ||
i--; | ||
count++; | ||
} | ||
count++; | ||
a[i+1]=key; | ||
|
||
} | ||
cout<<"\nTHE ARRAY AFTER SORTING:"; | ||
display(); | ||
cout<<"\nTHE NUMBER OF COMARISIONS ARE :"<<count; | ||
return count; | ||
} | ||
int main() | ||
{ | ||
ofstream f("insertionSort.csv"); | ||
int c; | ||
char ch='y'; | ||
while(ch=='y'||ch=='Y') | ||
{ | ||
isort<int>i; | ||
i.input(); | ||
cout<<"THE ELEMENTS OF AN ARRAY ARE :"<<endl; | ||
i.display(); | ||
c=i.Sort(); | ||
if(f) | ||
{ | ||
f<<i.n<<","<<c; | ||
f<<endl; | ||
} | ||
cout<<"\n...Do you want to continue ?(y/n)..."<<endl; | ||
cin>>ch; | ||
} | ||
f.close(); | ||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.