StringMatching
31
String Matching Problem
Given a text string T of length n and a pattern
string P of length m, the exact string matching
problem is to find all occurrences of P in T.
Example: T=AGCTTGA
P=GCT
Applications:
Searching keywords in a file
Sea
Recursion
Recursion is more than just a programming
technique. It has two other uses in computer
science and software engineering, namely:
as a way of describing, defining, or
specifying things.
as a way of designing solutions to
problems (divide and c
Previous Lecture Revision
Previous
Searching :
Hashing
The Main purpose of computer is to store & retrieve
Locating for a record is the most time consuming action
Methods:
Linear Search ( Search for a target element by element)
Asymptotic notation is
Artificial Neural Networks
Asad Anwar Butt
1
Non-Linear Classification
Motivating non-linear classification.
Use of logistic regression resulted in complex
hypothesis function.
Hypothesis generation can become extremely
complicated with the size of inp
CS877 Artificial Intelligence & Machine Learning
Semester Project
Choose a research paper that applies machine learning to solve a problem in any field and write a critique of
the paper. Some possible fields that use machine learning are:
1. Computer Visi
SOLoT’mM
Quiz# 3
Name:
Registration No.1
Question: NASA wants to be able to discriminate between Martians (M) and
Humans (H) based on the following characteristics: Green = {N, Y},
and Height. The available training data is as follows:
ies
Green
Beyond Classical Search
ASAD ANWAR BUTT
Introduction
We will now remove some of the simplifying
assumptions about our problems.
Previous problems had the following properties:
Observable:
Deterministic:
Known environments: Solution is a sequence of acti
National University of Sciences and Technology
School of Electrical Engineering and Computer Science
CS-877 Artificial Intelligence and Machine Learning (3+0)
Title: Artificial Intelligence and Machine Learning
Code: CS-877
Credit Hours: 3+0
Class: MS-CS-
Intelligent Agents
Intelligent Agents
Agent Definition:
Any entity that perceives its environment through sensors and
acts upon that environment through effectors
Percept:
The agents perceptual inputs at any given instant.
Percept Sequence:
Complete
CS877 Artificial Intelligence and
Machine Learning
Assignment # 1
Information about the map attached on last page.
States (A, B, C, D, E, F, G, H, I, J, K, L, M, N)
Initial state: Rawalpindi(A)
Goal state: Bahawalpur(M)
Question 1:
(a): Given the initial
Problem Solving by Searching
1
Outline
2
Problem-solving agents
Problem formulation
Example problems
Basic search algorithms
Problem-solving agents
3
Example: Romania
4
On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Bucharest
Problem Solving by Searching
1
Outline
2
Problem-solving agents
Problem formulation
Example problems
Basic search algorithms
Problem-solving agents
3
Example: Romania
4
On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Bucharest
Hashing
Hashing
Tables
Direct address tables
Hash tables
Collision and collision resolution
Chaining
Introduction
Many applications require a dynamic set that
supports dictionary operations.
Example: a compiler maintaining a symbol table
where keys corres
Dynamic Programming (DP)
Like divide-and-conquer, solve problem by
combining the solutions to sub-problems.
Differences between divide-and-conquer and DP:
Independent sub-problems, solve sub-problems
independently and recursively, (so same
sub(sub)prob
Recurrences and Running Time
An equation or inequality that describes a function in
terms of its value on smaller inputs.
T(n)=T(n1)+n
Recurrences arise when an algorithm contains recursive
calls to itself
What is the actual running time of the algorit
Heapsort
Why study Heapsort?
It is a well-known, traditional sorting algorithm
you will be expected to know
Heapsort is always O(nlogn)
Quicksort is usually O(nlogn) but in the worst case
slows to O(n2)
Quicksort is generally faster, but Heapsort is bette
Radix Sort
1
Classification of Sorting algorithms
Sorting algorithms are often classified using different metrics:
Computational complexity: classification is based on worst, average and best
behavior of sorting a list of size (n).
Memory usage (and use
Design & Analysis of Algorithms
COUNTING SORT
Sorting in linear time
Counting sort: No comparisons between elements.
Input: A[1 . . n], where A[ j]cfw_1, 2, , k .
Output: B[1 . . n], sorted.
Auxiliary storage: C[1 . . k] .
Counting sort
for i 1 to k
do
Dynamic programming
Longest Common Subsequence
1
Longest Common Subsequence
(LCS)
Application: comparison of two DNA strings
Ex: X= cfw_A B C B D A B , Y= cfw_B D C A B A
Longest Common Subsequence:
X= AB
C
BDAB
Y=
BDCAB A
Brute force algorithm would comp
Insertion, Bubble AND Selection
Sort
Sorting Algorithms
Some Definitions
Internal Sort
The data to be sorted is all stored in the computers
main memory.
External Sort
Some of the data to be sorted might be stored in
some external, slower, device.
In
Sorting Algorithms
Merge Sort
Quick Sort
Overview
Divide
and Conquer
Merge
Sort
Quick
Sort
2
Divide and Conquer
1. Base Case, solve the problem directly
if it is small enough
2. Divide the problem into two or more
similar and smaller subproblems
3. Rec
240-301, Computer Engineering Lab III (Software)
Semester 1, 2006-2007
Pattern Matching
Dr. Andrew Davison
WiG Lab (teachers room), CoE
[email protected]
T:
P:
a
b
a
c
a
a
b
1
a
b
240-301 Comp. Eng. Lab III (Software), Pattern Matching
b
c
a
a
b
4
Shellsort
Shellsort
Founded by Donald Shell and named the
sorting algorithm after himself in 1959.
1st algorithm to break the quadratic time barrier
but few years later, a sub quadratic time bound
was proven
Shellsort works by comparing elements that
a
GreedyAlgorithms
CS3381 Des & Anal of Alg (2001-2002 SemA)
http:/www.cs.cityu.edu.hk/~helena Wong
City Univ of HK / Dept of CS / Helena
5. Greedy Algorithms - 1
Greedy Algorithm Design
Comparison:
Dynamic Programming
Greedy Algorithms
At each step, the ch
Algorithms
Selected Lecture Notes
Partha Bhowmick
IIT Kharagpur
http:/www.facweb.iitkgp.ernet.in/~pb
Foreword
Some selected topics and related algorithms I have discussed
in the class are explained briey in this Lecture Notes. There
are also some other to
Complexity Analysis
Asymptotic Complexity
Big-O (asymptotic) Notation
Big-O Computation Rules
Proving Big-O Complexity
How to determine complexity of code structures
Asymptotic Complexity
Finding the exact complexity, f(n) = number of basic
operations, o