Laboratory 9 - Performance, Sorting and Searching
Aim
The aim of this lab is to get you familiar with performance and sorting/searching techniques.
Preparation
Please go through the slides for lectures 22-24. These cover performance and sorting/searching. As well, read chapters 16 and 22 of the textbook. Note that in order to get hold of chapter 22, you will need to download it from their website. Look up instructions in your copy of the text book for accessing online material. If you don't have a copy of the text book, then just follow the lecture slides and look up online for extra information. Try out the examples covered in the lectures and the text book.
Tools
The only tool you will need is the matlab programming environment. To use this, you will need to logon to a computer in one of the Computer Science labs, open up a terminal window and type the following from the command line:
matlab
Instructions
-
Run the
stopwatchexample covered in the lectures. Make sure you understand how it works. Try sorting vectors of different lengths. -
Use the above approach to compare the running times of the Matlab
sortalgorithm with the following that were covered in the lectures -bubble sort,quick sortandmerge sort. Which one is the fastest? -
Use the profiling tool to profile the
robots.mfunction that you wrote for your first assignment. Analyse the results. -
You are given the following piece of code:
for i = 1:n for j = 1:i sum = sum + i; end endHow many basic operations are there? How many times is each one performed? Add them and estimate the running time of this code usingO(big-Oh) notation. What does this represent?
