DSA Chapter 0
DSA Chapter 0
6/4/2022 Outline
Course Information
2
Class Room: -
Lecture Room Lab Room
311 510
6/4/2022
Course Description
3
6/4/2022
Teaching Strategy
6
Demonstration
Student presentations
Group discussions, and
6/4/2022
Assessment Criteria
7
Assessment Forms % of credit Given Submission
allotted week week
Lecture 100%
Hardware
Desktop Computer or Laptop
Software
Code Blocks C++ compiler or other C++ compilers
6/4/2022
References
9
Textbook
“Data Structures and Algorithms in C++” by A. Drozdek
(Brooks/Cole, 2013)
Other
“Data Structures and Algorithms with Object-Oriented
Design Patterns in C++” by B. R. Preiss.
Any related Data Structures and Algorithms books.
6/4/2022
Prerequisite skill and knowledge
10
6/4/2022
Laboratory Class
11
6/4/2022
Pre-lab
12
6/4/2022
In-lab
13
6/4/2022
Post-lab
14
6/4/2022
15
6/4/2022
17 6/4/2022
18 6/4/2022
Characteristics of a Data Structure
19
6/4/2022
Why Data Structure?
20
6/4/2022
ALGORITHM
21
6/4/2022
22
6/4/2022
How to Write an Algorithm?
23
6/4/2022
Characteristics of an Algorithm
24
6/4/2022
Example
26
step 6 − print c
step 7 − STOP
6/4/2022
27
step 3 − c ← a + b
step 4 − display c
step 5 − STOP
6/4/2022
28
6/4/2022
Algorithm Analysis
29
6/4/2022
Algorithm Complexity
30
6/4/2022
Introduction to flowchart and pseudo-code
31
6/4/2022
Flowcharts
32
6/4/2022
33
Flowcharting Symbols
There are 6 basic symbols commonly used in
flowcharting of programming language:
Terminal,Process, input/output, Decision, Connector and
Predefined Process.
This is not a complete list of all the possible
flowcharting symbols, it is the ones used most often in
the structure of programming language.
6/4/2022
34 6/4/2022
35
6/4/2022
36
6/4/2022
Exercise 1:
37
6/4/2022
38 6/4/2022
Exercise:2
39
Add 10 and 20
To solve this problem we will take a variable sum and
set it to zero.
Then we will take the two numbers 10 and 20 as input.
6/4/2022
40 6/4/2022
Exercise 3:
41
6/4/2022
42 6/4/2022
PSEUDO-CODE
43
6/4/2022
44
6/4/2022
46
Example:1
Suppose you are required to design an algorithm for
finding the average of six numbers, and the sum of the
numbers is given.
The pseudo-code will be as follows
Start
Get the sum
Average = sum / 6
Output the average
Stop
6/4/2022
47
6/4/2022
48
6/4/2022
49
Example 2:
The following shows how the selection control structure is
used in a program where a user chooses the options for
multiplying the numbers or adding them or subtracting.
Use variables: choice, of the type character; ans, number1,
number2, of type integer
display “choose one of the following”
display “m for multiply”
display “a for add”
display “s for subtract”
accept choice
display “input two numbers you want to use”
accept number1, number2
6/4/2022
50
6/4/2022
51
6/4/2022
52
6/4/2022
53
6/4/2022
54
6/4/2022
55
Example 3:
A program segment to print out each character typed
at a keyboard until the character ‘q’ is entered.
WHILE letter <> ‘q’
ACCEPT letter
DISPLAY “The character you typed is”, letter
ENDWHILE
6/4/2022
Exercise: Flowchart & Pseudo-code
56
Questions?
6/4/2022
58
Thank You
6/4/2022