Presentation is loading. Please wait.

Presentation is loading. Please wait.

Construction and Analysis of Efficient Algorithms Introduction Autumn 2015, Juris Vīksna.

Similar presentations


Presentation on theme: "Construction and Analysis of Efficient Algorithms Introduction Autumn 2015, Juris Vīksna."— Presentation transcript:

1 Construction and Analysis of Efficient Algorithms Introduction Autumn 2015, Juris Vīksna

2 Timetable Regular lecture times: Wednesdays12.30 - 14.00 413. aud. Fridays12.30 - 14.00 413. aud. The lectures at the following dates will be rescheduled: 09.09., 11.09. 20.11., 22.11. (?) – to be yet confirmed) Some other changes are possible (but hopefully, not too many). Replacement lectures most likely will be scheduled starting from the second half of October.

3 Outline Motivation and some examples Subjects covered in the course Requirements Textbooks Other practical information

4 Motivation Is there a sufficiently fast algorithm for a given problem? Problem 1b For a given pair of vertices in connected undirected graph find the length of longest non-intersecting path between these vertices. Problem 1a For a given pair of vertices in connected undirected graph find the length of shortest path between these vertices.

5 Problem 1a For a given pair of vertices in connected undirected graph find the length of shortest path between these vertices.

6 Problem 1a For a given pair of vertices in connected undirected graph find the length of shortest path between these vertices. There is an algorithm that solves this problem in time less than const · (|V| + |E|)

7 Problem 1a

8 d = 0

9 Problem 1a d = 1

10 Problem 1a d = 2

11 Problem 1a d = 3

12 Problem 1a d = 4

13 Problem 1a d = 5  OK

14 Problem 1b For a given pair of vertices in connected undirected graph find the length of longest non-intersecting path between these vertices.

15 Problem 1b For a given pair of vertices in connected undirected graph find the length of longest non-intersecting path between these vertices. There is not known an algorithm that solves this problem within polynomial time. (And it is widely believed that such algorithm does not exist.)

16 Problem 1c For a given pair of vertices in connected undirected graph find a non-intersecting path between these vertices consisting of even number of edges.

17 Problem 2a For a given undirected graph find an Euler cycle (if such exists). Euler cycle is defined as a closed path that contains every edge exactly once.

18 Eulerian path (cycle) problem For a given graph find a path (cycle) that visits every edge exactly once (or show that such path does not exist).

19 Problem 2a For a given undirected graph find an Euler cycle (if such exists). Euler cycle is defined as a closed path that contains every edge exactly once. There is an algorithm that solves this problem in time less than const · (|V| + |E|)

20 Eulerian path (cycle) problem For a given graph find a path (cycle) that visits every edge exactly once (or show that such path does not exist). Eulerian cycle exists if and only if each of graph vertices has even degree. Moreover, there is a simple linear time algorithm for finding Eulerian cycle.

21 Problem 2b For a given undirected graph find a Hamiltonian cycle (if such exists). Hamiltonian cycle is defined as a closed path that contains every vertex exactly once.

22 Hamiltonian path (cycle problem) Hamiltonian path (cycle) problem For a given graph find a path (cycle) that visits every vertex exactly once (or show that such path does not exist).

23 Hamiltonian path (cycle problem) Hamiltonian path (cycle) problem For a given graph find a path (cycle) that visits every vertex exactly once (or show that such path does not exist).

24 Problem 2b For a given undirected graph find a Hamiltonian cycle (if such exists). Hamiltonian cycle is defined as a closed path that contains every vertex exactly once. There is not known an algorithm that solves this problem within polynomial time. (And it is widely believed that such algorithm does not exist.)

25 Genome sequence assembly

26

27 Sequence assembly problem W.Bains, C.Smith (1988) A novel method for nucleic acid sequence determination. Journal of theoretical biology.Vol. 135:3, 303- 307. Ok, let us assume that we have these hybridizations. How can we reconstruct the initial DNA sequence from them? Affymetrix GeneChip

28 Sequence assembly problem Ok, let us assume that we have these hybridizations. How can we reconstruct the initial DNA sequence from them?

29 SBH – Hamiltonian path approach

30

31 SBH – Eulerian path approach

32 An Eulerian path approach to SBH problem PNAS (Proceedings of the National Academy of Sciences), 2001

33 SBH and de Bruijn graphs (~ 1950 :)

34 Motivation How to compute the time of computation required for a given algorithm? Does the given algorithm work correctly? Problem 3 Given two strings P and T over the same alphabet , determine whether P occurs as a substring in T.

