SlideShare a Scribd company logo
DATA STRUCTURES AND
ALGORITHMSI (DSA010)
PREPARED BY BLASIUS K PINIAS
INTRODUCTION TO ALGORITHMS
• At the end of this Chapter, the student will student will be able to:
• Define an algorithm;
• Give examples of algorithms from daily life processes;
• Demonstrate an understanding of how algorithms are constructed;
• Define a program; and
• Identify Relationship between Algorithms and Programs.
• Demonstrate an understanding of Pseudo-code
DEFINITION OF AN ALGORITHM
• What is an algorithm?
• An algorithm can be defined as a sequence of instructions or a set of rules that are
followed to complete a task.
NB: This task can be anything, so long as you can give clear instructions for it.
In other words, an algorithm can also be defined as a step by step solution to a problem.
CHARACTERISTICS:
1. An algorithm should be finite
2. An algorithm should be unambiguous
3. An algorithm must always include all the finer details about a problem that should be solved. (Do
not omit any despite the fact that it may sound trivial)
4. Every algorithm can be transformed into an executable program
5. An algorithm may be written by one person but may in future be used by any other person whom
might not necessarily know how it was derived
6. When an algorithm is executed, it should always give a correct solution to a problem irrespective of
the changing data set as long as the data set belong to a specified data type that from which the
input data should be taken
7. An algorithm is often presented using either pseudo-code; flow charts or Nassi Schneiderman
Diagrams
WHY LEARN ALGORITHMS?
• Data Structures and Algorithms course is designed to prepare you for the
programming course. It is designed to give an understanding of how to make
a computer do anything.To make a computer do anything, you have to write a
computer program. To write a computer program, you have to tell the
computer, step by step, exactly what you want it to do. The computer then
"executes" the program, following each step mechanically, to accomplish the
end goal.
Figure .3 c) Executable file, which results
from the process of compiling
Algorithm to Source Code
DEFINE
• Source code –a text listing of commands to be compiled or assembled into an
executable computer program.
• A compiler is a computer program (or a set of programs) that transforms source
code written in a programming language (the source language) into another
computer language (the target language), with the latter often having a binary
form known as object code.
• A program is a set of instructions derived from a specific algorithm that is written in
a specific programming language.
RELATIONSHIP BETWEEN ALGORITHMS
AND PROGRAMS
• A program is an algorithm that is translated into a set of instructions that the CPU
can understand. A program is executed by a computer in order to give a solution to
a problem for which it was designed to solve. Algorithms are only turned into
programs once they are validated.
PSEUDO-CODE
• Pseudo-code (or Pseudo code) is an informal high-level description of the operating
principle of a computer program or other algorithm.
• The word Pseudo means false.
• Pseudo code is a standard way of representing algorithms.
PSEUDO-CODE
• Problem: Given any two whole numbers, find their sum.
• Algorithm:
. DATA TYPES AND DATA STRUCTURES
• A data type is a set of values that have common characteristics (they belong to the
same domain).
• Data structure is a particular way of organizing data in a computer so that it can
be used efficiently.
. DATA TYPES AND DATA STRUCTURES
Examples of data types:
1. Integers: Set of negative and positive whole numbers
2. Real: A set of all possible numbers including decimal/fractional numbers, also
referred to as floating point numbers.
3. Characters: A set of all possible symbols, including letters of the alphabet. All
symbols found on a computer keyboard including numbers and special signs are
characters.
4. String: Is a group of characters (2 or more) that are used to represent one value
5. Boolean: A set of two values that represent either a true or false situation.
.USER DEFINED DATA STRUCTURES:
can represent more than one value at a time.
Examples of user defined data types:
1. Array: is a data type that is derived from a specific simple data type (same
domain) but can store more than one value at time.
2. File/Record/Structure: A user defined composite data type that groups together
different data values from one or more domains into a single data type.
3. Union: A data type that can only keep one value from a set of specified possible
data types.
. VARIABLES, CONSTANTS AND LITERALS :
Variables and Constants
1. Variable Is a name given to a specific memory location that is reserved to
store/keep a value from a specific data type.
NB: The values kept in a variable may change during program execution.
1. Constant Is a name given to a specific memory location that is reserved to
store/keep a value that cannot change during program execution.
. DECLARING A VARIABLE
Is the process of reserving and naming the memory space that will be used to keep
values from a specific data type during program execution.
How are variables declared
Data_Type Variable_Name
For example, a variable X that keeps an integer value will be declared as
Integer X
. DECLARING A CONSTANTS
How to Declare Constants
1. Constant_name Value
E.g. Rate 2.5 1.
Typed constants are declared as follows:
Data_type Constant_name value
E.g.String institutionName “NSEA”
LITERALS
Literals : is A value written exactly as it's meant to be interpreted. In contrast, a
variable is a name that can represent different values during the execution of the
program. And a constant is a name that represents the same value throughout a
program.
But a literal is not a name -- it is the value itself.
For example, in an expression:
Integer x = 20
The value 20 is a literal, while x is a variable
NAMING CONVENTION FOR VARIABLES AND CONSTANTS
1. Variable or constant name should only be one word.
2. If two or more words are to be used as a variable or constant name, they should be
joined with an underscore e.g. Integer student_age
3. No variable or constant name should start with a number but with a letter from the
alphabet.
4. No two different variables have the same name (same spelling)
5. Some special symbols, e.g. +, -, ‘,/, *, should not be used in a variable name
6. Variable and constant names may consist of one or more letters of the alphabet
7. A number may only be used as part of a variable name only if it written after a letter(s)
of the alphabet.
PROBLEM SOLVING AND BASIC COMPUTER
OPERATIONS
• Seven Basic Steps that should be followed when solving a problem
namely:
Understand/Identify the problem
Outline aSolution
Develop the ouline into an algorithm
Test/Validate your algorithm
Transform your algorithm into a program using a specific programming language
Run/Execute your program
Install, document and maintain the program
PROBLEM SOLVING AND BASIC COMPUTER
OPERATIONS
• Seven Basic Steps that should be followed when solving a problem
At this stage the problem can be divided into three separate components
namely: Three basic stages that are followed by a computer when solving a
problem: 1. Input 2. Processes 3. Output
the inputs
the outputs, and the
processingsteps to produce the required outputs
1. UNDERSTAND/IDENTIFY THE
PROBLEM
STEPS IN ALGORITHM DEVELOPMENT CONTINUE...
• The solution outline developed in step 2 is then expanded into an
algorithm: a set of precise steps that describes exactly the tasks to be
performed and the order in which they are to be carried out. We will be
using pseudo code (a form of structured English) to represent the solution
algorithm. Flowcharts and Nassi-Schneidermann diagrams will also be
introduced as graphical methods of representation
3. DEVELOP THE OULINE INTO AN
ALGORITHM
STEPS IN ALGORITHM DEVELOPMENT
CONTINUE….
• One of the most important steps in the development of a program, often
referred to as desk checking. The main purpose of this step is to identify
major errors early, so that they may easily be corrected. It involves
walking with test data through the logic of the algorithm exactly as a
computer would, keeping track of major variables on a sheet of paper.
4. TEST/VALIDATE YOUR ALGORITHM
STEPS IN ALGORITHM DEVELOPMENT
CONTINUE….
• Only after all design considerations have been met in the previous four
steps, and after you tested whether your algorithm is really working you
should actually start coding the program in your chosen programming
language.
5. TRANSFORM YOUR ALGORITHM INTO A PROGRAM
USING A SPECIFIC PROGRAMMING LANGUAGE
STEPS IN ALGORITHM DEVELOPMENT
CONTINUE….
• This step uses a program compiler / interpreter and programmer-
designed test data to machine test the code for syntax and
syntax/compilation errors (those detected at compile time) and run-
time/logical errors (those detected at run time). At this stage there are
hopefully no logical errors anymore, because they ideally should have
been eradicated in step 4.
6. RUN/EXECUTE YOUR PROGRAM
STEPS IN ALGORITHM DEVELOPMENT
CONTINUE….
• Documentation involves both external documentation (such as hierarchy charts,
the solution algorithm, and the test data results), and internal documentation that
may have been coded in the program. Program maintenance refers to changes
which may need to be made to the program throughout its life cycle.
7. INSTALL, DOCUMENT AND MAINTAIN THE
PROGRAM

