CF0810 17102024 034051pm
CF0810 17102024 034051pm
Topdown
flowcharts approach of
algorithms
Problem
Solving
Techniques
Efficiency of
Program
an
verification
algorithm
Efficiency of an algorithm-
• How fast the program produces the correct result
• It depends upon the two factors
• Time Complexity-running time of the program
• Space Complexity-memory taken by the program
• Space Complexity defines the amount of memory required by the
algorithm for the execution and generation of the output.
• Time Complexity refers to the amount of computer time required by an
algorithm for its execution.
• It includes both compile and runtime.
11/16/2024 Computing Fundamentals and C++ Programming 15
Analysis of algorithm-
• Determines the amount of resources such as time and memory(space) required for the
execution.
• Algorithm analysis provides theoretical estimates required by an algorithm to solve a
problem.
Asymptotic Analysis
• Performance of the algorithm based on the input size
• Relation between the running time and the input size
• Time and Space factor
Worst, Average and Best Cases
• Divided into three different cases
Best Case(Ω) − minimum time taken to execute the program.
Average Case(θ) − average time taken to execute the program.
Worst Case(O) − maximum time taken to execute the program.
Asymptotic Notations
• Asymptotic notations are mathematical tools to represent the time complexity of algorithms for asymptotic
analysis.
Ο (Big O) Notation
Ω (Omega)Notation
θ (Theta) Notation
11/16/2024 Computing Fundamentals and C++ Programming 16
Flowchart
Termina
sInput /
Processing
l
Output
Flow Lines
Decision
• Terminal Connectors
– Start or stop
• Processing
– Operations like add subtract etc.
• Flow ines
– Flow / sequence of operation.
• Connectors
– Required if the chart spreads over multiple
pages
Flowchart-
• Pictorial representation of the algorithm depicting the flow of
the various steps.
• Visualize the working of an algorithm
=0 =1 =2 =3 =4 = . . .
5
Multi – way
Branching
Example
(1)
• Find the % mark secured by a student, given all
marks
Start
Read mark
details
Add marks of all
subjects giving
total
Percentage =
total /
totalSubject
Print
percentage
Stop
Example
(2)
• Find the % mark secured by 50 students, given
all marks
Start
Counter = 1
Print
Read mark details percentage
of one student
Add 1 to
Add marks of all Counter
subjects giving
total NO
Is Counter > 50
Percentage =
total / yes
Stop
totalSubject
Flowchart
Guidelines
• Chart the main logic, then incorporate
detail
• Do not chart everything in the
chart. A consistent level of detail to
be maintained
• Names used should be prob.
Specific
• Crossing of flow lines may be
avoided
• Connectors may be leveled
Flowchart
advantages
• Better communication
• Proper program
documentation
• Efficient coding
• Systematic debugging
• Systematic testing
Flowchart
disadvantages
• Very time consuming and laborious to
draw
• Difficult to incorporate changes
• No standards available
determining the amount of detail
to be produced
Pseudoco
• deis written in an
Program logic
ordinary natural language
• Also called “Program Design
Language” (PDL)
• Basic Logic (control) Structure
– Sequence
• Sequence of execution
– Selection
• Decision (branching)
– Iteration
• Repetition (loop)
Pseudocode
• example
Counter =0
• Read first student record
• DO WHILE counter < 50
– Calculate totalMark
– percentage = totalMark /
totalSubject
– Print percentage
– Counter = counter + 1
– IF counter < 49
• Read next student record
– END IF
• ENDDO