35 Problem 3 SimpleMatcher(string P, string T) n  length[T] m  length[P] for s  0 to n  m do if P[1...m] = T[s+1... s+m] then print s Time = const ·n · m

36 Problem 3 KnuthMorrisPrattMatcher(string P, string T) n  length[T] m  length[P]   PrefixFunction(P) q  0 for i  1 to n do while q > 0 & P[q+1]  T[i] do q   [q] if P[q+1] = T[i] then q  q + 1 if q = m then print i  m q   [q]

37 Problem 3 PrefixFunction(string P) m  length[P]  [1]  0 k  0 for q  2 to m do while k > 0 & P[k+1]  P[q] do k   [q] if P[q+1] = P[q] then k  k + 1  [q]  k return 

38 Problem 3 KnuthMorrisPrattMatcher(string P, string T) n  length[T] m  length[P]   PrefixFunction(P) q  0 for i  1 to n do while q > 0 & P[q+1]  T[i] do q   [q] if P[q+1] = T[i] then q  q + 1 if q = m then print i  m q   [q] T(n,m) = T P (m) + n T While (m) T P (m) = const · m T(n,m)  const ·n · m It can be shown that T(n,m) = const · (n + m)

39 Knuth-Morris-Pratt Algorithm - Idea T = gadjama gramma berida P = gaga gagjamagrammaberida gaga gagjamagrammaberida gaga

40 Problem 4 Is there an implementation of array of n integers such that: elements can be accessed in constant time, array can be initialised (values of all elements reset to 0) in constant time?

41 Problem 4 Array M[1...n] Additional variables: Integer Count - number of assignements since the last initialisation Array When[1..n] - array of assignements that have changed the corresponding M elements Array Which[0..n-1] - array of element numbers that have been changed by the assignements 0...n-1

42 Problem 4 Initialise all elements to 0 Initialise() Count  0 Assign the value v to the i-th element Assign(v,i) M[i]  v if not Modified(i) then When[i]  Count Which[Count]  i Count  Count + 1

43 Problem 4 Return the i-th element Access(i) if Modified(i) then return M[i] else return 0 Return true, if the i-th element have been modified since the last initialisation Modified(i) if 0  When[i] < Count and Which[When[i]] = i then return true else return false

44 Subjects covered in the course Models of computation and complexity of algorithms Complexity analysis Data structures Sorting algorithms Algorithms on graphs String searching algorithms Dynamical programming Computational geometry Algorithms for arithmetical problems NP completeness

45 Requirements Two short-term homeworks Most likely will be given in October-November Strict (or almost) one week deadline 20% each Programming assignment Problem to be announced in second half of October No deadline – must be submitted before the exam 20% Exam 40% To qualify for grade 10 you may be asked to cope with some additional question(s)/problem(s)

46 Academic honesty You are expected to submit only your own work! Sanctions: Receiving a zero on the assignment (in no circumstances a resubmission will be allowed) No admission to the exam and no grade for the course

47 Textbooks Thomas H.Cormen Charles E.Leiserson Ronald L.Rivest Clifford Stein Introduction to Algorithms The MIT Press, 2009 (3 rd ed, 1 st ed 1990)

48 Textbooks Harry R.Lewis Larry Denenberg Data Structures and their Algorithms Harper Collins Publishers, 1991

49 Textbooks Steven S.Skiena The Algorithm Design Manual Springer Verlag, 2008 (2 nd ed, 1 st ed 1997)

50 Textbooks Alfred V.Aho, John E.Hopcroft, Jeffrey D.Ullman The Design and Analysis of Computer Algorithms Addison-Wesley Publishing Company, 1976

51 Textbooks David Harel, Algorithmics: the spirit of computing Addison-Wesley Publishing Company, 2004 (3 rd ed)

52 Textbooks Dan Gusfield Algorithms on Strings Trees and Sequences Cambridge University Press, 1997

53 Textbooks Michael R. Garey, David S. Johnson Computers and Intractability – A Guide to the Theory of NP-Completeness W. H. Freedman and Company, 1979

54 Web page http://susurs.mii.lu.lv/juris/courses/alg2015.html It is expected to contain: short summaries of lectures announcements power point presentations homework and programming assignment problems frequently asked questions (???) your grades other useful information Course information available also at https://estudijas.lu.lv

55 Contact information Juris Vīksna Room 421, Rainis boulevard 29 phone: 67213716


Download ppt "Construction and Analysis of Efficient Algorithms Introduction Autumn 2015, Juris Vīksna."

Similar presentations


Ads by Google