Biological Sciences faculty
Biophysics Department
Bioinformatics Algorithms Present
Presented By
Alireza Doustmohammadi
Graduate Student in Bioinformatics
December 2018
BA Present Tarbiat Modares University 1 of 27
Contents
Introduction
Donald Knuth
LCA Time Complexity
2 of 27BA Present Tarbiat Modares University
Introduction
3 of 27
LCP Problem:
longest common prefix of two suffixes
BA Present Tarbiat Modares University
Suffix i Suffix j
History
Donald Knuth
[https://alchetron.com/Donald-Knuth]
4 of 27
 An American computer scientist, mathematician
 Popularized the asymptotic notation
[http://tcs.unige.ch/doku.php]
BA Present Tarbiat Modares University
LCA
Most Popular Activities
Donald Knuth
[https://www.amazon.in/Computer-
Programming-Volumes-1-4A
-Boxed/dp/0321751043]
5 of 27BA Present Tarbiat Modares University
LCA
1. The Art of Computer Programming
2. TEX Machine
Efficient LCA Algorithm
Donald Knuth
6 of 27BA Present Tarbiat Modares University
LCA
Use Euler Walking
Euler Walking
Donald Knuth
7 of 27BA Present Tarbiat Modares University
LCA
1
Euler Walking
Donald Knuth
8 of 27BA Present Tarbiat Modares University
LCA
2
1
Euler Walking
Donald Knuth
9 of 27BA Present Tarbiat Modares University
LCA
4
2
1
Euler Walking
Donald Knuth
10 of 27BA Present Tarbiat Modares University
LCA
2
4
2
1
Euler Walking
Donald Knuth
11 of 27BA Present Tarbiat Modares University
LCA
5
2
4
2
1
Euler Walking
Donald Knuth
12 of 27BA Present Tarbiat Modares University
LCA
2
5
2
4
2
1
Euler Walking
Donald Knuth
13 of 27BA Present Tarbiat Modares University
LCA
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
14 of 27BA Present Tarbiat Modares University
LCA
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
15 of 27BA Present Tarbiat Modares University
LCA
3
1
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
16 of 27BA Present Tarbiat Modares University
LCA
7
3
1
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
17 of 27BA Present Tarbiat Modares University
LCA
3
7
3
1
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
18 of 27BA Present Tarbiat Modares University
LCA
8
3
7
3
1
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
19 of 27BA Present Tarbiat Modares University
LCA
3
8
3
7
3
1
2
6
2
5
2
4
2
1
Euler Walking
Donald Knuth
20 of 27BA Present Tarbiat Modares University
LCA
1
3
8
3
7
3
1
2
6
2
5
2
4
2
1
Efficient LCA Algorithm
Donald Knuth
21 0f 27BA Present Tarbiat Modares University
[https://www.geeksforgeeks.org/lca-n-ary-tree-constant-query-o1/]
LCA
Efficient LCA Algorithm
Donald Knuth
22 of 27BA Present Tarbiat Modares University
[https://www.geeksforgeeks.org/lca-n-ary-tree-constant-query-o1/]
RMQ
LCA
Min depth in this range
Efficient RMQ Algorithm (Sparse table)
Donald Knuth
23 of 27BA Present Tarbiat Modares University
LCA
1 2 4 2 5 2 6 2 1 3 7 3 8 3 1
0 1 2 1 2 1 2 1 0 1 2 1 2 1 0
Size of window
Efficient RMQ Algorithm (Sparse table)
Donald Knuth
24 of 27BA Present Tarbiat Modares University
LCA
1 2 4 2 5 2 6 2 1 3 7 3 8 3 1
0 1 2 1 2 1 2 1 0 1 2 1 2 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 0 -
0 1 1 1 1 1 0 0 0 0 1 1 0 - -
0 0 0 0 0 0 0 0 - - - - - - -
0 - - - - - - - - - - - - - -
s[i][j]=Min(s[i-1][j],S[i-1][j+1])
Size of window
Efficient RMQ Algorithm (Sparse table)
Donald Knuth
25 of 27BA Present Tarbiat Modares University
LCA
6 2 1 3 7
Result is min between this windows
Efficient RMQ Algorithm (Sparse table)
Donald Knuth
26 of 27BA Present Tarbiat Modares University
LCA
1 2 4 2 5 2 6 2 1 3 7 3 8 3 1
0 1 2 1 2 1 2 1 0 1 2 1 2 1 0
0 1 1 1 1 1 1 0 0 1 1 1 1 0 -
0 1 1 1 1 1 0 0 0 0 1 1 0 - -
0 0 0 0 0 0 0 0 - - - - - - -
0 - - - - - - - - - - - - - -
Size of window
Calculate Time Complexity
Donald Knuth
27 of 27BA Present Tarbiat Modares University
LCA

Lowest common ancestor (LCA) algorithm