Data structure
Data structure
Data Structure:
- **Editor**: Used for writing and editing the source code of a program. It
provides a text interface to write code in a programming language.
### 3. Heuristics:
This method doesn’t guarantee the optimal solution but provides a fast and
reasonable approximation.
- **O(log n)**: Binary Search – The algorithm divides the input space in half
with each iteration.
- **O(n log n)**: Merge Sort – The algorithm recursively splits the list and
then merges the sorted halves.
These complexities give an idea of how the algorithm’s runtime scales with
the size of the input.
### 1. Sieve of Eratosthenes to find all prime numbers less than 100,000:
```c
#include <stdio.h>
#include <stdbool.h>
Int main() {
Int n = 100000;
Bool isPrime[n+1];
isPrime[i] = true;
// Sieve of Eratosthenes
If (isPrime[i]) {
isPrime[j] = false;
If (isPrime[i])
Printf(“%d “, i);
Return 0;
```
### 2. Advantages of Developing a Program as a Collection of Independent
Functions:
```c
#include <stdio.h>
#include <stdbool.h>
Bool isPrime(int n) {
If (n <= 1)
Return false;
If (n % I == 0)
Return false;
Return true;
}
Int main() {
Int num;
Scanf(“%d”, &num);
If (isPrime(num))
Else
Return 0;
```
```c
#include <stdio.h>
Struct Complex {
Double real;
Double imag;
};
Return result;
Return result;
Return result;
}
Int main() {
// Perform addition
// Perform subtraction
// Perform multiplication
Return 0;
```
This code defines a structure `Complex` and provides functions for adding,
subtracting, and multiplying complex numbers.