Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

From a set of array elements, find

the number of occurrences of

each element present in the given

array.


Write C program to find the

maximum number from the nxm

array.


Design a C program to find the

largest element of an array.


Design a C program to sort a one dimensional array in ascending order.


Suppose you need to solve a problem that is comprised of N independent tasks, each of which takes the same time to complete. You want to execute these in parallel using p processing units. However, N is not a multiple of p.


It is suggested that the N tasks can be distributed over the p processing units as follows: p−1 processing units are allocated ⌈N/p⌉ tasks, where ⌈N/p⌉ is N/p rounded up to the nearest integer, and the final processing unit then takes all remaining tasks. What problem or problems can you see with this suggestion?


It is now proposed to allocate the tasks to processes in a ‘round-robin’ manner, cycling through all processing units, allocating one task to each in turn before moving onto the next unit. Provide some pseudo-code for a loop that implements this allocation of tasks.





Task 2: Find median in a 2D array

Write a function median_2d()that computes the median for a 2D numeric array (matrix). The inputs to the function are a pointer to the start of the array, and its dimensions (rows and cols). Your function should not modify the contents of the original matrix! The function prototype is given below.

float median_2d(float * ptr_array, int rows, int cols);

Domain knowledge:

The median is the middle number in a sorted, ascending or descending, list of numbers and can be more descriptive of that data set than the average.

If there is an odd amount of numbers, the median value is the number that is in the middle, with the same amount of numbers below and above.

If there is an even amount of numbers in the list, the middle pair must be determined, added together, and divided by two to find the median value.


Hint: In memory a 2D array is stored just like a 1D array.



Task 1: Convert a number string to number

Write a C function str_to_float() that takes a numeric string as input and converts it to a floating point number. The function should return the floating point number by reference. If the conversion is successful, the function should return 0, and -1 otherwise (e.g. the string does not contain a valid number). The prototype of the function is given below

int str_to_float(char * str, float * number);


Task 2: Test for Palindrome (recursive)

Write a function isPalindrom() that takes as input a C string and its size, and recursively tests whether it is a palindrome (a word or phrase which remains the same if reversed. e.g. radar, kayak etc). The function returns the Boolean data type which is either true or false. The required header “stdbool.h” has already been included in tasks.h.

The function has the following prototype:

bool isPalindrom(char * ptr_array, int size);

The recursive definition of a palindrome is:

The string is a palindrome if it has only one character or is an empty string.

The string is a palindrome if the first and the last characters are the same and the characters in between form a palindrome


Task 1: Reverse a character string.

Write a function called str_rev() that takes a pointer to a string as input and reverses the string in-place (this change should be reflected in the original string that was passed to the function, not to a copy of the string). No library functions for string reversal should be used. The function should also return a pointer to the reversed string.

Function prototype is given below:

char * str_rev(char * str);


Let A and B be the two matrix. The size of matrix A is m and size of matrix B. Then, find subtraction of C, is a A and B is defined as C(ij) = A(ij) - B(ij).


LATEST TUTORIALS
APPROVED BY CLIENTS