You are on page 1of 3

Assignment:

Submitted to:
Sir Shahzad Ali
Submitted by:

Roll:

Class:

Topic:
Algorithms
Question 1. Define Algorithm and Why algorithms are important?

Answer: Algorithm is a set of steps to solve a problem in the compter system

Algorithms are the building blocks of computer programs. They are as important to
programming as recipes are to cooking. An algorithm is a well-defined procedure that takes
input and produces output. The main difference here is that algorithms are mathematical or
textual in nature.

Question 2. What is the difference between iterative and recursive structure of algorithms?
Explain with examples.

Answer: Recursive functions work through the process of calling themselves until a condition is
met whereas iteration uses a looping control structure in order to repeat a section of code until
a certain condition is met. For example ,while ,do while and for. The only
real difference IMO between them is compilation differences.

Question 3. Differentiate between the efficiency, correctness and complexity of algorithms

Answer: Efficiency:-

In computer science, algorithmic efficiency is a property of an algorithm which


relates to the number of computational resources used by the algorithm. An algorithm must be
analyzed to determine its resource usage, and the efficiency of an algorithm can be measured
based on usage of different resources.

Correctness:-

Correctness of an algorithm is asserted when it is said that the algorithm is correct


with respect to a specification. Functional correctness refers to the input-output behaviour of the
algorithm (i.e., for each input it produces the expected output).

Complexity:-

Algorithm complexity is a measure which evaluates the order of the count of


operations, performed by a given or algorithm as a function of the size of the input data. To put
this simpler, complexity is a rough approximation of the number of steps necessary to execute
an algorithm.

You might also like