Presentation is loading. Please wait.

Presentation is loading. Please wait.

December 4, 20031 Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University

Similar presentations


Presentation on theme: "December 4, 20031 Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University"— Presentation transcript:

1 December 4, 20031 Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University simas@cs.auc.dk

2 December 4, 20032 Results of the questionnaire Problematic lectures:

3 December 4, 20033 This Lecture What have we learned? Summary-Pensum Solving exercises Recurrences Graph exercises ADT exercises Dvide and conquer algorithms

4 December 4, 20034 The Course – Pensum Toolbox of algorithmic techniques Divide and Conquer Merge sort, Quicksort, Binary search Dynamic programming Matrix chain multiplication, Longest Common Subsequence – not in exam pensum, except basic understanding of LCS Greedy algorithms Prim’s, Kruskal’s, Dijkstra’s Analysis of algorithms: Correctness of algorithms Loop invariants – not in exam pensum Asymptotic notations Recurrences

5 December 4, 20035 The Course – Pensum (2) Building algorithms - concept of ADT Toolbox of data structures: Simple data structures and ADTs array, all sorts of linked lists, stacks, queues, trees, heaps Dictionaries hash tables binary search trees (unbalanced) red-black trees

6 December 4, 20036 The Course – Pensum (3) Toolbox of algorithms: Sorting insertion sort, selection sort merge sort quick sort heap sort (priority queues) Graphs memory representation graph traversal breadth-first search depth-first search (topological sort) minimum spanning trees (Prim, Kruskal) shortest path (Dijkstra, Bellman-Ford)

7 December 4, 20037 The Exam The exam will be written, you will have three hours. Two parts: Multiple-choice, “quiz”-style part – tests basic knowledge, understanding of the core concepts “Creative exercises” – come up with algorithms, analyze them, argue for your solutions.

8 December 4, 20038 Preparation for the Exam To prepare for the exam: Concentrate on solving the exercises, not studying the textbook (although you have to know the concepts!) Solve exercises from last year exams When solving write your solutions down! On Jan 16, 13:00 come to B2-104 (here) and have your questions answered. Or pass by my office E1-215b! Good news: solutions to hand-in exercises will be posted on the web before Christmas!

9 December 4, 20039 Solving Recurrences Repeated substitution procedure: Substitute, expand, substitute, expand… Observe a pattern and write how your expression looks after the i-th substitution Find out what the value of i (e.g., lgn or n-1) should be to get the base case of the recurrence (e.g., T(1)) Insert the value of T(1) and the expression of i into your expression Compute your recurrence for small values and check if your general solution gives the same results!

10 December 4, 200310 Types of Recurrences Number of substitutions i : If T(n) = …T(n - 1)… and base case T(k) = … then i = n – k If T(n) = …T(n/b)… and base case T(k) = … then i = log b (n/k)

11 December 4, 200311 Types of recurrences II T(n) = aT(n – b) + c T(n) = aT(n/b) + cn + d Geometric series T(n)=T(n – b) + cn + d Arithmetic series Prove it yourself!

12 December 4, 200312 Graph Exercises Types of graph exercises: Decide what are the vertices and what are the edges Un-weighted graphs “Traverse and check(do) something” => use DFS or BFS Find shortest paths => use BFS Schedule or order dependent activities or processes => use Topological sorting

13 December 4, 200313 Graph Exercises Types of graph exercises: Weighted graphs Decide what are the weights Shortest paths, shortest times => use Dijkstra’s Minimum (maximum) spanning tree => use Prim’s or Kruskal’s Finding a critical path in a schedule (longest path in a DAG) => use Topological sorting on a DAG of activities

14 December 4, 200314 Do not forget: Write preconditions (INPUT) and postconditions (OUTPUT) of your algorithms You can only use the ADT operations provided in the exercise !!!


Download ppt "December 4, 20031 Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University"

Similar presentations


Ads by Google