



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




(a)ALGORITHMS ARE ANALYSED BASED ON THEIR COMPLEXITY. EXPLAIN THE CONCEPT OF ALGORITHM ANALYSIS INTERMS OF
(i)Optimality (2 marks)
An algorithm for a given problem is optimal if its complexity reaches the lower bound over all the algorithms solving this problem. An optimal algorithm is an algorithm that solves a problem in the best possible way, meaning there are no better algorithms for this.
(ii)Reduction (2 marks)
Reductions are operations that convert one problem into another. Reduction refers to translation of instances from one type of problem to instances of another such that the answers are preserved.
Reductions are a way to show that two problems are essentially identical. A fast algorithm for one of the problems implies a fast algorithm for the other.
(b)EXPLAIN THE CONCEPT OF GREEDY ALGORITHM. WHAT ARE THE FEATURES AND CHARACTERISTICS OF PROBLEMS SOLVED BY GREEDY ALGORITHM (4 MARKS).
A greedy algorithm always makes the choice that seems to be the best at that moment. This means that it makes a locally-optimal choice in the hope that this choice will lead to a globally-optimal solution. A problem must comprise these two components for a greedy algorithm to work.
Characteristics and Features of Problems solved by Greedy Algorithms
To construct the solution in an optimal way, algorithm maintains two sets.
Components of greedy algorithms
(c)DESCRIBE THE GREEDY ALGORITHM AND LIST DOWN THE FEATURES AND CHARACTERISTICS OF PROBLEMS SOLVED BY IT (5MARKS)
Greedy Algorithm works by making the decision that seems most promising at any moment. It never reconsiders this decision, whatever situation may arise later.
Features and characteristics of problems solved by greedy algorithm To construct the solution in an optimal way, algorithm maintains two sets.
The greedy algorithm consists of four functions.
independent view. The process of providing only the essentials and hiding the details is known as abstraction. (f)EXPLAIN HOW LINEAR EQUATIONS CAN BE RESOLVED IN A CASE OF TWO UNKNOWNS USING THE SIMULTANEOUS METHOD. USE EXAMPLE OF CHOICE TO ILLUSTRATE YOUR EXPLANATION (5MARKS).
Steps.
Example.
Step 1: Simplify if needed.
Both of these equations are already simplified. No work needs to be done here.
Step 2: Solve one equation for either variable.
It does not matter which equation or which variable you choose to solve for. Just keep it simple.
Since the x in the second equation has a coefficient of 1, that would mean we would not have to divide by a number to solve for it and run the risk of having to work with fractions. The easiest route here is to solve the second equation for x, and we definitely want to take the easy route.
You would not be wrong to either choose the other equation and/or solve for y, again you want to keep it as simple as possible.
Solving the second equation for x we get:
Step 3 and Step 4: Substitute what you get for step 2 into the other equation and Solve for the remaining variable
Step 5: Solve for second variable.
Step 6: Check the proposed ordered pair solution in BOTH original equations.
You will find that if you plug the ordered pair (4, 3) into BOTH equations of the original system, that this is a solution to BOTH of them.