Q1. Determine the growth function and order of the following code fragment:
for (int count=0; count < n; count++)
{
for (int count2=0; count2 < n; count2=count2*2)
{
System.out.println(count, count2);
}
}
Q2. What is the order of the following growth functions?
a. 10n2 + 100n + 1000
b. 10n3 – 7
c. 2n + 100n3
d. n2 log n
Q3. Arrange the growth functions of Q4 in ascending order of efficiency for n=10 and again for n = 1,000,000.
Q1. Write the code necessary to find the largest element in an unsorted array of integers. What is the time complexity of this algorithm?
Q2. Determine the growth function and order of the following code fragment:
for (int count=0; count < n; count++)
{
for (int count2=0; count2 < n; count2=count2+2)
{
System.out.println(count, count2);
}
}
DEI Manufacturing company plans to give a year-end bonus to each of their employees. Draw a flowchart which will compute the bonus of an employee. Consider the following conditions: If the employee`s monthly salary is less than P2000.00, the bonus is 50% of the salary; for employees with salary greater than P2000.00, the bonus is P1500.00. Print the name and the corresponding bonus for each employee. Write the equivalent algorithm. (Pseudocoding and Flowcharting)
Define what an algorithm is and outline the characteristics of a good algorithm. Write the algorithms to display the Fibonacci series and the factorial value for a given number using Pseudo code. Determine the steps involved in the process of writing and executing a program.
Take a sample number and dry run the above two algorithms. Show the outputs at the end of each iteration and the final output. Examine what Big-O notation is and explain its role in evaluating efficiencies of algorithms. Write the Python program code for the above two algorithms and critically evaluate their efficiencies using Big-O notation.