diff --git a/lab10/lab10 b/lab10/lab10 new file mode 100644 index 0000000000000000000000000000000000000000..5e92ccd0666cc1a0685bf78c335c136acd8fb054 --- /dev/null +++ b/lab10/lab10 @@ -0,0 +1,41 @@ +Q1: + +in the table, wherever stated f(n) = xxxx, it means the data in that line is T(n) /f(n) + +T(n): seems to be increasing til infinity --> bound below loosely by a constant +f(n) = n: T(n)/n seems to be increasing to infinity --> it is bound below loosely by a line +f(n) = n^2: it is moving towards 0, although it did slows down but the trend is unlikely to reach a constant --> can say that it is bound above lightly by n2 although tighter than n^3 +f(n) = n^3: seems to be decreasing too --> bound loosely above by a n^3 function + +f(n) = nlog(n) seems to be the one with trend approaching a constant fastest ==> can say that T(n) grows similarly to a nlog(n) function + + + n T(n) f(n)=n*10^5 f(n)=nlog(n) f(n)=n^2*10^9 f(n)=log(n)*10^5 f(n)=n^3*10^6 + 1000 0.1900 19.0000 27.5053 190.0000 2750.5317 19.0000 + 10000 2.2400 22.4000 24.3205 22.4000 24320.4910 0.2240 + 20000 4.1100 20.5500 20.7503 10.2750 41500.5318 0.0514 + 30000 5.8000 19.3333 18.7539 6.4444 56261.7774 0.0215 + 40000 7.9000 19.7500 18.6380 4.9375 74551.9705 0.0123 + 50000 11.2200 22.4400 20.7398 4.4880 103698.9826 0.0090 + 60000 14.2600 23.7667 21.6019 3.9611 129611.6215 0.0066 + 70000 15.0400 21.4857 19.2589 3.0694 134812.3186 0.0044 + 80000 20.8100 26.0125 23.0407 3.2516 184325.9698 0.0041 + + + +Q2: +f(n) = n gives the numbers of swaps goes to nfinity as n goes to infinity ---> it is a lower bound +f(n) = nlog(n) was pretty close to being the theta to T(n) but it still has the decrease trend --> upper bound but much tighter than n^2 +f(n) = n^2 decreases fast towards 0 --> loose upper bound +f(n) = log(n) increases --> lower bound + + n T(n) f(n) = n f(n) = nlog(n) f(n) = n^2 f(n) = log(n) f(n) = n^2log(n) + 1000 3425457 3425.457 1141.819 3.425457 1141819 0.168930947 + 10000 45721062 4572.1062 1143.02655 0.45721062 11430265.5 0.114387598 + 20000 98107982 4905.3991 1140.517296 0.245269955 22810345.92 0.057025093 + 30000 153522280 5117.409333 1143.013343 0.170580311 34290400.3 0.038183995 + 40000 210173451 5254.336275 1141.735719 0.131358407 45669428.78 0.028994489 + 50000 265180908 5303.61816 1128.676743 0.106072363 56433837.15 0.022509831 + 60000 319847373 5330.78955 1115.65944 0.088846493 66939566.42 0.018502093 + + Through these 2 tables, the data still show that the quicksort program still grows most similar with theta(nlog(n)) despite the differencce in the method of comparison: time measurement and counting number of swap function calls.