Data Mining - Computer Science Assume we have two \'prime number detectors\' cal
ID: 665455 • Letter: D
Question
Data Mining - Computer Science
Assume we have two 'prime number detectors' called A and B.
detector A uses the following equation: z = 2*x**2 + 29
detector B uses the following equation: z = x**4 + 29*x**2 + 101
test both of these detectors by providing the integers x from 1 to 100 and seeing if the resulting numbers are prime or not. To check if a number is prime or not, just look on any prime number table
Tell me the recall and precision of both detectors A and B.
(1) What is recall and precision for each detector (A and B) based on the input of the first 100 integers
(2) For Detector A, what is the smallest prime (if any) that was MISSED by the detector
(3) For Detector B, what was the smallest number output that was NOT A PRIME (a false alarm)
(4) source codes of the detectors
Explanation / Answer
(2) For Detector A, what is the smallest prime (if any) that was MISSED by the detector
Missed Prime No: 2 (smallest prime)
class PrimeNumbers
{
static void Main(string[] args)
{
List<int> list = new List<int>();
for (int x = 1; x < 100; x++)
{
int z = 2 * x *2 + 29;
if (z % 2 == 1)
{
list.Add(z);
}
}
int[] terms = list.ToArray();
foreach (int i in terms)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
(3) For Detector B, what was the smallest number output that was NOT A PRIME (a false alarm)
225 ( which is not a prime)
class PrimeNumberB
{
static void Main(string[] args)
{
List<int> list = new List<int>();
for (int x = 1; x < 100; x++)
{
int z = x * 4 + 29 * x * 2 + 101;
if (z % 2 == 1)
{
list.Add(z);
}
}
int[] terms = list.ToArray();
foreach (int i in terms)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.