0% found this document useful (0 votes)
18 views6 pages

Alg GF

An algorithm is a set of well-defined steps to solve a problem by taking inputs and producing outputs. Key factors that affect performance include correctness, efficiency, scalability, and resource usage. A good algorithm has precisely defined inputs/outputs, unambiguous steps, a limited number of instructions, and language independence. Pseudo-code is an informal way to write algorithms using simple programming logic without strict syntax, while an algorithm focuses on the problem-solving steps without regard to implementation details. Common algorithm types include searching, sorting, hashing, divide-and-conquer, greedy, dynamic programming, randomized, and brute force approaches.

Uploaded by

Onindo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Alg GF

An algorithm is a set of well-defined steps to solve a problem by taking inputs and producing outputs. Key factors that affect performance include correctness, efficiency, scalability, and resource usage. A good algorithm has precisely defined inputs/outputs, unambiguous steps, a limited number of instructions, and language independence. Pseudo-code is an informal way to write algorithms using simple programming logic without strict syntax, while an algorithm focuses on the problem-solving steps without regard to implementation details. Common algorithm types include searching, sorting, hashing, divide-and-conquer, greedy, dynamic programming, randomized, and brute force approaches.

Uploaded by

Onindo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Read the passage and answer the question A .

Definition

An algorithm is a finite set of well-defined instructions carried out in a specific order to


solve a particular problem. It takes a set of input(s) and produces the desired output.

For example,
An algorithm to add two numbers:
Take two number inputs
Add numbers using the + operator
Display the result

Qualities of a Good Algorithm

1.Input and output should be defined precisely.


2.Each step in the algorithm should be unambiguous, which means that its instructions
should be clear and straightforward.
3.Algorithms should have a limited number of instructions, i.e., the instructions should be
countable.
4.Algorithms should be most effective among many different ways to solve a problem.
5.An algorithm shouldn't include computer code.
6.An algorithm must be language-independent, which means that its instructions can be
implemented in any language and produce the same results.

Need of Algorithm

1.To understand the basic idea of the problem.


2.To find an approach to solve the problem.
3.To understand the basic principles of designing the algorithms.
4.To compare the performance of the algorithm with respect to other techniques.
5.To improve the efficiency of existing techniques.
6.The Algorithm gives a clear description of requirements and goal of the problem to the
designer.
7.To measure the behaviour (or performance) of the methods in all cases (best cases,
worst cases, average cases) and analyze the complexity (time and space) of the problems
concerning input size without implementing and running it; it will reduce the cost of
design.
8.With the help of an algorithm, we can also identify the resources (memory, input-
output) cycles required by the algorithm.
Difference between Algorithm and the Pseudo-code

1.An algorithm is simply a problem-solving process, which is used not only in computer
science to write a program but also in our day to day life. It is nothing but a series of
instructions to solve a problem or get to the problem's solution. It not only helps in
simplifying the problem but also to have a better understanding of it.
2.However, Pseudo-code is a way of writing an algorithm. Programmers can use
informal, simple language to write pseudo-code without following any strict syntax. It
encompasses semi-mathematical statements.

Types of Algorithms

There are several types of algorithms available. Some important algorithms are:
1.Brute Force Algorithm: It is the simplest approach for a problem. A brute force
algorithm is the first approach that comes to finding when we see a problem.
2.Recursive Algorithm: A recursive algorithm is based on recursion. In this case, a
problem is broken into several sub-parts and called the same function again and again.
3.Backtracking Algorithm: The backtracking algorithm basically builds the solution by
searching among all possible solutions. Using this algorithm, we keep on building the
solution following criteria. Whenever a solution fails we trace back to the failure point
and build on the next solution and continue this process till we find the solution or all
possible solutions are looked after.
4.Searching Algorithm: Searching algorithms are the ones that are used for searching
elements or groups of elements from a particular data structure. They can be of different
types based on their approach or the data structure in which the element should be found.
5.Sorting Algorithm: Sorting is arranging a group of data in a particular manner
according to the requirement. The algorithms which help in performing this function are
called sorting algorithms. Generally sorting algorithms are used to sort groups of data in
an increasing or decreasing manner.
6.Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm. But
they contain an index with a key ID. In hashing, a key is assigned to specific data.
7.Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems,
solves a single sub-problem and merges the solutions together to get the final solution. It
consists of the following three steps divide, solve and combine.
8.Greedy Algorithm: In this type of algorithm the solution is built part by part. The
solution of the next part is built based on the immediate benefit of the next part. The one
solution giving the most benefit will be chosen as the solution for the next part.
9.Dynamic Programming Algorithm: This algorithm uses the concept of using the already
found solution to avoid repetitive calculation of the same part of the problem. It divides
the problem into smaller overlapping subproblems and solves them.
10.Randomized Algorithm: In the randomized algorithm we use a random number so it
gives immediate benefit. The random number helps in deciding the expected outcome.
Factors of an Algorithm

The following are the factors to consider when designing an algorithm:


