CS260 Flashcards
What is an algorithm?
Its a procedure used to solve a problem or perform a computation
What do we intend for algorithms to be able to do?
Solve any instance of a class of problems eg. solve a list no matter the order
Solve for inputs of different size
May guarantee to give the correct answer with a proof
May have mathematical limits on whats possible
Why do we analyze algorithms?
This is because we want to measure the cost of an algorithm. This is usually quantified using the running time which is a function expressed in terms of an input size n.
Whats the mathematical proof for a polytime algo?
It states that for c>0 and d>0 on every input size N the max number of steps taken by a poly time algo is cN^d where d is the degree and c constant
What is average case running time
Obtain bound on running time of algorithm on a random input as a function of input size N
What is the desirable scaling property
It states that when the input size doubles the algo should slow down by a constant factor c=2^d
The algorithm ispolytime if the above is true
What are the exceptions to the general rule of thumb that poly algos are efficient and exponential inefficent?
1.When poly algos have high coffiencients this is impractical but can help reveal something about problem
2.Some of the worst case running times r rare for certain exponential algos.
What is stable matching?
Stable matching is an economic theory in which there are two parties that need to be paired together.The aim is to have have no unstable pairs and ensure that every participant is satisfied with their pairing.
What is an unstable pair?
Suppose we have a man m and women w.If man m prefers w to his current matching and w prefers m to her current match.They may want to switch and defect.
What type of system does a stable matching aim to make?
A self enforcing one meaning that acting in ones self interest does not destabilze the system
What is a stable matching?
It is a perfect matching meaning everyone is matched bijectively and a stable matching.No incentive for a pair to undermine the assignment by defecting.
Describe the Gale-Shapley algorithm
1.While there is a man m who is free and hasnt proposed to everyone.
2.Check if women w who is highest on m’s list prefers m to her current match if yes match the twoAnd make the other m free..Or if she is free match them.Else reject.
What are the observations from the stable matching algorithm?
1.The man proposes in decreasing order meaning they get a worse and worse match.
2.The womens matches increase and her preferences go in ascending order.Once the women is matched she never gets unmatched
What is the depth of set in interval partioning?
the depth of the set of open intervals is the maximum number of intervals that contain a given moment in time.
Describe the interval partitioning algorithm.Whats the time complexity
1.Sort jobs by earliest starting time
2.Have a variable to keep track of number of classrooms used
3.Iterate through jobs and check to see if they overlap if yes assign a new classroom.And increment classroom variable.
4.If not assign current classroom.
Time complexity is O(nlogn) due to sorting