Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 17.1 Exam Revision.

Similar presentations


Presentation on theme: "Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 17.1 Exam Revision."— Presentation transcript:

1 Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 17.1 Exam Revision

2 CS2004 Exam RevisionSlide 2 Introduction This lecture is a revision lecture for the examination for this module Thursday 7 th May at 2pm The exam is on Thursday 7 th May at 2pm Numerous locations… Please note I was sent a lot of topics for this revision lecture We can only cover some of them I am afraid... Some of them were sent rather late! ;-) In this lecture we are going to cover: The assessment The format of the exam Exam topics Brief revision of some topics Some example questions

3 CS2004 Exam RevisionSlide 3 Assessment The overall structure for the assessment is as follows: 60% Coursework/Worksheets These should now be done! last The last chance for assessment is this week At the usual times… At the usual times… 40% Exam (pending)

4 CS2004 Exam RevisionSlide 4 Exam A three hour exam The location should now be available This will consist of: A multiple choice part A worth 40% An essay-type question part B worth 60% All questions should be attempted All questions should be attempted

5 CS2004 Exam RevisionSlide 5 What to Revise – Part 1 The exam will cover the theoretical aspects of the module There will be no programming needed No questions on Java or Eclipse However you may need to understand and/or write some pseudo code

6 CS2004 Exam RevisionSlide 6 What to Revise – Part 2 Topics could include (not restricted to): Algorithmic concepts What is an algorithm, a program, etc… Time Complexity and Asymptotic Notation T(n) and O(n) Data structures Stacks, lists, arrays, queues, etc… Sorting Algorithms Bubblesort, Quicksort, etc…

7 CS2004 Exam RevisionSlide 7 What to Revise – Part 3 Topics could include (not restricted to): Graph Traversal Algorithms Depth First, Breadth First, A*, MST, etc… Search Search, Search Space, Fitness, Parameter optimisation, etc... Heuristic Search Methods HC, SHC, RRHC, SA, ILS, etc... Evolutionary Computation and Other Methods Genetic Algorithms, PSO, ACO, etc... Applications Bin Packing, Data Clustering, TSP, etc...

8 CS2004 Exam RevisionSlide 8 Exam – Part A – Part 1 Multiple choice questions (40%) Choose an answer from a list of options 20 questions of 2 marks each about Spend about 3 minutes per question Use the multiple choice answer sheet

9 CS2004 Exam RevisionSlide 9 Exam – Part A – Part 2 Good strategies for multiple choice questions: Read through all of the questions first Answer the ones that you know first NOT Do NOT spend too much time on a single question Often ruling out answers can reduce the options down to a few Do not leave any blank!

10 CS2004 Exam RevisionSlide 10 Exam – Part B – Part 1 Essay type questions 4 questions of 15 marks approximately Spend approximately 25 minutes per question Write your answers in the answer book

11 CS2004 Exam RevisionSlide 11 Exam – Part B – Part 2 Good strategies for essay type questions: Read through all of the questions first Answer the ones that you know first NOT Do NOT spend too much time on a single question Sketching a draft answer can help in laying out complex answers Cross out anything you do not want marked

12 CS2004 Exam RevisionSlide 12 Requested Topics The following subjects were emailed to me for revision topics Note that I can only briefly go over them today given the time… Ant Colony Optimisation Particle Swarm Optimisation Data Clustering Big-O Notation

13 CS2004 Exam RevisionSlide 13 Swarm Intelligence Algorithms Study of collective behaviour of decentralised, self-organised systems No central control Only simple rules for each individual Most Popular Algorithms Ant Colony Optimisation (ACO) Particle Swarm Optimisation (PSO)

14 CS2004 Exam RevisionSlide 14 ACO – Key Concepts graph Used for solving graph based problems Ants (blind) navigate from nest to food sources The shortest path is discovered via pheromone trails Indirect coordination/communication between agents or actions Stigmergy Stigmergy Route selection is determined according to the amount of pheromone on each edge Pheromone levels on edges is changed Ants deposit pheromone on the edges they traverse Pheromone evaporates over time

15 CS2004 Exam RevisionSlide 15 PSO – Key Concepts parameter estimation/optimisation Used for solving parameter estimation/optimisation based problems It uses a number of agents (particles) that constitute a swarm moving around in the search space looking for the best solution flying Each particle is treated as a point in an n-dimensional space which adjusts its “flying” according to its own flying experience as well as the flying experience of other particles A record is kept of each particles position, personal best (location) and the global best (location) Each particle is accelerated towards its personal best and the global best

16 CS2004 Exam RevisionSlide 16 Data Clustering – Part 1 Data Clustering Data Clustering is a common technique for data analysis, which is used in many fields, including machine learning, data mining, pattern recognition, image analysis and bioinformaticsmachine learningdata mining pattern recognitionimage analysisbioinformatics Data Clustering Data Clustering is the process of arranging objects (as points) into a number of sets ( k ) according to “distance” Each set (ideally) shares some common trait - often similarity or proximity for some defined distance measure Each set will be referred to as a cluster/group For the purposes of this module, each set is mutually exclusive, i.e. an item cannot be in more than one cluster

17 CS2004 Exam RevisionSlide 17 Data Clustering – Part 2 The data that we are clustering usually consists of a number of examples (rows) ( n ) where we have measured a number of features (variables) ( m = 3 in the example below) We want to cluster the rows together based on how similar their features are We shall assume that the data we are clustering is a table or matrix X, where x i is the i th row of X and x ij is the j th variable (feature) or row i For example x 92 is 2.9 in the table below: Sample Sepal Length in cmSepal Width in cmPetal Length in cm 15.13.51.4 24.93.01.4 34.73.21.3 44.63.11.5 55.03.61.4 65.43.91.7 74.63.41.4 85.03.41.5 94.42.91.4 104.93.11.5 Etc...5.43.71.5