1.Modularity: Modularity is a feature of an algorithm by which you can break a given
problem down into small-small modules or small-small steps, which is a basic definition
of an algorithm.
2.Correctness: When the given inputs produce the desired output it indicates that the
algorithm was designed correctly.
3.Maintainability: It means that the algorithm should be designed in a straightforward,
structured way so that when you redefine the algorithm, no significant changes are made
to the algorithm.
4.Functionality: It takes into account various logical steps to solve a real-world problem.
5.Robustness: Robustness refers to an algorithm's ability to define your problem clearly.
6.User-friendly: If the algorithm is difficult to understand, the designer will not explain it
to the programmer.
7.Simplicity: If an algorithm is simple, it is simple to understand.
8.Extensibility: An algorithm should be extensible, if another algorithm designer or
programmer wants to use it.

Answer the following question A.

1. (a) what do understand by the term” algorthim “? (Not more 20


words ). Discuss some key factors that can affect the performance
and effectives of an algorithm.Not more 25 words
(b) state some important qualities of a good algorithm.
2.(a) what is pseudo-code? Write the diffterences between algorithm
and pseudo-code.

(b) there are several typs of algorithms available, make a list of least 6
such algorithms we us during solve any problem and write short notes
on them .
1. (a) What do you understand by the term "algorithm"? Discuss some
key factors that can affect the performance and effectiveness of an
algorithm.
An algorithm is a finite set of well-defined instructions executed in a specific
order to solve a particular problem. It takes inputs and produces the desired
output. Key factors that can affect the performance and effectiveness of an
algorithm include:
 Correctness: The algorithm must produce the correct output for all
possible valid inputs. If an algorithm is incorrect, its results are unreliable.
 Efficiency: An algorithm should perform the task using a
reasonable amount of resources, such as time and memory. Efficient
algorithms minimize these resources to achieve their goal.
 Scalability: An algorithm's performance should not degrade
significantly as the size of the input increases. Algorithms with good
scalability can handle larger and more complex problems.
 Modularity: Breaking down the algorithm into smaller modules or
steps enhances its readability, maintainability, and reusability.
 Robustness: The algorithm should handle unexpected inputs or
edge cases gracefully, avoiding errors or crashes.
 Simplicity: A simple algorithm is easier to understand, implement,
and debug. Complexity can lead to confusion and mistakes.
 Adaptability: An algorithm should be designed to accommodate
changes in requirements or inputs without significant redesign.
 Resource Usage: Efficient memory and computational resource
usage contribute to an algorithm's effectiveness. Algorithms that use
resources judiciously are preferable.
 Algorithmic Paradigm: Different types of problems may require
different algorithmic approaches, such as divide and conquer, greedy,
dynamic programming, etc. Choosing the appropriate paradigm can
greatly impact the solution's efficiency.
2. (b) State some important qualities of a good algorithm.
Some important qualities of a good algorithm are:
1. Precise Input and Output: The inputs and outputs should be
clearly defined without ambiguity.
2. Unambiguous Steps: Each step should be straightforward and
clearly defined, leaving no room for interpretation.
3. Limited Instructions: The algorithm should have a reasonable
number of instructions to keep it manageable and understandable.
4. Effectiveness: An algorithm should provide an efficient solution
compared to alternative methods.
5. No Computer Code: Algorithms are language-independent and
shouldn't include actual programming code.
6. Language-Independence: The instructions should be
implementable in any programming language, producing the same results.
2. (a) What is pseudo-code? Write the differences between an algorithm
and pseudo-code.
Pseudo-code is a way of writing an algorithm using informal, simple language
that resembles programming logic without adhering to strict syntax rules. It helps
programmers outline the steps of an algorithm in a more human-readable form
before writing actual code. The main differences between an algorithm and
pseudo-code are:
 Formality: An algorithm is a high-level description of a problem-
solving process, while pseudo-code is a less formal representation of the
algorithm's steps.
 Syntax: Algorithms can be written using formal programming
languages or natural language, while pseudo-code uses simplified
language that may not strictly follow programming language syntax.
 Readability: Pseudo-code is designed to be easily readable by
both programmers and non-programmers, whereas an algorithm might be
more technical.
 Flexibility: Pseudo-code allows for more flexibility in terms of
describing steps, whereas an algorithm can be more rigid in its structure.
3. (b) There are several types of algorithms available. Make a list of at
least such algorithms we use during solving any problem and write short
notes on them.
Sure, here are six types of algorithms and brief explanations for each:
1. Brute Force Algorithm: This is a straightforward approach where
all possible solutions are explored to find the correct one. It's simple but
can be inefficient for large problems.
2. Recursive Algorithm: A problem is broken into smaller sub-
problems of the same type. Each sub-problem is solved recursively,
leading to a solution for the entire problem.
3. Backtracking Algorithm: This involves building solutions
incrementally while making choices at each step. If a choice leads to a
dead-end, the algorithm backtracks and tries another choice.
4. Searching Algorithm: Algorithms used to find specific elements
within data structures, like linear or binary search in arrays or lists.
5. Sorting Algorithm: Sorting rearranges data in a particular order.
Examples include bubble sort, merge sort, and quicksort.
6. Divide and Conquer Algorithm: The problem is divided into
smaller sub-problems, solved independently, and then combined to solve
the original problem. An example is merge sort.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy