0% found this document useful (0 votes)
8 views5 pages

Lecture 1

The document introduces algorithms, emphasizing their importance in maximizing computer hardware efficiency. It defines algorithms, distinguishes between general and computer algorithms, and discusses their characteristics and efficiency in design. A practical example illustrates how algorithm choice affects execution time, demonstrating that a slower computer with a more efficient algorithm can outperform a faster computer with an inefficient one.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Lecture 1

The document introduces algorithms, emphasizing their importance in maximizing computer hardware efficiency. It defines algorithms, distinguishes between general and computer algorithms, and discusses their characteristics and efficiency in design. A practical example illustrates how algorithm choice affects execution time, demonstrating that a slower computer with a more efficient algorithm can outperform a faster computer with an inefficient one.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Bayero University, Kano

CSC2204: Analysis of Algorithms

Lecture 1: Introduction to Algorithms

Instructors:
Dr. Muhammad Yusuf
Baffa Sani
Bilal Lawal Alhassan
Faruk Yusha’u

Department of Computer Science


Bayero University, Kano
Introduction to Algorithms

1 Introduction
Algorithms are fundamental to maximizing the benefits of advanced computer hardware.
Just like having the latest and most powerful processors, the efficiency of algorithms de-
termines the overall performance and effectiveness of computational tasks. In this lesson,
we will explore the significance of implementing efficient algorithms, using a practical
example to illustrate their impact on computing systems.

2 Definitions
2.1 Algorithms in General
An algorithm is a step-by-step procedure or set of rules designed to solve a specific problem
or perform a particular task. It provides a systematic approach to problem-solving and
is applicable across various fields. Here are two examples of algorithms in general:

1. Algorithm: Making a Cup of Tea

(a) Add water to the kettle


(b) Boil it
(c) Add tea leaves
(d) Add milk
(e) Add sugar

2. Algorithm: Withdrawing Money from an ATM

(a) Insert the card


(b) Enter the PIN
(c) Enter the amount
(d) Withdraw amount
(e) Check balance
(f) Cancel/clear

1
2.2 Computer Algorithms
A computer algorithm is a step-by-step procedure or set of rules designed to solve a
specific problem or perform a particular task, implemented for execution on a computer.
It provides a systematic approach to writing computer programs and is crucial for software
development. Here are five examples of computer algorithms:

1. Quicksort: An efficient sorting algorithm, commonly used in computer science.

2. Depth-First Search (DFS): An algorithm for traversing or searching tree or graph


data structures.

3. Merge Sort: A divide-and-conquer algorithm for sorting lists.

4. PageRank Algorithm: Used by search engines to rank web pages in their search
results.

5. RSA Algorithm: A public-key cryptosystem algorithm used for secure communica-


tion.

3 Characteristics of an Algorithm
Before delving into the importance of efficient algorithms, let’s review the key character-
istics that define an algorithm:

1. Input and Output: An algorithm must take input and produce some output,
which could be in the form of true/false, a specific value, etc.

2. Definiteness: Each instruction in the algorithm must be clear and unambiguous.

3. Finiteness: The algorithm must terminate after a finite number of steps.

4. Effectiveness: Every instruction in the algorithm must be basic, constituting


simple and executable steps.

4 Efficiency in Algorithm Design


Efficiency in algorithm design is crucial for utilizing the full potential of computer hard-
ware. While powerful processors provide raw computing power, the choice of algorithm
significantly influences the execution time and resource utilization. A well-designed algo-
rithm can substantially enhance performance and optimize resource consumption.

4.1 Resource Usage


Resource usage is a critical aspect of algorithm design, primarily focusing on time and
space considerations.

2
4.1.1 Aposteriori Analysis
Aposteriori analysis involves implementing the algorithm and then measuring the time
taken by the system to successfully execute the program. Practical considerations, such as
the speed of the computer, the programming language used, the compiler or interpreter,
and the skill of the programmers, can impact the actual running time.

4.1.2 Apriori Analysis


Apriori analysis evaluates the algorithm’s running time growth rate before implementa-
tion. This includes:

1. Determining how long the algorithm takes, represented as a function of the size of
the input, denoted as f (n) where n is the size of the input.

2. Analyzing the growth rate of the running time function with respect to the input
size, known as the running time growth rate.

Algorithms are compared based on their running time growth rates, with those exhibiting
lower growth rates considered more favorable. This approach allows for a proactive as-
sessment of an algorithm’s efficiency before practical implementation, taking into account
the algorithm’s characteristics and its anticipated performance across varying input sizes.

5 Practical Example
Consider two computers: Computer A, which is faster and executes 10 billion instructions
per second, and Computer B, which is slower, running at 10 million instructions per
second. Both computers are tasked with sorting an array of 10 million numbers.

5.1 Algorithm Analysis


ˆ Computer A (Faster):

– Running time growth: O(n2 ).


– The programmer writes an inefficient algorithm requiring 2n2 instructions to
sort n numbers.

ˆ Computer B (Slower):

– Running time growth: O(n log n).


– The programmer writes an efficient algorithm requiring 50n log n instructions.

5.2 Running Time Comparison


ˆ Computer A: 2 × (107 )2 = 2 × 1014 instructions.
14
Time required: 2×10
1010
= 20, 000 seconds (more than 5.5 hours).

ˆ Computer B: 50 × 107 log(107 ) ≈ 50 × 107 × 16.1 = 8.05 × 109 instructions.


9
Time required: 8.05×10
107
≈ 805 seconds (under 15 minutes).

3
6 Conclusion
This example highlights the critical importance of choosing algorithms with slower rates
of growth. Despite the faster processing power of Computer A, the inefficiency of its
algorithm resulted in a significantly longer execution time compared to Computer B.
This underscores the profound impact that algorithm selection has on overall system
performance and efficiency.

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