-
Notifications
You must be signed in to change notification settings - Fork 0
/
STATS.H
103 lines (89 loc) · 2.81 KB
/
STATS.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/******************************************************************************
* Copyright (C) 2017 by Alex Fosdick - University of Colorado
*
* Redistribution, modification or use of this software in source or binary
* forms is permitted as long as the files maintain this copyright. Users are
* permitted to modify this and use it to learn about the field of embedded
* software. Alex Fosdick and the University of Colorado are not liable for any
* misuse of this material.
*
*****************************************************************************/
/**
* @file stats.h
* @brief Header file for stats.c. Performs statistical analysis on a dataset.
*
*
*
* @author DINESHKUMAR
* @date JULY 8, 2021
*
*/
#ifndef __STATS_H__
#define __STATS_H__
/**
* @brief A function that prints the statistics of an array including minimum,
* maximum, mean, and median.
*
* @param array The array containing the dataset of unsigned chars
* @param length The length of the array
*
* @return NULL
*/
void print_statistics(unsigned char array[], unsigned int length);
/**
* @brief Given an array of data and a length, prints the array to the screen
*
* @param array An array of unsigned chars
* @param length The length of the array
*
* @return NULL
*/
void print_array(unsigned char array[], unsigned int length);
/**
* @brief Given an array of data and a length, returns the median value
*
* @param array An array of unsigned chars
* @param length The length of the array
*
* @return median The median of the array
*/
unsigned char find_median(unsigned char array[], unsigned int length);
/**
* @brief Given an array of data and a length, returns the min value
*
* @param array An array of unsigned chars
* @param length The length of the array
*
* @return median The min of the array
*/
unsigned char find_min(unsigned char array[], unsigned int length);
/**
* @brief Given an array of data and a length, returns the max value
*
* @param array An array of unsigned chars
* @param length The length of the array
*
* @return median The max of the array
*/
unsigned char find_max(unsigned char array[], unsigned int length);
/**
* @brief Given an array of data and a length, returns the mean value
*
* @param array An array of unsigned chars
* @param length The length of the array
*
* @return median The mean of the array
*/
unsigned char find_mean(unsigned char array[], unsigned int length);
/**
* @brief Sorts the array using selection sort
*
* Selection sort is used despite its O(n^2) runtime because it has a
* spatial complexity of O(1) and that is more important in this
* embedded system context (limited memory).
*
* @param array An array of unsigned chars
* @param length The length of the array
*/
void sort_array(unsigned char array[], unsigned int length);
#endif /* __STATS_H__ */