0% found this document useful (0 votes)
5 views

Algorithm

Uploaded by

lazarozijan04
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Algorithm

Uploaded by

lazarozijan04
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

ALGORITHM

A DEEPER DIVE AND UNDERSTANDING THE BASICS


ALGORITHM

An ALGORITHM is a procedure used


for solving a problem or performing a
computation. Algorithms act as an
exact list of instructions that conduct
specified actions step by step in either
hardware- or software-based routines.

Algorithm could be used for sorting


sets of numbers or for more
complicated tasks, such as
recommending user content on social
media. Algorithms typically start with
initial input and instructions that
describe a specific computation. When
the computation is executed, the
process produces an output.
ALGORITHM

HOW DO ALGORITHM WORKS?

Algorithms work by following a set


of instructions or rules to complete
a task or solve a problem. They
can be expressed as natural
languages, programming
languages, pseudocode,
flowcharts and control tables.
Natural language expressions are
rare, as they are more ambiguous.
Programming languages are
normally used for expressing
algorithms executed by a
computer.
ALGORITHM

Algorithm Example: • It should compare the first power of


• X-Men Character Sorting each character. If one character has a
power the other doesn't, that
character is considered "greater."
Problem: • If both characters have the same first
• Sort a list of X-Men characters by their power, compare their second powers,
mutant powers. and so on.
Define a sorting function:
Create a list of X-Men characters: • The function should take two
• Each character should have a name and a characters as input.
list of their mutant powers.
• It should compare the first power of
each character. If one character has a
Define a sorting function: power the other doesn't, that
character is considered "greater."
• The function should take two characters
as input. • If both characters have the same first
power, compare their second powers,
and so on.
Sort the list:
Use a sorting algorithm like bubble sort, quicksort,
or mergesort to sort the list of characters using the
defined sorting function.
WHAT ARE THE TYPES OF
ALGORITHMS?
There are several types of algorithms, all designed to accomplish different
tasks.
ALGORITHM

Search engine algorithm Recursive algorithm


• This algorithm takes search strings of • This algorithm calls itself repeatedly
keywords and operators as input, until it solves a problem. Recursive
searches its associated database for algorithms call themselves with a
relevant webpages and returns results.
smaller value every time a recursive
Encryption algorithm function is invoked.
• This computing algorithm transforms data Backtracking algorithm
according to specified actions to protect it.
A symmetric key algorithm, such as the • This algorithm finds a solution to a
Data Encryption Standard, for example, given problem in incremental
uses the same key to encrypt and decrypt approaches and solves it one piece
data. If the algorithm is sufficiently at a time.
sophisticated, no one lacking the key can
decrypt the data. Divide-and-conquer algorithm
Greedy algorithm • This common algorithm is divided
into two parts. One part divides a
• This algorithm solves optimization
problems by finding the locally optimal
problem into smaller subproblems.
solution, hoping it is the optimal solution at The second part solves these
the global level. However, it does not problems and then combines them to
guarantee the most optimal solution. produce a solution.
ALGORITHM

Dynamic programming algorithm Hashing algorithm


• This algorithm solves problems by • This algorithm takes data and
dividing them into subproblems. The
results are then stored to be applied to converts it into a uniform
future corresponding problems. message with a hashing.
Brute-force algorithm
• This algorithm iterates all possible Randomized algorithm
solutions to a problem blindly,
searching for one or more solutions to • This algorithm reduces running
a function. times and time-based
Sorting algorithm. complexities. It uses random
• Sorting algorithms are used to elements as part of its logic.
rearrange data structures based on a
comparison operator, which is used to
decide a new order for data.
ALGORITHM

Key Components of an Algorithm

Input: The data that the algorithm processes.


Output: The result produced by the algorithm.
Process: The sequence of steps or operations that are performed on the input to produce the
output.

Three basic building blocks

Sequencing: An algorithm is a step-by-step process, and the order of those steps are crucial to
ensuring the correctness of an algorithm.
Selection: Algorithms can use selection to determine a different set of steps to execute based
on a Boolean expression.
Iteration: Algorithms often use repetition to execute steps a certain number of times or until a
certain condition is met.
ALGORITHM

THE FOLLOWING ARE THE EXAMPLES OF ALGORITM IN REAL LIFE:

• Following a recipe
• Tying shoelaces
• Facial recognition
• Traffic signals
• Sorting documents and papers
• Searching for a book in the library
ALGORITHM

Algorithms are essential in various fields:

• Computer Science: Data structures, operating systems,


databases.
• Artificial Intelligence: Machine learning, natural language
processing.
• Scientific Computing: Simulations, data analysis.
• Engineering: Optimization, control systems.
• Business: Decision-making, logistics.
What is the purpose of an algorithm,
and can you provide a real-world
example?

You might also like