Explore BrainMass
Share

String function evaluation and algorithm analysis

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Hello,
I need the answer of below questions please:
1)
Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g is a function that returns the concatenation of the two strings given as its input. If x is the string hrwa, what is returned by g(f(x),x)? Explain your answer and result

2)
Use big-O notation to classify the traditional grade school algorithms for addition and multiplication. That is, if asked to add two numbers each having N digits, how many individual additions must be performed? If asked to multiply two N-digit numbers, how many individual multiplications are required?

Thanks,

© BrainMass Inc. brainmass.com March 21, 2019, 6:15 pm ad1c9bdddf
https://brainmass.com/computer-science/algorithms/string-function-evaluation-and-algorithm-analysis-250906

Solution Preview

Since the function f() returns the result of a string it is passed, f("hrwa") will be "awrh". Also, since the function g returns the concatenation of the two inputs, g("awrh","hrwa") will be "awrhhrwa". These two functions can be put together so ...

Solution Summary

This solution is a two-part solution. The first part shows how two string functions operate and how they can be composed. This is shown with an example and explanation. The second part provides a detailed explanation of the algorithmic complexity of the addition and multiplication algorithms.

$2.19