Sujal2 1
Sujal2 1
Worksheet2
Aim: An IoT device collects temperature reading from varioussensors in real time these reading
needs to be sorted efficiently to monitor temperature changes, trigger alerts when necessary.
choose an appropriate sorting technique for scenario.
Requirements (Hardware/Software):
Online code compileror Visual Studio
Code/ Output:Code:
#include <iostream>
using namespace std;
int i = 0, j = 0, k = left;
while (i < n1 && j < n2) {
if (leftArray[i] <= rightArray[j]) {
readings[k] = leftArray[i];
i++;
} else {
readings[k] = rightArray[j];
j++;
}
k++;
}
int main() {
int size;
cout << "Enter the number of temperature readings: ";
cin >> size;
int temperatureReadings[size];
cout << "Enter the temperature readings: ";
return 0;
}
Output: