Entries by admin

count prime: b. Write a function is_prime() which determi…

count prime: b. Write a function is_prime() which determines if a number is prime. The function has one integer parameter. The function returns true if the input parameter is prime and false otherwise.A number a is prime if and only if (a mod b ≠ 0) for b = 2, 3, …, (a − 1) […]

Counting sort: implementation and analysis Counting sort …

Counting sort: implementation and analysis Counting sort works by first counting the number of records with each key value (assume the input key values are integers), and then uses this information to place the records in order (see a pseudo-code below). Implementation: Write an implementation of counting sort. For simplicity, assume the input is an […]

Counts digits in different bases

Counts digits in different bases // For instance 232223 has 4 2’s in base 10, 15 has 4 1’s in base 2 #include using namespace std; //This should return the number of 1’s in the binary representation //of the input number (in decimal) int CountBinOnes(int dec_number) { //base case //recursive case } //This should return […]