Operating Systems
CMPT 300
Based on William Stallings
Revised by S. Pearce
1
2
3
This PPT is largely based on Stallings (Chapter 14).
4
Offense is really easy, defense is really hard
Josh Corman, I Am The Cavalry - https:/www.iamthecavalry.org/about/histo
find more resources at oneclass.com
find more resources at oneclass.com
find more resources at oneclass.com
find more resources at oneclass.com
find more resources at oneclass.com
find more resources at oneclass.com
find more resources at oneclass.com
fin
Hash Table Collisions
Occurs when 2 different keys are mapped to the same index
2 main ways of dealing with them:
Open addressing
Separate chaining
Open Addressing:
When insertion results in collision, look for somewhere else to put the value
Start at ind
Quicksort Continued
Every partition step requires less work. Amount of work doing is ~number of items in array (holds up
better if the array is larger).
How many times does n have to be divided in half before the result is 1?
log2(n) times
Quicksort perfo
Graphs
Graph theory considered to be born with Euler, solved Konigsberg bridge problem
Town has 7 bridges in center. Was it possible to walk across each bridge just once and return to where
they started
Euler proved it was impossible, proof involved repre
Disk Scheduling and External Sorting
Hard Drive: consists of number of disks, aligned with each other, sit on spindle
Disk head array - series of heads which sit on top of the disks
Disk head reads from one side of one disk at a time
Raid: composed of mul
Priority Queue ADT
First thing to be removed is item with highest priority
Could be lowest first or highest first
Actual priority could be based on anything you want
Inserting and remove in at most O(log n) time.
Removal must be done in priority order.
Re
Error Handling
3 basic ways of dealing with poping from an empty stack:
Obviously can't return thing at top of stack. If you'd return a pointer, could return a null pointer, but
might not work. If stack could hold all possible int values, -1 would not be
Cost of Dijkstra's depends both on size of edge list and size of vertex list
More than one variable contributes to running time
Also very dependent on data structure used to store priority queue
e = # edges
v = # vertices
Dijk's:
Initialize priority queue
Insertion:
BST properties must hold after insertion
Roughly O(height), same as search.
Finding correct position when inserting is really easy, just search for the value. Then put it at the null
child where you want to insert it. Need to look ahead, howeve
Dijkstra's Algorithm Analysis
Want to find path from A to B - Dijk's gets you from A to everywhere.
If graph doesn't change, Dijk's can be very useful, as you can precompute. However, if you have to
check on the fly, not as good, wasting time processing t
Tree:
Set of nodes or vertices
Has single starting point (root, at top)
Each node is connected by an edge to another node
Connected graph
One less edge than number of nodes
Can use descendants for children, even if not direct
Also have ancestors - parents
Possible to write Depth and Breadth first search with identical code, just different data structures.
Shortest Path Problem
What is smallest cost path from one vertex to another?
Unweighted - shortest = least # of edges
Weighted - shortest = smallest sum
Traversals (+ recursion)
void print(Node* nd) cfw_
if (nd != null) cfw_
print(nd->leftChild);
cout < nd.data < endl;
print(nd->right);
In order traversal.
How can you determine size with a traversal? Increment size as you traverse.
At least 2 ways of do
Hash Tables
Data needs to be accessed really really quickly, but does not have to be maintained in order. Order is
not important, don't care about "adjacent" values or anything. Don't want to print out a bunch of stuff in
order.
Possible solutions:
Balanc
Node is not allowed to be "doubly black" - will see on Monday
Insert as for a BST and make the new node red
- from here, can violate properly that both a red node's children are black (is parent red), or could
violate property that every path from node to
Merge - O(n) operation
Have two sorted stacks want to put into one sorted stack. Do something like merge?
Like partitioning, doesn't actually sort. Just brings two (sorted?) sub arrays together
Array of 1 million items contains 1 million sorted subarrays!
Problem Solving and Search
Chapter 3
Outline
Problem-solving agents
Problem formulation
Example problems
Basic search algorithms
Problem-Solving Agents
In the simplest case, an agent will:
formulate a goal and a problem;
search for a sequence of act
CMPT 310
Artificial Intelligence Survey
Simon Fraser University
Summer 2011
Instructor: Oliver Schulte
Assignment 4: Chapters 14, 15, 18. Probabilistic Reasoning, Learning.
Total Marks: 155.
Due Date: August 5, 10:20 am.
Instructions: Check the instructio
Intelligent Agents
Chapter 2
Outline
Agents and environments
Rationality
Task environment:
PEAS:
Performance measure
Environment
Actuators
Sensors
Environment types
Agent types
Agents and Environments
An agent is anything that can be viewed as perce
Midterm Answers, with FFQ(TM) feature
CSC 242
March 2007
Write your NAME legibly on the bluebook. Work all problems. You may use two double-sided
pages of notes. Please hand your notes in with your bluebook. The best strategy is not to spend
more than the
CMPT 310
Artificial Intelligence Survey
Simon Fraser University
Summer 2011
Instructor: Oliver Schulte
Assignment 2: Chapters 4, 5, 6. Revised: June 20.
Total Marks: 63 + 5 bonus.
Due Date: June 22, 11 pm.
Instructions: Check the instructions in the sylla
Informed Search Algorithms
Chapter 4
Outline
Informed Search and Heuristic Functions
For informed search, we use problem-specific knowledge to
guide the search.
Topics:
Best-first search
A search
Heuristics
Recall: General Tree Search
function Tree-Se
Logical Agents: Propositional Logic
Chapter 7
Outline
Topics:
Knowledge-based agents
Example domain: The Wumpus World
Logic in general
models and entailment
Propositional (Boolean) logic
Equivalence, validity, satisfiability
Inference rules and the
Constraint Satisfaction Problems
Chapter 6
Outline
Topics:
CSP examples
Backtracking search for CSPs
Improving backtracking efficiency
Problem structure and problem decomposition
Local search for CSPs
Constraint satisfaction problems (CSPs)
Standard