Lecture 1 - Introduction
Lecture 1 - Introduction
algorithms
BCT2202 (4CU’s)
By Mrs. Barbara A. Mwijukye
What are Algorithms About?
• Solving problems in everyday life
• Travel from Bolzano to Munich; Cook Spaghetti, eggs; Register for a
Bachelor thesis at FUB
• For all these problems, there are
• Instructions, Recipes, Procedures,
• Which describe a complex operation in terms of
• elementary operations (“beat well …”); control structures and conditions
(“… until fluffy”)
Algorithms
• Problems involving numbers, strings, mathematical objects:
• For two numbers, determine their sum, product, …
• For two numbers, find their greatest common divisor
• For a sequence of strings, find an alphabetically sorted permutation of the
sequence
• For two arithmetic expressions, find out if they are equivalent
• On a map, find for a given house the closest bus stop
• We call instructions, recipes, for such problems algorithms
Overall Picture
• Using a computer to help solve problems.
• Precisely specify the problem
• Designing programs
• Architecture
• Algorithm
• Writing programs
• Verifying (testing) programs
Overall Picture
• Data Structure and Algorithm Design Goals
• Correctness
• Efficiency
• Implementation Goals
• Robustness
• Reusability
• Adaptability
This course is not about:
• Programming languages
• Computer architecture
• Software architecture
• SW design and implementation principles
• We will only touch upon the theory of complexity and
computability.
Data Structures and Algorithms
• Data structure
• Organization of data to solve the problem at hand
• Algorithm
• Outline, the essence of a computational procedure, step-by-step
instructions
• Program
• Implementation of an algorithm in some programming language
Data Structure Example Applications
• How does Google quickly find web pages that contain a search term?
• What’s the fastest way to broadcast a message to a network of
computers?
• How can a subsequence of DNA be quickly found within the genome?
• How does your operating system track which memory (disk or RAM)
is free?
What is a Data Structure Anyway?
• It’s an agreement about:
• How to store a collection of objects in memory,
• What operations we can perform on that data,
• The algorithms for those operations, and
• How time and space efficient those algorithms are.
• Ex. vector in C++:
• Stores objects sequentially in memory; Can access, change, insert or delete
objects; Algorithms for insert & delete will shift items as needed
Algorithmic problem
• Data structuring is the best way of organizing the data, associated
with that problem.
• An algorithmic problem is essentially, that you have a certain
specifications of an input and specify what the output should be
like.
Specification of
Specification
? output as a
of input
function of input
Algorithmic problem
• There is an infinite number of possible input instances satisfying
the specification.
• For example:
• A sorted, non-decreasing sequence of natural numbers, on nonzero, finite length:
• 1, 20, 908, 909, 100000, 1000000000
• 3
• Above are the two examples of input, which meets the
specification and I have not given any output specification.
What is an instance?