More Related Content

PDF
lect 1-ds algo(final)_2.pdf
PPTX
8.unit-1-fds-2022-23.pptx
PPTX
Algorithms and Data Structures
PPTX
lecture1-220221114413Algorithims and data structures.pptx
PPTX
lecture1-2202211144eeeee24444444413.pptx
PPTX
Data Structure and Algorithms –Introduction.pptx
PPTX
Design and analysis of algorithms Module-I.pptx
PPT
AOA Week 01.ppt
lect 1-ds algo(final)_2.pdf
8.unit-1-fds-2022-23.pptx
Algorithms and Data Structures
lecture1-220221114413Algorithims and data structures.pptx
lecture1-2202211144eeeee24444444413.pptx
Data Structure and Algorithms –Introduction.pptx
Design and analysis of algorithms Module-I.pptx
AOA Week 01.ppt

Similar to DATAND ALGORITHMSI (DSA010)_LESSON 1.pdf (20)

PPT
Data Structures- Part1 overview and review
PDF
Unit 1-problem solving with algorithm
PPTX
GLOBAL INSTITUTE OF MANAGEMENT AND TECHNOLOGY.pptx
PPT
Chapter 5( programming) answer
PPTX
Design and Analysis of Algorithm ppt for unit one
PPTX
Intro to Data Structure & Algorithms
PPTX
Unit 1 Introduction Part 3.pptx
PDF
Algorithms notes 2 tutorials duniya
PPT
lec_4_data_structures_and_algorithm_analysis.ppt
PPT
lec_4_data_structures_and_algorithm_analysis.ppt
PPTX
Data structure and algorithm
PPTX
Basic syntax : Algorithm,Flow chart
DOC
Program concep sequential statements
PPTX
Data Structures_Introduction to algorithms.pptx
PDF
Data structures and algorithms Module-1.pdf
PPTX
Lecture 1 and 2
DOCX
Lecture1
PPT
Introduction to Programming
PPT
Intro to DSAA.ppt
PDF
ProgFund_Lecture7_Programming_Algorithm.pdf
Data Structures- Part1 overview and review
Unit 1-problem solving with algorithm
GLOBAL INSTITUTE OF MANAGEMENT AND TECHNOLOGY.pptx
Chapter 5( programming) answer
Design and Analysis of Algorithm ppt for unit one
Intro to Data Structure & Algorithms
Unit 1 Introduction Part 3.pptx
Algorithms notes 2 tutorials duniya
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
Data structure and algorithm
Basic syntax : Algorithm,Flow chart
Program concep sequential statements
Data Structures_Introduction to algorithms.pptx
Data structures and algorithms Module-1.pdf
Lecture 1 and 2
Lecture1
Introduction to Programming
Intro to DSAA.ppt
ProgFund_Lecture7_Programming_Algorithm.pdf
Ad

