Vlaaadu10/Window-join
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
# **This document contains the explanations for the implementation of topic 1 of the Programming and Programming Languages I course. You can also find the description of the Calculators and the functions used in the three problems. In addition, the implementations are modular, each problem uses separate functions for the main operations.** 314CA Stefan Alexandru Vladut ## **Problem 1: window joining** The problem involves processing a stream of pairs (timestamp, value) and performing a join between all received pairs that fall within the window time interval with respect to the most recently arrived element. Collection and storage: all valid pairs (t,x) until the combination 0,0 appears are read and stored in a pair struct. To perform the join, the elements are traversed using two for-loops, and each current element pair[i] is compared with all previous elements pair[j] (where j<i). A pair is valid if *pair[i].t-pair[j].t<=window* For each valid pair, the CMMDC and CMMMC are calculated and the result is stored, along with the times(min_t, max_t) in another result struct. Finally, it is sorted and displayed. **Implemented functions** `cmmdc`(greatest common divisor) - Parameters: unsigned long long a, unsigned long long b - Returns all unsigned long long data types (the cmmdc between a and b) - How it works: implements Euclid's algorithm iteratively. `cmmmc`(least common multiple) - Parameters: unsigned long long a, unsigned long long b - Returns all data types unsigned long long (the cmmmc between a and b) - Mode of operation: calculates the CMMMC relation: - cmmmc(a,b) = a/cmmdc(a,b) * b - Note! I rearranged the relation so that division is performed before multiplication in order to prevent memory overflow. `sort` - Parameters: result rez[](result vector), int k(number of results) - The function does not expect anything to be returned, being of type void - Mode of operation: Sorts the result vector, using the Bubble Sort algorithm. The primary criterion is by min_t(ascending), secondary by max_t(ascending).