CS
202 Fundamental Structures of Computer Science II
Assignment 1 – Algorithm Efficiency and Sorting
Due Date: 7 October 2013 (Monday)
Question-1 (30 points)
Trace
the following sorting algorithms for sorting the array: 7 6 1
3 5 2 into ascending order. Use the array implementation
as described in the textbook/lectures.
a) Insertion sort.
b) Selection
sort.
c) Bubble
sort.
d) Merge sort. Also list the
calls to mergesort and merge in the order in which they
occur.
e) Quick sort. Also list the
calls to quicksort and partition in the order in which they
occur. Assume that the last item is chosen as pivot.
Question-2 (60 points) – Programming Assignment
You are asked to implement the sorting algorithms
selection sort and quicksort for linked lists of integers and then perform some measurements. For quicksort, take the first element of the linked list as
pivot. The details are as follows:
Question-3
(10 points)
Compare
your empirical results with the theoretical one for each sorting algorithm
(Explain any differences between the empirical and theoretical results, if
any).
Hand-in:
·
You should submit both the softcopy and hardcopy
of your homework.
· Before 6:00 pm of October 7, 2013, send an e-mail, with subject title CS202 HW1, to your TA, Mecit Sarı (mecit.sari@bilkent.edu.tr), attaching one zipped file which contains:
Ø hw01.doc, the file containing the answers to Questions 1 and 3, the sample output of the program and graphical representation of the experiments for Question 2, and
Ø hw01.cpp and hw01.h (if needed), the files containing the C++ source code and the non-standard library used in Question 2, and
Ø readme.txt, the file containing anything important on the compilation and execution of your program in Question 2.
· The subject field of your e-mail must be CS202 HW1, otherwise, it may be considered as one of the junk e-mails!
· In the first lecture on October 7, 2013, turn in the hardcopy of your homework which includes solutions to all questions. The hardcopy should be identical to the files zipped in your e-mail. Make sure that your homework contains your name, student id, and section number; otherwise, it will not be graded.
· Do not forget to put your name in the header comments in both hw01.cpp and hw01.h.
· Keep all the files before you receive your grade.
·
DO THE HOMEWORK YOURSELF.
·
PLAGIARISM AND CHEATING ARE HEAVILY PUNISHED.