More from blasiuspinias (9)

PDF
DATA STRUCTURES AND ALGORITHMSI (DSA010)_LESSON 1.pdf
PPTX
wCIHc9AaI fgn gfgjhgf bxn ffbb fv .pptx
PPTX
05fghsdgsgrg dxgs sdgfs sdgfd sdgs.pptx
PPTX
Data Structures Unit 1 bnmxc xgfh (1).pptx
PPTX
Programming II - Introductio bncvfh dgdgn.pptx
PPTX
Week 1fah xzvfsgds sdfasdfsfg dsaewag.pptx
PDF
DATA STRUCTURES AND ALGORITHMSI (DSA010).pdf
PDF
DPG Class Reps Information 2gffd5 v1.pdf
PDF
Repetition Control Structure_lsson 3.pdf
DATA STRUCTURES AND ALGORITHMSI (DSA010)_LESSON 1.pdf
wCIHc9AaI fgn gfgjhgf bxn ffbb fv .pptx
05fghsdgsgrg dxgs sdgfs sdgfd sdgs.pptx
Data Structures Unit 1 bnmxc xgfh (1).pptx
Programming II - Introductio bncvfh dgdgn.pptx
Week 1fah xzvfsgds sdfasdfsfg dsaewag.pptx
DATA STRUCTURES AND ALGORITHMSI (DSA010).pdf
DPG Class Reps Information 2gffd5 v1.pdf
Repetition Control Structure_lsson 3.pdf
Ad

