Algorithms and Pseudocode
Bioinformatics
Formulating Problems
Clarify input and output elements
Requires
modeling
the problem in
some concise form
Example: Given n cities and distances
between cities, find the shortest tour
More concise description of input: integer
N, distances d[i,j], 1<=i<=N, 1<=j<=N.
What about output?
Traveling Salesman Problem
Input:
Integer N
Distances d[i,j],
1<=i<=N, 1<=j<=N
Output:
Permutation p
1
p
2
… p
N
of the
integers 1…N such that
1<=i<N
d[p
i
,p
i+1
] is the
smallest possible
String Search Problem
Input:
Strings s[1…m] and t[1…n]
Output:
The (smallest) position p
such that for all i, 1 <= i <= m,
s[i] = t[p+i
-
1];
p = 0, if no such p exists
Algorithm
String_Search(s[1…m], t[1…n])
for p = 1 to n
-
m+1 do
found = true
for i = 1 to m do
if s[i]
瑛瀫p
-
ㅝ⁴桥1
†††
景畮搠㴠晡f獥
if found then
break
if not found then
return 0
else
return p
Algorithm Specification
Pseudocode: not tied to a particular
programming language syntax
Data
Variables
Arrays
Statements
Assignments and computation
Decisions, conditions, and loops
Break and return
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Comments 0
Log in to post a comment