Row Sorting in MATLAB With Best Efficiency-M. Ganesh Sai

Row sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted through the rows in the matrix swapping each row if they are in the wrong order. The pass through the matrix is repeated until no swaps are needed, which indicates that the matrix is sorted. The algorithm gets its name from the way that the each row is sorted in the matrix.

 

Illustrative Example

           Let us take the matrix form , and sort the each row step by step from lowest number to greatest number using row sort. In each step, elements written in bold are being sorted. Five steps will be required.

 

                                                         95       45       92       41       13

                                                         73       89       20       74       52

                                                         05       19       44       20       73

                                                         40       35       60       93       67

                                                         81       27       46       83       93

 

First step:

First sort the row 1 elements in the matrix form.

95     45     92   41     13                                                       13   41   45   92   95

73     89     20   74     52                                                       73   89   20   74   52

05     19     44    20     73                           →                        05   19   44   20   73

40     35     60   93     67                                                       40   35   60   93   67

81     27   46   83     93                                                         81     27   46   83   93

 

Second step:

Sort the row 2 elements in the matrix form.

95     45     92   41     13                                                       95   45   92   41   13

73     89     20   74     52                                                       20   52   73   74   89

05     19     44   20     73                           →                         05   19   44   20   73

40     35     60   93     67                                                       40   35   60   93   67

81     27   46   83     93                                                         81     27   46   83   93

 

Third step:

Sort the row 3 elements in the matrix form.

95     45     92   41     13                                                      95   45   92   41   13

73     89     20   74    52                                                       73   89   20   74   52

05     19     44   20     73                           →                       05   19   20   44   73

40     35     60   93     67                                                      40   35   60   93   67

81     27   46   83     93                                                        81     27   46   83   93

 

Fourth step:

Sort the row 4 elements in the matrix form.

95     45     92   41     13                                                      95   45   92   41   13

73     89     20   74     52                                                      73   89   20   74   52

05     19     44   20     73                           →                       05   19   44   20   73

40     35     60   93     67                                                      35   40   60   67   93

81     27   46   83     93                                                        81     27   46   83   93

 

Fifth step:

Sort the row 5 elements in the matrix form.

95     45     92   41     13                                                        95   45   92   41   13

73     89     20   74     52                                                        73   89   20   74   52

05     19     44   20     73                           →                          05   19   44   20   73

40     35     60   93     67                                                        40   35   60   93   67

81     27   46   83     93                                                          27     46   81   83   93

 

Finally sorted rows in the matrix is shown below:

95     45     92   41     13                                                      13   41   45   92   95

73     89     20   74     52                                                      20   52   73   74   89

05     19     44   20     73                           →                       05   19   20   44   73

40     35     60   93     67                                                      35   40   60   67   93

81     27   46   83     93                                                        27     46   81   83   93

 

Output Table of Row Sorting in Matlab with better efficiency is given below.

Row

           3X3

 

          5X5

 

        7X7

 

         9X9

 

Noise Density

psnr

Time

Psnr

Time

Psnr

time

psnr

Time

10%

31.82

3.04

32.03

3.00

31.85

2.97

32.07

3.03

20%

28.58

3.03

28.15

2.93

28.67

3.07

28.58

2.92

30%

26.20

3.00

25.95

2.89

25.93

2.92

26.21

2.85

40%

24.12

2.84

23.91

2.81

24.21

2.92

24.14

2.85

50%

22.11

2.75

22.09

2.67

22.15

2.85

22.13

2.79

60%

20.66

2.72

20.53

2.70

20.40

2.73

20.43

2.67

70%

18.74

2.69

18.84

2.58

18.76

2.58

18.41

2.66

80%

16.67

2.52

16.53

2.52

16.77

2.47

16.51

2.54

90%

14.02

2.35

13.99

2.35

14.09

2.39

14.23

2.34

//

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s