Unit 4 Part C
Unit 4 Part C
Problem Statement
Write a program to sort n numbers using a sorting algorithm. Also, represent the program
logic with:
• A Flowchart
• A Flow Graph
➤ Algorithm:
• Simple to implement
python
CopyEdit
def bubble_sort(arr):
n = len(arr)
for i in range(n):
return arr
# Example usage
sorted_numbers = bubble_sort(numbers)
4. Flowchart Explanation
Structure:
Node 1: Start
Node 2: Input
Node 5: If condition
Node 6: Swap
Node 8: Output
Node 9: End
6. Cyclomatic Complexity
➤ Definition:
➤ Formula:
V(G) = E - N + 2P
Where:
E = Number of Edges
N = Number of Nodes
➤ In our case:
E = 10
N=7
P=1
V(G) = 10 - 7 + 2*1 = 5
8. Conclusion