18 CS2004 Exam RevisionSlide 18 Data Clustering – Part 3 Data Clustering Method Data Similarity Number of Clusters Cluster Worth

19 CS2004 Exam RevisionSlide 19 Representing a Cluster A cluster will be represented as a vector C where c i =j means that object/item/row i is in cluster j For example C = {1,2,3,2,3,3} ( k=3) Largest cluster the most The number that appears the most in the vector/cluster Number of clusters The most frequent number in the vector/count the clusters 1 2 3 6 Cluster 1 Cluster 2 Cluster 3 4 5

20 CS2004 Exam RevisionSlide 20 Big-O Notation Used to compare algorithms Why? Why? Gives a long term, large input size, limit on the growth rate of the effort an algorithm takes We measure an algorithms effort in terms of counting primitive operations We derive a function T(n) (exact count) from the pseudo code, parameterised in terms of the algorithms input size Simple rules are applied to T(n) to get O(n) What are they? What are they? We will go over a worked example later…

21 CS2004 Exam RevisionSlide 21 Example Multiple Choice – Part 1 What is pseudo code? a) A Java program b) A programming language independent description of an algorithm c) The intermediate code produced by the Java compiler d) An algorithmic description of a computer program e) None of the above

22 CS2004 Exam RevisionSlide 22 Example Multiple Choice – Part 2 Algorithm A runs in time complexity O(n 2 ), algorithm B in O(n 3 ) and algorithm C in O(n 2 ). Which of the following statements is true? a) Algorithm B is always faster than C b) Algorithm A and C are the same c) Algorithm A is slower than Algorithm B d) Algorithm A and C are asymptotically similar in performance e) None of the above

23 CS2004 Exam RevisionSlide 23 Example Multiple Choice – Part 3 Which of the following data structures would be appropriate for storing a list of names and addresses? a) A stack b) A queue c) An array d) A linked list e) It depends on the application

24 CS2004 Exam RevisionSlide 24 Example Multiple Choice – Part 4 Which of the following is not part of a graph: a) An arrow b) A node c) An edge d) A vertex e) An arc

25 CS2004 Exam RevisionSlide 25 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} a) No time – it is already sorted b) O(n) c) O(nln(n)) d) O(n 2 ) e) It depends on the algorithm

26 CS2004 Exam RevisionSlide 26 Example Multiple Choice – Part 6 A* search can be used for: a) Finding the shortest route between two stations on the underground b) Optimising the parameters of a Neural Network c) Organising similar objects into mutually exclusive sets d) Creating compilation CDs e) Decision Planning

27 CS2004 Exam RevisionSlide 27 Example Multiple Choice – Part 7 Which of the following Heuristic Search Methods is the odd one out? a) Random Restart Hill Climbing b) Stochastic Hill Climbing c) Genetic Algorithm d) Hill Climbing e) Simulated Annealing

28 CS2004 Exam RevisionSlide 28 Example Multiple Choice – Part 8 Which of the following statements is true regarding bin packing and data clustering? a) Bin packing is slower than data clustering b) Bin packing is used on small sized objects whilst data clustering is used on large objects c) Both algorithms arrange objects into groups d) Bin packing is used on 1-dimensional data whilst data clustering can be used on n-dimensional data e) They perform the same function

29 CS2004 Exam RevisionSlide 29 Example Essay Type – Part 1 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

30 CS2004 Exam RevisionSlide 30 Example Essay Type – Part 2 For a total of 15 marks: Describe the algorithm in words (not pseudo code) Compute T(n) for algorithm 1 Compute O(n) for algorithm 1 How would you modify the algorithm to create a new algorithm MinArray ?

31 CS2004 Exam RevisionSlide 31 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.

32 CS2004 Exam RevisionSlide 32 Example Essay Type – Part 4 For T(n) count all variables reads, writes and operators, note we have two input sizes n and m Algorithm 1. MaxArray(A) Input: An n row by m column Array A  2 1) Let max = element 1,1 (A(1,1)) of Array A  2  n 2) For i = 1 to n  n  n  (m) 3) For j = 1 to m  n  (m)  n  m  (5) [Assume worse] 4) If A(i,j) > max Then  n  m  (5) [Assume worse]  n  m  (4) 5) Let max = A(i,j)  n  m  (4)  none 6) End If  none  none 7) End For  none  none 8) End For  none  none Output: max- the largest element in array A  none

33 CS2004 Exam RevisionSlide 33 Example Essay Type – Part 5 For T(n) continued... 2 n nm 5nm 4nm T(n) = 10nm + n + 2 O(n) = nm To create algorithm MinArray We change the > on line 4 to a < We would also rename the algorithm name and results variable

34 CS2004 Exam RevisionSlide 34 Example Essay Type – Part 6 B.3.1) Describe the main similarities and differences between a Genetic Algorithm (GA) and an Evolutionary Program (EP). [4 marks] Taken from Part B of the CS2004 past exam paper 2011-2012

35 CS2004 Exam RevisionSlide 35 Example Essay Type – Part 7 Both maintain a population Only a GA has crossover Both have mutation but an EP has a much more complex mutation operator All individual mutate in an EP Only some in a GA Both have selection Roulette Wheel However a GA usually uses the Roulette Wheel which allows an individual to be selected zero or more times Tournament Selection An EP uses Tournament Selection which allows an individual to be selected zero times or once

36 CS2004 Exam RevisionSlide 36 Next Topic There is none! Hopefully see you next year Good luck! Any questions…


Download ppt "Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 17.1 Exam Revision."

Similar presentations


Ads by Google