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=AGCTT
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
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
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
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
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:
Determinis
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 Machin
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 in
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 s
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; cur
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; cur
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:
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-proble
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
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(n
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
behavio
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.
Auxili
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
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
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
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
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
w
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:
Dyn
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 br