0% found this document useful (0 votes)
7 views5 pages

Program Analysis

The document outlines the steps involved in program development, including problem definition, algorithm design, flowchart creation, coding, debugging, testing, and documentation. It also explains the characteristics of algorithms, the advantages of flowcharts, and provides examples of sorting algorithms and binary search. Additionally, it discusses modular vs. structured programming and presents algorithms for various problems.

Uploaded by

tayshetedipali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Program Analysis

The document outlines the steps involved in program development, including problem definition, algorithm design, flowchart creation, coding, debugging, testing, and documentation. It also explains the characteristics of algorithms, the advantages of flowcharts, and provides examples of sorting algorithms and binary search. Additionally, it discusses modular vs. structured programming and presents algorithms for various problems.

Uploaded by

tayshetedipali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Paper-I

Lesson No.2 Program Analysis


1. Steps Involved in Program Development
Program development consists of multiple phases to ensure that a program is correctly
designed and executed. The steps include:

Step 1: Problem Definition

 Understanding the problem that needs to be solved.


 Identifying inputs, outputs, and constraints.

Step 2: Algorithm Design

 Creating a sequence of well-defined steps to solve the problem.


 Ensuring the logic is correct and efficient.

Step 3: Flowchart Creation

 A graphical representation of the algorithm.


 Uses standard symbols to visualize logic.

Step 4: Coding

 Writing the program in a specific programming language.


 Using best practices for readability and efficiency.

Step 5: Compilation and Debugging

 Compilation: Converting code into machine language.


 Debugging: Identifying and fixing errors in code.

Step 6: Testing and Execution

 Checking if the program works as expected.


 Running different test cases to verify correctness.

Step 7: Documentation and Maintenance

 Documenting the code for future reference.


 Updating the program as needed.

Two Types of documentations: User Documentation and Developers Documentation


2. Symbols Used in Flowcharts
Flowcharts use various symbols to represent different operations in a program:

Symbol Purpose Representation


Oval Start/End of a program Start / Stop
Input/Output operations, read input data and Display output Input / Output
Parallelogram
data
Rectangle Process or computation or Formula Process

Diamond Decision-making (Yes/No)(to check Condition ) Decision

Arrow Flow/direction of execution Flowline

3. Algorithm Definition and Example


Definition:

An algorithm is a step-by-step procedure to solve a specific problem.

Example Algorithm:

Finding the Sum of Two Numbers

1. Start
2. Input two numbers (A, B)
3. Sum = A + B
4. Print the sum
5. Stop

4. Characteristics of an Algorithm
An algorithm must have the following characteristics:

1. Well-Defined Inputs and Outputs


o Should take input and produce an output.
2. Definiteness
o Each step should be clear and unambiguous.
3. Finiteness
o Must terminate after a fixed number of steps.
4. Feasibility
o Should be practically executable.
5. Independence
o Can be implemented in any programming language.

5. Flowchart Definition and Advantages


Definition:

A flowchart is a graphical representation of an algorithm.

Advantages of Flowcharts:

1. Easy to Understand – Visual representation helps in understanding logic.


2. Simplifies Debugging – Helps in finding logical errors.
3. Effective Communication – Easier to explain to others.
4. Better Documentation – Serves as a reference for future development.

6. Sorting and Pseudocode


Sorting:

Sorting is the process of arranging elements in ascending or descending order.

 Types of Sorting Algorithms:


o Bubble Sort
o Selection Sort
o Merge Sort
o Quick Sort

Pseudocode:

Pseudocode is a simplified, language-independent way to write an algorithm.

Example of pseudocode for finding the largest number:

BEGIN
Input A, B, C
If A > B AND A > C THEN
Print "A is the largest"
Else If B > A AND B > C THEN
Print "B is the largest"
Else
Print "C is the largest"
ENDIF
END
7. Modular vs. Structured Programming
Aspect Modular Programming Structured Programming
Divides program into separate Uses logical structures like loops and
Definition
modules conditions
Code Reusability High Moderate
Complexity
Easier to manage Harder for large programs
Handling

8. Sorting and Its Uses


Sorting is used in:

 Databases (e.g., arranging records)


 Search Algorithms (e.g., binary search requires sorted data)
 Data Analysis (e.g., sorting numbers for statistical calculations)

9. Binary Search Explanation


Binary search is an efficient algorithm used to find an element in a sorted array.

Steps:

1. Divide the data structure into two equal parts and find the middle element.
2. Start with the middle element.
3. If the target value is equal to the middle element, return its position.
4. If the target is smaller, search the left half.
5. If the target is larger, search the right half.
6. Repeat until the element is found or the array is exhausted.
11. Algorithms & Flowcharts for Given Problems
(a) Find the Minimum of Three Numbers

Algorithm:

1. Start
2. Input three numbers (A, B, C)
3. If A < B and A < C, Minimum = A
4. Else If B < A and B < C, Minimum = B
5. Else, Minimum = C
6. Print Minimum
7. Stop

(b) Check if a Number is Odd or Even

Algorithm:

1. Start
2. Input a number (N)
3. If numner N is completely divisible by 2 then , Print "Even"
4. Else, Print "Odd"
5. Stop

(c) Sum of Odd Numbers from 1 to 100

Algorithm:

1. Start
2. Initialize sum = 0
3. Loop from i=1 to 100 with step 2 (only odd numbers)
4. Add each odd number to sum sum=sum+i
5. Print sum
6. Stop

You might also like