Module1 Part1
Module1 Part1
1/39 © SCTripathi
Assessment Breakdown
2/39 © SCTripathi
Introduction to Computations
3/39 © SCTripathi
Algorithm
Definition:
A step-by-step procedure or formula for solving a problem.
Complexity:
Measures how the runtime or space requirements of an algorithm grow
with the size of the input (e.g., time complexity and space complexity).
Examples:
Sorting algorithms (like quicksort and mergesort), search algorithms
(like binary search), and graph algorithms (like Dijkstra’s shortest
path).
4/39 © SCTripathi
Algorithm
For a good algorithm, it must satisfy the following characteristics or
properties:
Input:
There must be a finite number of inputs for the algorithm.
Output:
There must be some output produced as a result of execution of the
algorithm.
Definiteness:
There must be a definite sequence of operations for transformation of
input into output.
Effectiveness:
Every step of the algorithm should be basic and essential.
Finiteness:
The transformation of input to output must be achieved in finite steps,
i.e. the algorithm must stop, eventually! Stopping may mean that it
should produce the expected output or a response that no solution is
possible.
5/39 © SCTripathi
Algorithm
6/39 © SCTripathi
What is a Flowchart?
7/39 © SCTripathi
Flowchart Symbols
Start/End
Process
Decision
Input/Output
8/39 © SCTripathi
Creating a Flowchart
9/39 © SCTripathi
Example Algorithm
10/39 © SCTripathi
Python Code to find the largest number in a list
1
2 def find_l ar g es t _ nu m ber ( numbers ):
3 # Step 2: Initialize max to the first number
4 if not numbers : # Handle the case where the list is empty
5 return None
6
7 max_num = numbers [0]
8 # Step 3: For each number in the list
9 for number in numbers :
10 # Step 3.1: If number > max , update max
11 if number > max_num :
12 max_num = number
13 # Step 4: Output max
14 return max_num
15 # Example usage
16 numbers = [3 , 5 , 2 , 9 , 1]
17 largest_number = fi n d_largest_number ( numbers )
18 print ( " The largest number in the list is : " , largest_number )
11/39 © SCTripathi
Algorithm vs. Flowchart
12/39 © SCTripathi
Algorithm
13/39 © SCTripathi
Algorithm
14/39 © SCTripathi
Algorithm
15/39 © SCTripathi
Algorithm
16/39 © SCTripathi
Building Blocks of Algorithm
18/39 © SCTripathi
What is a Procedure?
19/39 © SCTripathi
Algorithmic Procedure
20/39 © SCTripathi
Subroutines and Functions
21/39 © SCTripathi
Procedures in Programming Languages
22/39 © SCTripathi
Procedure vs. Process
23/39 © SCTripathi
Summary
24/39 © SCTripathi
What is Recursion?
25/39 © SCTripathi
Factorial Definition:
Base Case: 0! = 1 and 1! = 1
Recursive Case: n! = n × (n − 1)!
Python Implementation:
1
2 def factorial ( n ):
3 if n == 0 or n == 1:
4 return 1
5 else :
6 return n * factorial ( n - 1)
26/39 © SCTripathi
Advantages and Disadvantages
Advantages:
Simplicity: Often more elegant and easier to understand.
Reduction in Code Complexity: Can reduce the amount of code
compared to iterative solutions.
Disadvantages:
Memory Usage: Each recursive call adds to the call stack, leading to
higher memory consumption.
Performance: Recursive calls can be less efficient due to overhead
from multiple function calls.
27/39 © SCTripathi
Fibonacci Definition:
Base Case: fib(0) = 0 and fib(1) = 1
Recursive Case: fib(n) = fib(n − 1) + fib(n − 2)
Python Implementation:
1
2 def fibonacci ( n ):
3 if n == 0:
4 return 0
5 elif n == 1:
6 return 1
7 else :
8 return fibonacci ( n - 1) + fibonacci ( n - 2)
28/39 © SCTripathi
Complexity of Algorithms
Time Complexity: The running time of an algorithm for producing the
output is also known as time complexity. The running time of an
algorithm is represented as a function T (n), where n is the input size. In
this presentation, we will examine a specific case where the running time is
given by a linear function.
Consider an algorithm with a running time T (n) expressed as:
T (n) = cn (1)
where c is a constant.
In this linear model:
T (n) denotes the running time of the algorithm.
n represents the size of the input.
c is a constant factor that characterizes the time required per unit of
input size.
29/39 © SCTripathi
The unit of T (n) is unspecified and depends on the context (e.g.,
milliseconds, seconds). The linear dependency means:
If the input size n doubles, the running time T (n) also doubles.
This straightforward relationship makes it easier to predict the
algorithm’s performance as the input size increases.
30/39 © SCTripathi
Data Structures
Introduction:
What are data structures and why they matter?
Types of Data Structures:
Arrays, Linked Lists, Stacks, Queues, Trees, Graphs
Applications in Engineering:
Practical examples where data structures are used
31/39 © SCTripathi
Numerical Methods
Introduction:
Importance of numerical methods in engineering computations
Common Methods:
Root finding, Integration, Differentiation, Solving ODEs
Tools:
MATLAB, Python libraries (e.g., NumPy, SciPy)
32/39 © SCTripathi
Floating-Point Arithmetic
Representation:
How real numbers are represented in computers
Precision and Errors:
Rounding errors and precision limits
IEEE Standard for Floating-Point Arithmetic:
Basic understanding of IEEE 754 standard
33/39 © SCTripathi
Computer Architecture Basics
34/39 © SCTripathi
Introduction
35/39 © SCTripathi
Basic Components
36/39 © SCTripathi
Data Path and Control
Data Path:
The path data follows within the CPU
Includes buses, registers, and ALU
Control Unit:
Directs operations of the CPU
Decodes instructions and generates control signals
37/39 © SCTripathi
Memory Hierarchy
Registers:
Small, fast storage within the CPU
Cache:
Fast memory closer to the CPU
Stores frequently accessed data
Main Memory (RAM):
Larger but slower than cache
Secondary Storage:
Non-volatile storage like SSDs and HDDs
38/39 © SCTripathi
Conclusion
39/39 © SCTripathi