Escolar Documentos
Profissional Documentos
Cultura Documentos
1. Selection Sort
2. Insertion Sort
3. Bubble Sort
4. Quick Sort
5. Merge Sort
6. Shell Sort
Sample codes will be as below. In MATAB, this can be used to compare any
numeric data type such as uint8, uint16, int8, int16, double, etc. But in case of
JAVA and C++ I wrote them to work with integers. Since I am new to C++ I some
good points in using arrays/pointers with C++, such as how to initialize an array
with a length which is an argument of that function, to get the size of an array, etc.
These codes may not be the optimised codes for above algorithms but a small
attempt to implement those on three platforms.
Selection Sort
Selection sort is a comparison sort with O(n2) timing complexity making in-
efficient on large sets. In this algorithm the element on active position (say
ith position) is compared with other positions (say i+1th to nth position) and swaps if
its larger than the compared element.
MATLAB
JAVA
C++
Insertion Sort
Insertion sort is a comparison sort algorithm which works similar to the way we
arrange the cards in a hand. We take one element at a time, starts compare from
one end and them place them in between the card lesser and greater than it.
MATLAB
JAVA
C++
Bubble Sort
Bubble sort is a simple algorithm which compares neighbouring elements and
swaps them if they are not in the order.
MATLAB
JAVA
C++
Quick Sort
MATLAB
JAVA
C++
Merge Sort
Merge sort is an algorithm with O(n.log(n)) timing complexity for all cases. This
algorithm is a divide and conquer algorithm. Merge sort has two parts which
comparison and merging part.
MATLAB
JAVA
C++
void SortAlgo::merge(int merged[], int lenD, int L[], int lenL, int R[],
int lenR){
int i = 0;
int j = 0;
while(i<lenL||j<lenR){
if (i<lenL & j<lenR){
if(L[i]<=R[j]){
merged[i+j] = L[i];
i++;
}
else{
merged[i+j] = R[j];
j++;
}
}
else if(i<lenL){
merged[i+j] = L[i];
i++;
}
else if(j<lenR){
merged[i+j] = R[j];
j++;
}
}
}
Shell Sort
Shell sort is a generalised form of insertion sort algorithm which improved the
performance of insertion sort.
MATLAB
JAVA
C++
Rate this:
17
Rate This
Share this:
inShare
More
Like this:
Like Loading...
Related
Digital Image Zooming Sample Codes on MATLAB
In "Image Processing"
16 Comments
1. Thanks !!!
6. Thanks
Comment by sajmax1992 | 2012 December 30 | Reply
9. It was amazing to understand the algorithm and sample code example. Keep
rocking
****new int[lenD];
12. thank you so mach silina whit the best wishes for you
i am farzane from iran
Leave a Reply
Previous | Next
About
Search
Search for:
Categories
o WildLife (3)
o Biomedical (2)
o C++ (2)
o Electronics (9)
o FPGA (7)
o Image Processing (20)
Chroma Keying (5)
o ITK (1)
o Java (2)
o MATLAB (27)
o SolidWorks (1)
o Technology (13)
o Ubuntu (1)
o VTK (1)
Ask from Thilina
Live Feed
Follow
June 2011
S M T W T F S
May Jul
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
RSS - Posts
Blog Hits
o 149,243 hits
Visitors
Clustr Maps
Top Of Blogs
My Networked Blogs
NetworkedBlogs
Blog:
Thilina's Blog
Topics:
Technology, Image Processing, Electronics
Follow my blog
Goodreads
Goodreads: currently-reading
by Dennis Overbye
by Jimmie Gilbert
Matrix Computations (Johns Hopkins Studies in Mathematical Sciences)
by Gene H. Golub
by Allan Pease
by K.C. Chang
Site info
Thilina's Blog
The Andreas04 Theme.
Follow
Sign me up
Powered by WordPress.com
%d bloggers like this: