This coursework is worth 50 marks representing 10% of your total course grade. Objectives: Learning basic techniques of the time complexity analysis, in particular, how to evaluate complexity of a given piece of Java code, analyse performance of algorithms with the Big-Oh notation, solve basic recurrences describing the performance, and sorting and searching algorithms.
Please read the following passage of text carefully:
Report: Your have to submit this coursework as a report in “pdf” format. You may prepare the report using an appropriate text editor, such as e.g. MS Word or LaTeX, which can output a “pdf”. Scanned handwritten documents are strictly forbidden (even as images included into an electronic text) and will not be accepted for marking.
Submission: The due date is Wednesday, 19th of November 2014, 11:59 p.m.
(Malaysian Time). If submitted after due date, the penalty is 5% for each day.
Submission must be through Moodle.
Marking Scheme:
Clear structure of your report and detailed explanations
% marks up to 30
Correctness of your final answers
up to 30
Correctness of your intermediate steps in deriving these answers
up to 40
100%
You should give detailed answers to all the following questions.
©Abdur Rakib 2014
Page 1
G52ADS: Coursework 1 on complexity analysis, Autumn abstract data types, and sorting algorithms 2014/15
Question 1.
(a) How many times does “time complexity” get printed in the following code fragment? Analyse and state the time complexity of this code using
Big-O notation, and in words.
int n; void funnyFunction(int n)
{
int count = 0; if (n > 1) funnyFunction(n-1); for(count =0; count< n; count++) print(“time complexity”);
}
[5 marks]
(b) Analyse and state the time complexity of the following function in terms of Big-O notation, and in words.
int peculiarFunction (int n){ if (n < 100) return 1; return n * peculiarFunction