You are on page 1of 25

Algorithms and their Applications CS2004 2010-2011

Dr Stephen Swift Click to edit Master subtitle style 16.1 Exam Revision

Introduction
This lecture is a revision lecture for the exam for this module nThe exam is on Tuesday 10th May at 2pm nIn this lecture we are going to cover:
n

The assessment nThe format of the exam nExam topics nSome example questions
n

CS2004 Exam Revision

2Slide 2

Assessment The overall structure for the assessment is as follows:


n

50% Coursework (done) n10% Laboratory work sheets (done) n40% Exam (pending)
n

CS2004 Exam Revision

3Slide 3

Exam
n

A two hour exam


n

The location should now be available A multiple choice part A worth 40% An essay-type question part B worth 60%

This will consist of:


n n

All questions should be attempted


n
CS2004 Exam Revision 4Slide 4

What to Revise Part 1


The exam will cover the theoretical aspects of the module nThere will be no programming needed
n
n

No questions on Java or Eclipse

However you may need to understand and/or write some pseudo code
n
CS2004 Exam Revision 5Slide 5

What to Revise Part 2


Topics could include (not restricted to):
n
n

Algorithmic concepts
n

What is an algorithm, a program, etc T(n) and O(n) Stacks, lists, arrays, queues, etc Bubblesort, Quicksort, etc

Time Complexity and Asymptotic Notation


n

Data structures
n

Sorting Algorithms
n

CS2004 Exam Revision

6Slide 6

What to Revise Part 3


Topics could include (not restricted to):
n
n

Graph Traversal Algorithms


n

Depth First, Breadth First, A*, MST, etc Search, Search Space, Fitness, Parameter optimisation, etc... HC, SHC, RRHC, SA, ILS, etc... Genetic Algorithms, PSO, ACO, etc... Bin Packing, Data Clustering, TSP, etc...

Search
n

Heuristic Search Methods


n

Evolutionary Computation and Other Methods


n

Applications
n

CS2004 Exam Revision

7Slide 7

Exam Part A Part 1 Multiple choice questions (40%)


n

Choose an answer from a list of options n20 questions of 2 marks each nSpend about 2 minutes per question nUse the multiple choice answer sheet
n

CS2004 Exam Revision

8Slide 8

Exam Part A Part 2


Good strategies for multiple choice questions:
n

Read through all of the questions first nAnswer the ones that you know first nDo NOT spend too much time on a single question nOften ruling out answers can reduce the options down to a few nDo not leave any blank!
n

CS2004 Exam Revision

9Slide 9

Exam Part B Part 1


n

Essay type questions


4 questions of 15 marks nSpend approximately 15 minutes per question nWrite your answers in the answer book
n

CS2004 Exam Revision

10Slide 10

Exam Part B Part 2


Good strategies for essay type questions:
n

Read through all of the questions first nAnswer the ones that you know first nDo NOT spend too much time on a single question nSketching a draft answer can help in laying out complex answers nCross out anything you do not want marked
n

CS2004 Exam Revision

11Slide 11

Example Multiple Choice Part 1


n

What is pseudo code?


n

a) A Java program nb) A programming language independent description of an algorithm nc) The intermediate code produced by the Java compiler nd) An algorithmic description of a computer program ne) None of the above CS2004 Exam Revision 12Slide 12

Example Multiple Choice Part 2


Algorithm A runs in time complexity O(n2), algorithm B in O(n3) and algorithm C in O(n2). Which of the following statements is true?
n

a) Algorithm B is always faster than C nb) Algorithm A and C are the same nc) Algorithm A is slower than Algorithm B nd) Algorithm A and C are asymptotically similar in performance ne) None of the above
n

CS2004 Exam Revision

13Slide 13

Example Multiple Choice Part 3


Which of the following data structures would be appropriate for storing a list of names and addresses?
n

a) A stack nb) A queue nc) An array nd) A linked list ne) It depends on the application
n

CS2004 Exam Revision

14Slide 14

Example Multiple Choice Part 4


Which of the following is not part of a graph:
n

a) An arrow nb) A node nc) An edge nd) A vertex ne) An arc


n

CS2004 Exam Revision

15Slide 15

Example Multiple Choice Part 5


What is the fastest time that the following list of number could be sorted in descending order: {10,9,8,7,6,5,4,3,2,1}
n

a) No time it is already sorted nb) O(n) nc) O(nln(n)) nd) O(n2) ne) It depends on the algorithm
n

CS2004 Exam Revision

16Slide 16

Example Multiple Choice Part 6


n

A* search can be used for:


a) Finding the shortest route between two stations on the underground nb) Optimising the parameters of a Neural Network nc) Organising similar objects into mutually exclusive sets nd) Creating compilation CDs ne) Decision Planning
n

CS2004 Exam Revision

17Slide 17

Example Multiple Choice Part 7


Which of the following Heuristic Search Methods is the odd one out?
n

a) Random Restart Hill Climbing nb) Stochastic Hill Climbing nc) Genetic Algorithm nd) Hill Climbing ne) Simulated Annealing
n

CS2004 Exam Revision

18Slide 18

Example Multiple Choice Part 8


Which of the following statements is true regarding bin packing and data clustering?
n

a) Bin packing is slower than data clustering nb) Bin packing is used on small sized objects whilst data clustering is used on large objects nc) Both algorithms arrange objects into groups nd) Bin packing is used on 1-dimensional data whilst data clustering can be used on ndimensional data ne) They perform the same function
n

CS2004 Exam Revision

19Slide 19

Example Essay Type Part 1


n

Consider the following algorithm:

Algorithm 1. MaxArray(A) Input: An n row by m column Array A 1) Let max = element 1,1 (A(1,1)) of Array A 2) For i = 1 to n 3) For j = 1 to m 4) If A(i,j) > max Then 5) Let max = A(i,j) 6) End If 7) End For 8) End For Output: max- the largest element in array A CS2004 Exam Revision 20Slide 20

Example Essay Type Part 2


For a total of 15 marks: nDescribe the algorithm in words (not pseudo code) nCompute T(n) for algorithm 1 nCompute O(n) for algorithm 1 nHow would you modify the algorithm to create a new algorithm MinArray?
n
CS2004 Exam Revision 21Slide 21

Example Essay Type Part 3


The algorithm is designed to locate the largest value in an array, passed as a parameter. It assumes that the maximum is equal to the first element (1,1) and then systematically examines each element in turn, updating the maximum if the current item under scrutiny is larger than the maximum. This maximum value is then returned by the algorithm. CS2004 Exam Revision 22Slide 22
n

Example Essay Type Part 4


For T(n) count all variables reads, writes and operators, note we have two input sizes n and m
n

Algorithm 1. MaxArray(A) Input: An n row by m column Array A 1) Let max = element 1,1 (A(1,1)) of Array A 2 2) For i = 1 to n n 3) 4) 5) 6) For j = 1 to m n (m) If A(i,j) > max Then n m (5) [Assume worse] Let max = A(i,j) n m (4) End If none 23Slide 23

7) End For none CS2004 Exam Revision

Example Essay Type Part 5


n

For T(n) continued...


2 nn nnm n5nm n4nm nT(n) = 10nm + n + 2
n

O(n) = nm nTo create algorithm MinArray nWe change the > on line 4 to a < nWe would also rename the algorithm name and results variable CS2004 Exam Revision 24Slide 24
n

Next Topic

There is none! nHopefully see you next year nGood luck! nAny questions
n

CS2004 Exam Revision

25Slide 25

You might also like