Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views2 pages

Tutorial 6

The document includes a C program that calculates the sum of an array of five integers. It also explains Big O, Omega, and Theta notations for algorithm complexity, detailing their meanings and examples. Additionally, it describes various algorithm representation methods including pseudocode, flowcharts, structured English, and Nassi-Shneiderman diagrams.

Uploaded by

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

Tutorial 6

The document includes a C program that calculates the sum of an array of five integers. It also explains Big O, Omega, and Theta notations for algorithm complexity, detailing their meanings and examples. Additionally, it describes various algorithm representation methods including pseudocode, flowcharts, structured English, and Nassi-Shneiderman diagrams.

Uploaded by

ryuk07u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tutorial 6

#include <stdio.h>

int main() {
// Declare an array of five elements
int arr[5] = {10, 20, 30, 40, 50};
int sum = 0; // Variable to store the sum

// Calculate the sum of all array elements


for (int i = 0; i < 5; i++) {
sum += arr[i];
}

// Display the sum


printf("Sum of all array elements: %d\n", sum);

return 0;
}

Tutorial no.9

1)

Big O Notation (O-notation): - Indicates the worst-case complexity of an algorithm.

- This represents the maximum amount of resources consumed.

- O(n^2) represents quadratic temporal complexity.

The Omega Notation (Ω-notation) describes an algorithm's best-case complexity.

- Indicates the lower limit on resources used.

Ω(n) represents linear temporal complexity.


Theta Notation (Θ-notation): - Describes upper and lower boundaries, providing a
precise approximation.

- Represents the exact rate at which resources grow.

Example: Θ(n) represents linear temporal complexity.

2)

English-like Pseudocode:
● Describes algorithmic steps using plain language.
● Example: "Repeat until the list is sorted: Compare adjacent elements. If they're
in the wrong order, swap them."

Flowchart:
● Uses symbols like rectangles and diamonds to represent steps and decisions.
● Example: Rectangles show actions, diamonds represent decisions, and
arrows indicate the flow of steps.

Structured English:
● A bit like simplified C code using words.
● Example: "If temperature is over 30 degrees Celsius, say 'It's hot.' Otherwise,
say 'It's cool.'"

Nassi-Shneiderman Diagrams:
● Similar to flowcharts but with specific symbols.
● Example: Boxes for actions, diamonds for decisions, and arrows to show
order.

You might also like