Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % Welcome to Overleaf --- just edit your LaTeX on the left,
  4. % and we'll compile it for you on the right. If you give
  5. % someone the link to this page, they can edit at the same
  6. % time. See the help menu above for more info. Enjoy!
  7. %
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. \documentclass{article} % Loads settings for the document layout
  10. \usepackage{amsmath}
  11. \usepackage{graphicx}
  12. % Preambel
  13.  
  14. % The following settings are used for title generation and will show up in the
  15. % main document where the \maketitle command is set.
  16. \title{BBM204 Assignment I}
  17. \date{25.03.2017}
  18. \author{Sarp Cikis-21426792}
  19.  
  20. % Main document
  21.  
  22. \begin{document} % The document starts here
  23.  
  24. \maketitle % Creates the titlepage
  25. \pagenumbering{gobble} % Turns off page numbering
  26.  
  27. \newpage % Starts a new page
  28. \pagenumbering{arabic} % Turns on page numbering
  29.  
  30. \section{Part I: Running Time Analysis}
  31.  
  32.  
  33. \subsection{Analysis algorithm and finding the tilde notation}
  34.  
  35. \begin{figure}[h!]
  36. \caption{Code and time analysis}
  37. \centering
  38. \includegraphics[width=\textwidth]{V269Ldw.png}
  39. \end{figure}
  40.  
  41. \begin{equation*}
  42. Total Cost = c1+c2*(log(n)+1)+c3+c4*(log(n)+1)*log(n)+c5*log(n)*log(n)+c6*log(n)*log(n)+c7*log(n)
  43. \end{equation*}
  44. The time required for this algorithm is proportional to $log(n)^2$.
  45.  
  46. \subsection{5 Algorithms}
  47.  
  48. \begin{figure}[h!]
  49. \caption{Algorithm time-table as microseconds}
  50. \centering
  51. \includegraphics[width=\textwidth]{4AY5UHB.png}
  52. \end{figure}
  53.  
  54. From the table we can see that the stooge sort algorithm is the slowest working one by a long mile. Followed by Shaker sort algorithm and the Radix sort algorithm respectively. Unsurprisingly Maximum sub-array algorithm and Finding the second largest element function are much faster working functions, since they don't have to sort the arrays just make operations on them. This makes it so they don't have to use their time moving elements in an array(or list) which is a very time consuming operation.
  55.  
  56. \newpage
  57.  
  58. \begin{figure}
  59. \caption{Table of time as microseconds without stooge sort algorithm}
  60. \centering
  61. \includegraphics[width=\textwidth]{m1trdcs.png}
  62. \end{figure}
  63.  
  64. I had to make two different graphs since stooge sort takes up so much more time than the other algorithms. To make any kind of sense from a graph i had to take stooge sort out of it.
  65.  
  66. \begin{figure}[h!]
  67. \caption{Table of time as microseconds with the stooge sort algorithm}
  68. \centering
  69. \includegraphics[width=\textwidth]{3JvYnFm.png}
  70. \end{figure}
  71.  
  72. As i said we can clearly see from this graph that stooge sort algorithm takes up extremely high resources and its time to run increases exponentially with the amount of randomly generated elements in an array.
  73.  
  74. \subsubsection{Big o notation of functions}
  75. \begin{figure}[h!]
  76. \caption{Second highest function}
  77. \centering
  78. \includegraphics[width=\textwidth]{zP5QOHN.png}
  79. \end{figure}
  80.  
  81. The second highest function takes O(n) time to find the second highest element of a list.
  82.  
  83. \begin{figure}[h!]
  84. \caption{Stooge sort algorithm}
  85. \centering
  86. \includegraphics[width=\textwidth]{TlGBOxE.png}
  87. \end{figure}
  88.  
  89. Stooge sort algorithm takes $O(n^{log(3)/log(1.5)})$ time to which is roughly equal to $O(n^{2.7095)})$ which makes Stooge sort the slowest algorithm by a long shot.
  90. \newpage
  91. \begin{figure}[h!]
  92. \caption{Radix sort algorithm}
  93. \centering
  94. \includegraphics[width=\textwidth]{mL7QlBz.png}
  95. \end{figure}
  96. Radix sort algorithm takes O(wn) time to sort for n keys which are integers of word size w which makes radix sort better than most compassion based sorting algorithms for sufficiently large size of lists.
  97.  
  98. \begin{figure}[h!]
  99. \caption{Cocktail shaker sort algorithm}
  100. \centering
  101. \includegraphics[width=\textwidth]{7UVopLP.png}
  102. \end{figure}
  103. Cocktail shaker sort algorithm takes $O(n^2)$ time to run.
  104.  
  105. \subsection{Question}
  106. \begin{figure}[h!]
  107. \caption{Question}
  108. \centering
  109. \includegraphics[width=\textwidth]{url.png}
  110. \end{figure}
  111. For an input size of 220 it would take 1129259.31977 operations to execute the algorithm if our hardware can perform $10^6$ operations per second it would take 1.12925931977 seconds to complete the algorithm which is closest to 1 the answer is A.
  112. \end{document} % The document ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement