DSA Chapter 0
DSA Chapter 0
3/18/2024 Outline
Course Information
2
Class Room: -
Lecture Room Lab Room
311 510
3/18/2024
Course Description
3
3/18/2024
Teaching Strategy
6
Demonstration
Student presentations
Group discussions, and
3/18/2024
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
3/18/2024
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.
3/18/2024
Prerequisite skill and knowledge
10
3/18/2024
Laboratory Class
11
3/18/2024
Pre-lab
12
3/18/2024
In-lab
13
3/18/2024
Post-lab
14
3/18/2024
15
3/18/2024
17 3/18/2024
18 3/18/2024
Characteristics of a Data Structure
19
3/18/2024
Why Data Structure?
20
3/18/2024
ALGORITHM
21
3/18/2024
22
3/18/2024
How to Write an Algorithm?
23
3/18/2024
Characteristics of an Algorithm
24
3/18/2024
Example
26
step 6 − print c
step 7 − STOP
3/18/2024
27
step 3 − c ← a + b
step 4 − display c
step 5 − STOP
3/18/2024
28
3/18/2024
Algorithm Analysis
29
3/18/2024
Algorithm Complexity
30
3/18/2024
Introduction to flowchart and pseudo-code
31
3/18/2024
Flowcharts
32
3/18/2024
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.
3/18/2024
34 3/18/2024
35
3/18/2024
36
3/18/2024
Exercise 1:
37
3/18/2024
38 3/18/2024
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.
Next we will add both the numbers and save the
result in the variable sum i.e., sum = 10 + 20.
Finally, we will print the value stored in the variable
sum.
3/18/2024
40 3/18/2024
Exercise 3:
41
3/18/2024
42 3/18/2024
PSEUDO-CODE
43
3/18/2024
44
3/18/2024
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
3/18/2024
47
3/18/2024
48
3/18/2024
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
3/18/2024
50
3/18/2024
51
3/18/2024
52
3/18/2024
53
3/18/2024
54
3/18/2024
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
3/18/2024
Exercise: Flowchart & Pseudo-code
56
Questions?
3/18/2024
58
Thank You
3/18/2024