View
223
Download
0
Category
Preview:
Citation preview
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 1/25
Click to edit Master subtitle style
Algorithms and theirApplications
CS2004 2010-2011Dr Stephen Swift
16.1 Exam Revision
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 2/25
CS2004 Exam RevisionCS2004 Exam Revision 2Slide 2
Introduction
n This lecture is a revision lecture forthe exam for this module
n The exam is on Tuesday 10th May at
2pmnIn this lecture we are going to cover:
n The assessment
n The format of the examnExam topicsnSome example questions
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 3/25
CS2004 Exam RevisionCS2004 Exam Revision 3Slide 3
Assessment
n The overall structure for theassessment is as follows:
n
50% Coursework (done)n10% Laboratory work sheets(done)n
40% Exam (pending)
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 4/25
CS2004 Exam RevisionCS2004 Exam Revision 4Slide 4
Exam
nA two hour examn The location should now be available
n This will consist of:n A multiple choice part A worth 40%n An essay-type question part B worth
60%
nAll questions should beattempted
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 5/25
CS2004 Exam RevisionCS2004 Exam Revision 5Slide 5
What to Revise – Part 1
n The exam will cover thetheoretical aspects of the modulen
There will be no programmingneedednNo questions on Java or Eclipse
n
However you may need tounderstand and/or write somepseudo code
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 6/25
CS2004 Exam RevisionCS2004 Exam Revision 6Slide 6
What to Revise – Part 2
n Topics could include (not restrictedto):
nAlgorithmic conceptsnWhat is an algorithm, a program, etc…
n Time Complexity and Asymptotic NotationnT (n) and O(n)
nData structuresnStacks, lists, arrays, queues, etc…
nSorting AlgorithmsnBubblesort, Quicksort, etc…
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 7/25 CS2004 Exam RevisionCS2004 Exam Revision 7Slide 7
What to Revise – Part 3
n Topics could include (not restrictedto):
nGraph Traversal AlgorithmsnDepth First, Breadth First, A*, MST, etc…
nSearchnSearch, Search Space, Fitness, Parameter optimisation, etc...
nHeuristic Search MethodsnHC, SHC, RRHC, SA, ILS, etc...
nEvolutionary Computation and Other MethodsnGenetic Algorithms, PSO, ACO, etc...
nApplicationsnBin Packing, Data Clustering, TSP, etc...
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 8/25 CS2004 Exam RevisionCS2004 Exam Revision 8Slide 8
Exam – Part A – Part 1
nMultiple choice questions(40%)
n
Choose an answer from a list of optionsn20 questions of 2 marks eachn
Spend about 2 minutes perquestionnUse the multiple choice answersheet
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 9/25 CS2004 Exam RevisionCS2004 Exam Revision 9Slide 9
Exam – Part A – Part 2
nGood strategies for multiplechoice questions:
nRead through all of the questions firstnAnswer the ones that you know firstnDo NOT spend too much time on asingle question
nOften ruling out answers can reducethe options down to a fewnDo not leave any blank!
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 10/25 CS2004 Exam RevisionCS2004 Exam Revision 10Slide 10
Exam – Part B – Part 1
nEssay type questionsn4 questions of 15 marksn
Spend approximately 15 minutesper questionnWrite your answers in the answerbook
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 11/25 CS2004 Exam RevisionCS2004 Exam Revision 11Slide 11
Exam – Part B – Part 2
nGood strategies for essay typequestions:
nRead through all of the questions firstnAnswer the ones that you know firstnDo NOT spend too much time on asingle question
nSketching a draft answer can help inlaying out complex answersnCross out anything you do not wantmarked
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 12/25 CS2004 Exam RevisionCS2004 Exam Revision 12Slide 12
Example Multiple Choice –Part 1
nWhat is pseudo code?na) A Java programnb) A programming languageindependent description of analgorithmnc) The intermediate code
produced by the Java compilernd) An algorithmic description of acomputer program
ne) None of the above
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 13/25 CS2004 Exam RevisionCS2004 Exam Revision 13Slide 13
Example Multiple Choice –Part 2
nAlgorithm A runs in time complexity O(n2),algorithm B in O(n3) and algorithm C inO(n2). Which of the following statements istrue?
na) Algorithm B is always faster than C
nb) Algorithm A and C are the same
nc) Algorithm A is slower than Algorithm B
n
d) Algorithm A and C are asymptoticallysimilar in performance
ne) None of the above
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 14/25 CS2004 Exam RevisionCS2004 Exam Revision 14Slide 14
Example Multiple Choice –Part 3
nWhich of the following data structureswould be appropriate for storing a list of names and addresses?
na) A stack
nb) A queue
nc) An array
nd) A linked list
n
e) It depends on the application
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 15/25 CS2004 Exam RevisionCS2004 Exam Revision 15Slide 15
Example Multiple Choice –Part 4
nWhich of the following is not part of a graph:
na) An arrow
nb) A nodenc) An edgend) A vertexn
e) An arc
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 16/25 CS2004 Exam RevisionCS2004 Exam Revision 16Slide 16
Example Multiple Choice –Part 5
nWhat is the fastest time that thefollowing list of number could besorted in descending order:
{10,9,8,7,6,5,4,3,2,1}na) No time – it is already sortednb) O(n)
nc) O(nln(n))nd) O(n2)
ne) It depends on the algorithm
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 17/25
CS2004 Exam RevisionCS2004 Exam Revision 17Slide 17
Example Multiple Choice –Part 6
nA* search can be used for:na) Finding the shortest route betweentwo stations on the underground
nb) Optimising the parameters of aNeural Networknc) Organising similar objects intomutually exclusive setsnd) Creating compilation CDsne) Decision Planning
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 18/25
CS2004 Exam RevisionCS2004 Exam Revision 18Slide 18
Example Multiple Choice –Part 7
nWhich of the following HeuristicSearch Methods is the odd one out?
na) Random Restart Hill Climbing
nb) Stochastic Hill Climbingnc) Genetic Algorithmnd) Hill Climbingn
e) Simulated Annealing
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 19/25
CS2004 Exam RevisionCS2004 Exam Revision 19Slide 19
Example Multiple Choice – Part8
nWhich of the following statements is trueregarding bin packing and data clustering?
na) Bin packing is slower than data clustering
nb) Bin packing is used on small sized objectswhilst data clustering is used on large objects
nc) Both algorithms arrange objects into groups
nd) Bin packing is used on 1-dimensional datawhilst data clustering can be used on n-dimensional datane) They perform the same function
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 20/25
CS2004 Exam RevisionCS2004 Exam Revision 20Slide 20
Example Essay Type – Part 1
nConsider 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
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 21/25
CS2004 Exam RevisionCS2004 Exam Revision 21Slide 21
Example Essay Type – Part 2
nFor a total of 15 marks:nDescribe the algorithm in words (notpseudo code)
nCompute T(n) for algorithm 1nCompute O(n) for algorithm 1
nHow would you modify the
algorithm to create a new algorithmMinArray?
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 22/25
CS2004 Exam RevisionCS2004 Exam Revision 22Slide 22
Example Essay Type – Part 3
n The algorithm is designed to locatethe largest value in an array, passedas a parameter. It assumes that the
maximum is equal to the firstelement (1,1) and thensystematically examines each
element in turn, updating themaximum if the current item underscrutiny is larger than the maximum.
This maximum value is then returned
by the algorithm.
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 23/25
CS2004 Exam RevisionCS2004 Exam Revision 23Slide 23
Example Essay Type – Part 4
nFor T(n) count all variables reads, writesand operators, note we have two inputsizes n and m
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) For j = 1 to m n (m)
4) If A(i,j) > max Then n m (5) [Assume
worse]
5) Let max = A(i,j) n m (4)
6) End If none
7) End For none
8/4/2019 CS0004 16.1 Exam Revsion %282010-2011%29
http://slidepdf.com/reader/full/cs0004-161-exam-revsion-282010-201129 24/25
CS2004 Exam RevisionCS2004 Exam Revision 24Slide 24
Example Essay Type – Part 5
nFor T(n) continued...n2
nn
nnm
n5nm
n4nm
nT(n) = 10nm + n + 2
nO(n) = nm
n To create algorithm MinArray
nWe change the > on line 4 to a <nWe would also rename the algorithm
name and results variable
Recommended