Design & analysis of algorithm
BSCS 6th semester 1st lecture
(date: 24/08/2023)
By Rahila Aslam
The Role of Algorithms in Computing
Algorithms play a crucial role in computing by providing a set of
instructions for a computer to perform a specific task. They are used
to solve problems and carry out tasks in computer systems, such
as sorting data, searching for information, image processing, and much
more. An algorithm defines the steps necessary to produce the desired
outcome, and the computer follows the instructions to complete the task
efficiently and accurately.
The development of efficient algorithms is a central area of computer science
and has significant impacts in various fields, from cryptography and finance
to machine learning and robotics.
Algorithms are widely used in various industrial areas to improve
efficiency, accuracy, and decision-making. Some of the key applications
include:
1.Manufacturing: Algorithms are used to optimize production processes
and supply chain management, reducing waste and increasing efficiency.
2.Finance: Algorithms are used to analyze financial data and make
predictions, enabling traders and investors to make informed decisions.
3.Healthcare: Algorithms are used to process and analyze medical images,
assist in diagnosing diseases, and optimize treatment plans.4Retail:
Algorithms are used for customer relationship management, personalized
product recommendations, and pricing optimization.
4.Transportation: Algorithms are used to optimize routes for delivery and
transportation, reducing fuel consumption and increasing delivery speed.
5.Energy: Algorithms are used to optimize energy generation, distribution,
and consumption, reducing waste and increasing efficiency.
6.Security: Algorithms are used to detect and prevent security threats, such
as hacking, fraud, and cyber-attacks.
In these and many other industries, algorithms play a crucial role in
automating tasks, improving decision-making, and enhancing overall
performance and efficiency.
Algorithms are fundamental to computing and play a crucial role in
many aspects of the field. Some of the key needs and applications of
algorithms in computing include:
1.Data processing: Algorithms are used to process and analyze large
amounts of data, such as sorting and searching algorithms.
2.Problem solving: Algorithms are used to solve computational problems,
such as mathematical problems, optimization problems, and decision-
making problems.
3.Computer graphics: Algorithms are used to create and process images
and graphics, such as image compression algorithms and computer-
generated graphics algorithms.
4.Artificial Intelligence: Algorithms are used to develop intelligent
systems, such as machine learning algorithms, natural language processing
algorithms, and computer vision algorithms.
5.Database management: Algorithms are used to manage and organize
large amounts of data in databases, such as indexing algorithms and query
optimization algorithms.
6.Network communication: Algorithms are used for efficient
communication and data transfer in networks, such as routing algorithms
and error correction algorithms.
7.Operating systems: Algorithms are used in operating systems for tasks
such as process scheduling, memory management, and disk management.
In computing, algorithms are essential for solving complex problems and
tasks, improving efficiency and performance, and enabling new
technologies and applications.
Algorithms play a critical role in networking and communication
systems, enabling efficient and reliable data transfer and
communication. Some of the key applications of algorithms in
networking include:
1.Routing: Algorithms are used to determine the best path for data to
travel from one device to another, such as shortest path algorithms and load
balancing algorithms.
2.Error correction: Algorithms are used to detect and correct errors that
occur during data transmission, such as cyclic redundancy check (CRC)
algorithms and forward error correction (FEC) algorithms.
3.Data compression: Algorithms are used to reduce the amount of data
being transmitted, such as Huffman coding and run-length encoding
algorithms.
4.Network security: Algorithms are used to secure networks and protect
against attacks, such as encryption algorithms and authentication
algorithms.
5.Quality of Service (QoS): Algorithms are used to prioritize different
types of data and ensure that critical applications receive adequate
bandwidth, such as traffic shaping algorithms and congestion control
algorithms.
6.Wireless networks: Algorithms are used in wireless networks for tasks
such as signal optimization, channel allocation, and power control.
7.Network topology: Algorithms are used to analyze and optimize
network topology, such as graph algorithms and network partitioning
algorithms.
In networking, algorithms play a vital role in ensuring efficient and reliable
data transfer, maintaining network security, and optimizing network
performance.
Pre-requisite: Introduction to Algorithms
• The word Algorithm means “a process or set of rules to be
followed in calculations or other problem-solving operations”.
Therefore Algorithm refers to a set of rules/instructions that step-
by-step define how a work is to be executed upon in order to get
the expected results.
• Algorithms are at the core of most techniques used in
contemporary computers alongside other technologies.
• An algorithm is an abstraction of a program to be executed on a
physical machine(model of Computation).
Algorithm Design Technique
• Strategy or paradigm — General approach to solve program
algorithmically
• Brute Force — Straight forward technique with naïve
approach
• Divide and conquer — problem is divided into smaller instances
• Decrease and conquer — Instance size is decreased to solve the
problem
• Transform and conquer — Instance is modified and then solved
• Dynamic Programming — Results of smaller ,
reoccurring instances are obtained to solve problem
• Greedy Technique — Solve the problem by making locally
optimal decisions
Analysis of Algorithm
• Time Efficiency — Indicates how fasts algorithm runs
• Space Efficiency — How much extra memory the algorithm
needs to complete its execution
• Simplicity — Generating sequence of instructions which are easy
to understand
• Generality — Range of inputs it can accept .
Practical applications of algorithms:
• The Internet without which it is difficult to imagine a day is the
result of clever and efficient algorithms. With the aid of these
algorithms, various sites on the Internet are able to manage and
manipulate this large volume of data. Finding good routes on
which the data will travel and using search engine to find pages
on which particular information is present.
• Another great milestone is the Human Genome Project which has
great progress towards the goal of identification of the 100000
genes in human DNA, determining the sequences of the 3 billion
chemical base pairs that make up the human DNA, storing
this huge amount of information in databases, and developing
tools for data analysis. Each of these steps required sophisticated
and efficient algorithms.
• The day-to-day electronic commerce activities is hugely
dependent on our personal information such as credit/debit card
numbers, passwords, bank statements, OTPs and so on. The core
technologies used include public-key cryptography and digital
signatures which are based on numerical algorithms and number
theory.
• The approach of linear programming is also one such technique
which is widely used like
• In manufacturing and other commercial enterprises
where resources need to be allocated scarcely in the
most beneficial way.
• Or a institution may want to determine where to spend
money buying advertising in order to maximize the
chances of their institution to grow.
• Shortest path algorithm also has an extensive use as
• In a transportation firm such as a trucking or railroad
company, may have financial interest in finding shortest
path through a road or rail network because taking
shortest path result in lower labour or fuel costs.
• Or a routing node on the Internet may need to find the
shortest path through the network in order to route a
message quickly.
• Even an application that does not require algorithm content at the
application level relies heavily on algorithms as the application
depends on hardware, GUI, networking or object orientation and
all of these make an extensive use of algorithms.
The role of algorithms in computing is crucial as they are the backbone of
any software application or system. Here are some advantages,
disadvantages, important points, and reference books related to the role of
algorithms in computing:
Advantages:
1. Algorithms provide a systematic approach to solving problems
and performing tasks efficiently.
2. Algorithms can be optimized to improve the performance of
software applications and systems.
3. Algorithms can be reused in different applications and systems,
which can save time and resources.
Disadvantages:
1. Poorly designed algorithms can cause software applications and
systems to perform poorly or fail altogether.
2. The design and optimization of algorithms can be time-
consuming and require a high level of expertise.
3. Algorithms may not always be suitable for certain types of
problems or tasks.
Important points:
1. Algorithms are a set of steps or instructions that define a process
or method for solving a problem or performing a task.
2. The efficiency of an algorithm is measured by its time and space
complexity.
3. Different algorithms may be better suited for different types of
problems or tasks.
4. The design and optimization of algorithms are ongoing processes
that require constant attention and improvement.
Asymptotic Notation and Analysis (Based on input size) in Complexity
Analysis of Algorithms
Asymptotic Analysis is defined as the big idea that handles the above issues
in analyzing algorithms. In Asymptotic Analysis, we evaluate the
performance of an algorithm in terms of input size (we don’t measure the
actual running time). We calculate, how the time (or space) taken by an
algorithm increases with the input size.
Asymptotic notation is a way to describe the running time or space
complexity of an algorithm based on the input size. It is commonly used in
complexity analysis to describe how an algorithm performs as the size of
the input grows. The three most commonly used notations are Big O,
Omega, and Theta.
1. Big O notation (O): This notation provides an upper bound on the
growth rate of an algorithm’s running time or space usage. It
represents the worst-case scenario, i.e., the maximum amount of
time or space an algorithm may need to solve a problem. For
example, if an algorithm’s running time is O(n), then it means
that the running time of the algorithm increases linearly with the
input size n or less.
2. Omega notation (Ω): This notation provides a lower bound on the
growth rate of an algorithm’s running time or space usage. It
represents the best-case scenario, i.e., the minimum amount of
time or space an algorithm may need to solve a problem. For
example, if an algorithm’s running time is Ω(n), then it means
that the running time of the algorithm increases linearly with the
input size n or more.
3. Theta notation (Θ): This notation provides both an upper and
lower bound on the growth rate of an algorithm’s running time or
space usage. It represents the average-case scenario, i.e., the
amount of time or space an algorithm typically needs to solve a
problem. For example, if an algorithm’s running time is Θ(n),
then it means that the running time of the algorithm increases
linearly with the input size n.
In general, the choice of asymptotic notation depends on the problem and
the specific algorithm used to solve it. It is important to note that
asymptotic notation does not provide an exact running time or space usage
for an algorithm, but rather a description of how the algorithm scales with
respect to input size. It is a useful tool for comparing the efficiency of
different algorithms and for predicting how they will perform on large
input sizes.
Why performance analysis?
There are many important things that should be taken care of, like user-
friendliness, modularity, security, maintainability, etc. Why worry about
performance? The answer to this is simple, we can have all the above
things only if we have performance. So performance is like currency
through which we can buy all the above things. Another reason for
studying performance is – speed is fun! To summarize, performance ==
scale. Imagine a text editor that can load 1000 pages, but can spell check 1
page per minute OR an image editor that takes 1 hour to rotate your image
90 degrees left OR … you get it. If a software feature can not cope with the
scale of tasks users need to perform – it is as good as dead.