Recently uploaded (20)

PDF
How to Get Business Funding for Small Business Fast
PDF
Tata consultancy services case study shri Sharda college, basrur
PDF
Building a Smart Pet Ecosystem: A Full Introduction to Zhejiang Beijing Techn...
PDF
Cours de Système d'information about ERP.pdf
PDF
NewBase 12 August 2025 Energy News issue - 1812 by Khaled Al Awadi_compresse...
PDF
TyAnn Osborn: A Visionary Leader Shaping Corporate Workforce Dynamics
PDF
How to Get Approval for Business Funding
PPT
Lecture 3344;;,,(,(((((((((((((((((((((((
PDF
Module 3 - Functions of the Supervisor - Part 1 - Student Resource (1).pdf
PDF
Technical Architecture - Chainsys dataZap
PPTX
sales presentation، Training Overview.pptx
PDF
IFRS Notes in your pocket for study all the time
PDF
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
PDF
NISM Series V-A MFD Workbook v December 2024.khhhjtgvwevoypdnew one must use ...
PDF
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
PDF
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
PPTX
Slide gioi thieu VietinBank Quy 2 - 2025
PDF
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PPTX
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax
How to Get Business Funding for Small Business Fast
Tata consultancy services case study shri Sharda college, basrur
Building a Smart Pet Ecosystem: A Full Introduction to Zhejiang Beijing Techn...
Cours de Système d'information about ERP.pdf
NewBase 12 August 2025 Energy News issue - 1812 by Khaled Al Awadi_compresse...
TyAnn Osborn: A Visionary Leader Shaping Corporate Workforce Dynamics
How to Get Approval for Business Funding
Lecture 3344;;,,(,(((((((((((((((((((((((
Module 3 - Functions of the Supervisor - Part 1 - Student Resource (1).pdf
Technical Architecture - Chainsys dataZap
sales presentation، Training Overview.pptx
IFRS Notes in your pocket for study all the time
THE COMPLETE GUIDE TO BUILDING PASSIVE INCOME ONLINE
NISM Series V-A MFD Workbook v December 2024.khhhjtgvwevoypdnew one must use ...
BsN 7th Sem Course GridNNNNNNNN CCN.pdf
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
Slide gioi thieu VietinBank Quy 2 - 2025
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax

DATAND ALGORITHMSI (DSA010)_LESSON 1.pdf

  • 1. DATA STRUCTURES AND ALGORITHMSI (DSA010) PREPARED BY BLASIUS K PINIAS
  • 2. INTRODUCTION TO ALGORITHMS • At the end of this Chapter, the student will student will be able to: • Define an algorithm; • Give examples of algorithms from daily life processes; • Demonstrate an understanding of how algorithms are constructed; • Define a program; and • Identify Relationship between Algorithms and Programs. • Demonstrate an understanding of Pseudo-code
  • 3. DEFINITION OF AN ALGORITHM • What is an algorithm? • An algorithm can be defined as a sequence of instructions or a set of rules that are followed to complete a task. NB: This task can be anything, so long as you can give clear instructions for it. In other words, an algorithm can also be defined as a step by step solution to a problem.
  • 4. CHARACTERISTICS: 1. An algorithm should be finite 2. An algorithm should be unambiguous 3. An algorithm must always include all the finer details about a problem that should be solved. (Do not omit any despite the fact that it may sound trivial) 4. Every algorithm can be transformed into an executable program 5. An algorithm may be written by one person but may in future be used by any other person whom might not necessarily know how it was derived 6. When an algorithm is executed, it should always give a correct solution to a problem irrespective of the changing data set as long as the data set belong to a specified data type that from which the input data should be taken 7. An algorithm is often presented using either pseudo-code; flow charts or Nassi Schneiderman Diagrams
  • 5. WHY LEARN ALGORITHMS? • Data Structures and Algorithms course is designed to prepare you for the programming course. It is designed to give an understanding of how to make a computer do anything.To make a computer do anything, you have to write a computer program. To write a computer program, you have to tell the computer, step by step, exactly what you want it to do. The computer then "executes" the program, following each step mechanically, to accomplish the end goal.
  • 6. Figure .3 c) Executable file, which results from the process of compiling Algorithm to Source Code
  • 7. DEFINE • Source code –a text listing of commands to be compiled or assembled into an executable computer program. • A compiler is a computer program (or a set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language), with the latter often having a binary form known as object code. • A program is a set of instructions derived from a specific algorithm that is written in a specific programming language.
  • 8. RELATIONSHIP BETWEEN ALGORITHMS AND PROGRAMS • A program is an algorithm that is translated into a set of instructions that the CPU can understand. A program is executed by a computer in order to give a solution to a problem for which it was designed to solve. Algorithms are only turned into programs once they are validated.
  • 9. PSEUDO-CODE • Pseudo-code (or Pseudo code) is an informal high-level description of the operating principle of a computer program or other algorithm. • The word Pseudo means false. • Pseudo code is a standard way of representing algorithms.
  • 10. PSEUDO-CODE • Problem: Given any two whole numbers, find their sum. • Algorithm:
  • 11. . DATA TYPES AND DATA STRUCTURES • A data type is a set of values that have common characteristics (they belong to the same domain). • Data structure is a particular way of organizing data in a computer so that it can be used efficiently.
  • 12. . DATA TYPES AND DATA STRUCTURES Examples of data types: 1. Integers: Set of negative and positive whole numbers 2. Real: A set of all possible numbers including decimal/fractional numbers, also referred to as floating point numbers. 3. Characters: A set of all possible symbols, including letters of the alphabet. All symbols found on a computer keyboard including numbers and special signs are characters. 4. String: Is a group of characters (2 or more) that are used to represent one value 5. Boolean: A set of two values that represent either a true or false situation.
  • 13. .USER DEFINED DATA STRUCTURES: can represent more than one value at a time. Examples of user defined data types: 1. Array: is a data type that is derived from a specific simple data type (same domain) but can store more than one value at time. 2. File/Record/Structure: A user defined composite data type that groups together different data values from one or more domains into a single data type. 3. Union: A data type that can only keep one value from a set of specified possible data types.
  • 14. . VARIABLES, CONSTANTS AND LITERALS : Variables and Constants 1. Variable Is a name given to a specific memory location that is reserved to store/keep a value from a specific data type. NB: The values kept in a variable may change during program execution. 1. Constant Is a name given to a specific memory location that is reserved to store/keep a value that cannot change during program execution.
  • 15. . DECLARING A VARIABLE Is the process of reserving and naming the memory space that will be used to keep values from a specific data type during program execution. How are variables declared Data_Type Variable_Name For example, a variable X that keeps an integer value will be declared as Integer X
  • 16. . DECLARING A CONSTANTS How to Declare Constants 1. Constant_name Value E.g. Rate 2.5 1. Typed constants are declared as follows: Data_type Constant_name value E.g.String institutionName “NSEA”
  • 17. LITERALS Literals : is A value written exactly as it's meant to be interpreted. In contrast, a variable is a name that can represent different values during the execution of the program. And a constant is a name that represents the same value throughout a program. But a literal is not a name -- it is the value itself. For example, in an expression: Integer x = 20 The value 20 is a literal, while x is a variable
  • 18. NAMING CONVENTION FOR VARIABLES AND CONSTANTS 1. Variable or constant name should only be one word. 2. If two or more words are to be used as a variable or constant name, they should be joined with an underscore e.g. Integer student_age 3. No variable or constant name should start with a number but with a letter from the alphabet. 4. No two different variables have the same name (same spelling) 5. Some special symbols, e.g. +, -, ‘,/, *, should not be used in a variable name 6. Variable and constant names may consist of one or more letters of the alphabet 7. A number may only be used as part of a variable name only if it written after a letter(s) of the alphabet.
  • 19. PROBLEM SOLVING AND BASIC COMPUTER OPERATIONS • Seven Basic Steps that should be followed when solving a problem namely: Understand/Identify the problem Outline aSolution Develop the ouline into an algorithm Test/Validate your algorithm Transform your algorithm into a program using a specific programming language Run/Execute your program Install, document and maintain the program
  • 20. PROBLEM SOLVING AND BASIC COMPUTER OPERATIONS • Seven Basic Steps that should be followed when solving a problem At this stage the problem can be divided into three separate components namely: Three basic stages that are followed by a computer when solving a problem: 1. Input 2. Processes 3. Output the inputs the outputs, and the processingsteps to produce the required outputs 1. UNDERSTAND/IDENTIFY THE PROBLEM
  • 21. STEPS IN ALGORITHM DEVELOPMENT CONTINUE... • The solution outline developed in step 2 is then expanded into an algorithm: a set of precise steps that describes exactly the tasks to be performed and the order in which they are to be carried out. We will be using pseudo code (a form of structured English) to represent the solution algorithm. Flowcharts and Nassi-Schneidermann diagrams will also be introduced as graphical methods of representation 3. DEVELOP THE OULINE INTO AN ALGORITHM
  • 22. STEPS IN ALGORITHM DEVELOPMENT CONTINUE…. • One of the most important steps in the development of a program, often referred to as desk checking. The main purpose of this step is to identify major errors early, so that they may easily be corrected. It involves walking with test data through the logic of the algorithm exactly as a computer would, keeping track of major variables on a sheet of paper. 4. TEST/VALIDATE YOUR ALGORITHM
  • 23. STEPS IN ALGORITHM DEVELOPMENT CONTINUE…. • Only after all design considerations have been met in the previous four steps, and after you tested whether your algorithm is really working you should actually start coding the program in your chosen programming language. 5. TRANSFORM YOUR ALGORITHM INTO A PROGRAM USING A SPECIFIC PROGRAMMING LANGUAGE
  • 24. STEPS IN ALGORITHM DEVELOPMENT CONTINUE…. • This step uses a program compiler / interpreter and programmer- designed test data to machine test the code for syntax and syntax/compilation errors (those detected at compile time) and run- time/logical errors (those detected at run time). At this stage there are hopefully no logical errors anymore, because they ideally should have been eradicated in step 4. 6. RUN/EXECUTE YOUR PROGRAM
  • 25. STEPS IN ALGORITHM DEVELOPMENT CONTINUE…. • Documentation involves both external documentation (such as hierarchy charts, the solution algorithm, and the test data results), and internal documentation that may have been coded in the program. Program maintenance refers to changes which may need to be made to the program throughout its life cycle. 7. INSTALL, DOCUMENT AND MAINTAIN THE PROGRAM