Вы находитесь на странице: 1из 2

NAME : VICTOR MEYO MANDELA

REG NO. : F17/30406/2015.


Thursday October 8 2015.
ASSIGNMENT.
QUESTION 1.
Since Big (O) is concerned with the worst case scenario (upper bound), O(kn) = O(n), the constant
k is neglected because it becomes irrelevant.
QUESTION 2.
For the Big O O(n), the function grows linearly whereas for the Big Omega, it executes once when
two values are provided.
QUESTION 3.
Big O is a constant that shows how fast a function grows or declines.
The constants are neglected because they become insignificant as n grows larger hence we take
the highest value of n.
QUESTION 4.
The running time of the algorithm is at least meaningless means that it brings about the best case
scenario whereas the Big O notation brings about the worst case scenario.
QUESTION 5.
N

N^2

N^3

2^N

Nlog2N

log2N

RtN

16

64

16

16

16

256

4096

65536

64

256

64

4096

262144 1.8447E+1
9

384

4096

256

65536

16777216 1.1579E+7
7

2048

16

65536

512

262144

13427728 NaN

4608

9 16rt2

QUESTION 6.
a). F3 <=F2 <= F1 <= F4.
F2 has the smallest growth rate while F4 has the highest growth rate.
b). In the increasing order of complexity is as follows : F1, F4, F3, F2.
F2 has the fastest growth rate while F1 has the slowest growth rate.
QUESTION 7.
The complexity of the algorithm is O(nsq)

262144

QUESTION 8.
The algorithm of the complexity is O(log n).
QUESTION 9.
#include<stdio.h>
#include<stdbool.h>
#define SIZE 8
bool search(int needle, int haystack [], int size)
{
for (int = 0; i < size ; i++)
{
if( needle == haystack [i])
return true;
}
int main (void)
{
int numbers { SIZE } = [ 4, 8, 15, 16, 23, 42, 50, 108 ]
printf(Enter the number to search);
int n;
scanf(%d, &n);
if ( search(n, numbers, SIZE))
printf(The number has been found\n);
else
printf(The number has NOT been found\n);
return 0;

Вам также может понравиться