"K Nearest and Furthest Points in M-Dimensional Space
"K Nearest and Furthest Points in M-Dimensional Space
"K Nearest and Furthest Points in M-Dimensional Space
+ +
O
O
Worst case:
) (
arg
3 15 12 11
2 2
2
n n t
e l n
for
n mn n t
o
o
O ~
+ + +
(n
2
) O(n
2
) = (n
2
).
The total time taken by the algorithm, hence is
dependent of two factors, total number of points and
size of dimensional space.
4. PROFILING:
As seen in the a priori analysis, total time taken by the
program to execute is dependent on two factors, that is
total number of points in space, and dimensions of the
space.
For the above reason a posteriori analysis has been
done by first considering size of dimensions constant
and varying only number of points whose table of
values is shown below.
3
n Best case Worst case Average
5 270 430 356.5833
10 690 1410 1081.833
15 1260 2970 2093.667
20 1980 5020 3582
25 2850 7650 5541.833
30 3870 10830 6807.5
Table 4.1 Values by keeping constant dimensions.
The graph below has been generated from the table of the
values were generated from the experiment.
The graph shows a quadratic relationship between the
computing time and the size of the list for both best and
worst cases. There exists an average case which lies
averagely between the best and worst case.
Lastly by considering the variation in dimensions and
keeping number of points constant as shown in the table of
the values below.
M Time
2 1260
3 1440
4 1620
5 1800
6 1980
7 2160
Table 4.2 Values by keeping points constant.
The graph below has been generated from the table of the
values were generated from the experiment
We observe that time complexity is linear
5. CONCLUSION
In conclusion the time complexity of the algorithm is
depends on the method of sorting we using it in the
algorithm, here we using bubble sort method, so the
time complexity is ) (
2
n u in n where n represents the
number of points in the neighborhood. If a better
sorting technique like merge sort was used in the above
algorithm then time complexity would be n nlog .
The space complexity is depend on the size of
dimension space, and the calculated distance values are
stored in one-dimensional array whose size depends on
size of the inputs, and some temporary variables.
Reference
[1] R.G Dromey, How to solve by computer, Prentice
Hall of India, New Delhi, 2004.
[2] Horowitz, Sahni, Rajasekaran, Fundamentals of
computer algorithms, Glogotia Publisher New Delhi
2004.
[3] Steven C. Chapra and Raymond P. Canale,
Numerical methods for engineers, Tata Mcgraw
Hill, new Delhi 2004.