The Importance of
A Good Representation
You cant learn what
you cant represent.
- G. Sussman
Properties of a good representation:
Reveals important features
Hides irrelevant detail
Exposes useful constraints
Makes frequent operations easy-to-do
Supports l
resultsarenotoptimal, theyareoftenquitegood.Forexample,inthencitytravelingsalesmanproblem,wecangetnear-optimal toursintime
O(n2)whentheintercitycostsaresymmetric(Ci,j = Cj,i for all i and j) and
satisfy the triangleinequality(Ci,j Ci,k + Ck,j for all i, j
4.1.3.2 Implicit vs. Explicit Two fundamental data organization
mechanisms are used in data structures. In an explicit data structure,
pointers (i.e., memory addresses) are used to link the elements and
access them (e.g., a singly linked list, where each
1 int C[n][n]; 2 for (int i = 0; i < n; i+) 3 for (int j = 0; j < n; j+) 4 C[i][j] =
MAXINT; 5
6 int C (int i, int j) cfw_ 7if(C[i][j]=MAXINT) 8 if (i = j) 9 C[i][j] = 0; 10 else
cfw_ 11 int minCost = MAXINT; 12 int cost; 13 for (int k = i+1; k <= j; k+)
complexity of an operation is the average time over a suitably dened
sequence of operations. However, efciency is not the only quality
measure of a data structure. Simplicity and ease of imple- mentation
should be taken into account when choosing a data s
Nowweshowhowtoperformthevariouspriorityqueueoperationsbymeans
ofaheap T. We denote with x() the element stored at an internal node
of T. We denote with the root of T. We call the last node of T the
rightmost internal node of the bottommost internal level
element e in the rth position of S; ifr < 1 orr > N +1, where N is the
current size of S, then p is set to null. REMOVE(p,e): remove from S and
return element e withposition p. MODIFY(p,e): replace with e the
element with position p.
Some of the preceding
then p is set to null. POSITIONRANK(r, p): assign to p the position of the
rth element of S; ifr < 1 orr > N, whereN is the size of S, then p is set to
null. PREV(p, p):assignto p thepositionoftheelementof S
precedingtheelementwithposition p;ifp is the po
the partial order property. Hence, if = ,wecompare x()with x(), where is
the parent of . If x() > x(), then we need to restore the partial order
property, which can be locally achieved by
exchangingtheelementsstoredat and .Thiscausesthenewelement e to
mov
Below, for each problem on this Midterm Exam, Perfect is the percentage of students who received
full credit, Partial is the percentage who received partial credit, and Zero is the percentage who
received zero credit.
(Due to rounding or other exceptional
the current tour in solid lines and the pieces of optimal tour as dotted
lines:
Initially,thespiderconsistsofthearbitrarilychosencitywithwhichtheclosesti
nsertiontourbeginsand the legs of the spider consist of all the edges of
the optimal tour except for
tour of length |On|. Then, |In| |On| < 2. This bound is proved by an
incremental form of the optimality proofs for greedy heuristics we saw
seen above: we ask not where the rst error is, but by how much we
are in error at each greedy insertion to the
tour
internal memory is much faster than external memory but has much
smaller capacity. Data structures designed to work for data that t into
internal memory may not perform well for large amounts of data that
need to be stored in external memory. For large-sc
Informed search algorithms
This lecture topic
Read Chapter 3.5-3.7
Next lecture topic
Read Chapter 4.1-4.2
(Please read lecture topic material before
and after each lecture on that topic)
You will be expected to know
evaluation function f(n) and heuristic
Local Search Algorithms
This lecture topic
Read Chapter 4.1-4.2
Next lecture topic
Read Chapter 5
(Please read lecture topic material before and
after each lecture on that topic)
You will be expected to know
Local Search Algorithms
Hill-climbing search
Uninformed (also called blind)
search algorithms
This Lecture
Read Chapter 3.1-3.4
Next Lecture
Read Chapter 3.5-3.7
(Please read lecture topic material before and after each lecture on that topic)
You will be expected to know
Overview of uninformed sear
Solving problems by
searching
This Lecture
Read Chapters 3.1 to 3.4
Next Lecture
Read Chapter 3.5 to 3.7
(Please read lecture topic material before and after each lecture on that topic)
1
You will be expected to know
State-space search
Definitions of a
Introduction to AI
&
Intelligent Agents
This Lecture
Read Chapters 1 and 2
Next Lecture
Read Chapter 3.1 to 3.4
(Please read lecture topic material before and after each lecture on that
topic)
You will be expected to know
Agent: Anything that can be viewe
optimum is to assume, by way of contradiction, that it is not optimum.
In this case, the greedy strategy must have erred in one of its choices,
so lets look at the rst error this strategy made. Because all previous
greedy choices were not errors, and henc
ollowtheruleofchoosing the largest i to be the root, we get trees that
are no better, on the average, than a randomly chosen trees). The
problem with such an approach is that it makes decisions that are
locally optimum, although perhaps not globallyoptimu
C[i][i+2],andsoonuntiltheupperrightcornerofthearrayisreached.Rewritingthecodetodothis directly, and
adding an array R[][] to keeptrackoftherootsofsubtrees,weobtain: 1 int
W[n][n]; 2 int R[n][n]; 3 int C[n][n]; 4 5/Fillinmaindiagonal 6 for (int i =
0; i <
repeatedly add the cheapest edge connecting the spanning-tree-to-be
to a vertex not yet in it. If the
verticesnotyetinthetreearestoredinapriorityqueueimplementedbyaFibo
nacciheap,thetotaltime requiredbyPrimsalgorithmwillbe O(|E|+|V|log|
V|). But why does
CS-171, Intro to A.I. Mid-term Exam Summer Quarter, 2016
YOUR NAME:
YOUR ID:
ID TO RIGHT:
ROW:
SEAT:
The exam will begin on the next page. Please, do not turn the page until told.
When you are told to begin the exam, please check first to make sure that y
Below, for each problem on this Midterm Exam, Perfect is the percentage of students who received
full credit, Partial is the percentage who received partial credit, and Zero is the percentage who
received zero credit.
(Due to rounding, values below may be
Quiz Chapters 1,2,3 (In part)
Note the two versions A & B
Oct.7 2010
Exam A: 1. A chess playing agent operates in an episodic task environment
a) True, b) False
Exam B: 1.
Quiz 2 Chapter 3
Note the two versions A & B
Oct.14 2010
Exam A: 1. Uniform Cost Search is opEmal if the step cost is posiEve.
a) True b) False
Exam B: 1. Breadth First
Quiz 3 Chapter 3/4
Note the two versions A & B
Oct.21 2010
Exam A: 1. Local search requires exponenFal memory
a) True b) False
Exam B: 1. Local search is complete
Quiz 3 Chapter 6
Note the two versions A & B
Oct.28 2010
Exam A: 1. Constraint propagaDon does not necessarily converge on a constraint graph
with loops
a) True b) Fa
HW 6 - Solutions
cs171
1. (a) J : the car is at Johns house. F : the car is at Freds house.
(b) S1: J F , S2: J F
(c) No, you cannot determine where the car is
2.
(7.4)
(a)
(b)
(c)
(d)
(e)
(f)
(g)
correct
incorrect
correct
incorrect
correct
correct
corre
HW 5 - Solutions
cs171
n
n
1. (a) (In the following I will use the notation k1 ,k2 ,k3 to mean k1 !k2!k3 ! ). For the time
being, allow states that occur after a goal state (ie a board position where there is
both 3 X s in a row and 3 Os in a row is still