Skip navigation
The Australian National University

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

  1. Run the stopwatch example covered in the lectures. Make sure you understand how it works. Try sorting vectors of different lengths.
  2. Use the above approach to compare the running times of the Matlab sort algorithm with the following that were covered in the lectures - bubble sort, quick sort and merge sort. Which one is the fastest?
  3. Use the profiling tool to profile the robots.m function that you wrote for your first assignment. Analyse the results.
  4. You are given the following piece of code:
            for i = 1:n
    	  for j = 1:i
    	    sum = sum + i;
    	  end
    	end
          
    How many basic operations are there? How many times is each one performed? Add them and estimate the running time of this code using O (big-Oh) notation. What does this represent?

Updated:  Mon May 13 11:22:15 EST 2013 / Responsible Officer:   JavaScript must be enabled to display this email address. / Page Contact:   JavaScript must be enabled to display this email address.