Write algorithm using pseudocode and flowchart that uses while loops to perform the
following steps:
i. Prompt the user to input two integers: firstNum and secondNum note that firstNum
must be less than secondNum.
ii. Output all odd numbers between firstNum and secondNum.
iii. Output the sum of all even numbers between firstNum and secondNum.
iv. Output the numbers and their squares between firstNum and secondNum.
v. Output the sum of the square of the odd numbers between firstNum and secondNum.
b. Redo Exercise (a) using for loops.
c. Redo Exercise (a) using do. . .while loops.
The population of a town A is less than the population of town B. However, the population of
town A is growing faster than the population of town B. Write algorithm using pseudocode and
flowchart that prompts the user to enter the population and growth rate of each town. The
algorithm outputs after how many years the population of town A will be greater than or equal to
the population of town B and the populations of both the towns at that time. (A sample input is:
Population of town A = 5000, growth rate of town A = 4%, population of town B = 8000, and
growth rate of town B =2%)
a. Write algorithm using pseudocode and flowchart that uses while loops to perform the
following steps:
i. Prompt the user to input two integers: firstNum and secondNum note that firstNum
must be less than secondNum.
ii. Output all odd numbers between firstNum and secondNum.
iii. Output the sum of all even numbers between firstNum and secondNum.
iv. Output the numbers and their squares between firstNum and secondNum.
v. Output the sum of the square of the odd numbers between firstNum and secondNum.
b. Redo Exercise (a) using for loops.
c. Redo Exercise (a) using do. . .while loops.
Write the algorithms to display the Fibonacci series and the factorial value for a given number using Pseudo code.
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.
Five Processes P1, P2, P3, P4 and P5, arrive at almost the same time. They have estimated running times of M, 6, 2, N, and 8 respectively. Their priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. For each of the following scheduling algorithms, determine the average process turnaround time by ignoring process switching overhead.
(a) Round-robin (with time quantum 2 unit)
(b) Priority scheduling (using both preemptive and non-preemptive scheduling)
(c) First come First serve (run in order mentioned above)
(d) Shortest job first (using both preemptive and non-preemptive scheduling).
Use Master Theorem to estimate the running times for divide-and-conquer
algorithms satisfying the following estimates: (a) T(n)≤4T(n/2)+O(n)
(b) T(n)≤T(2n/3)+O(n)
(c) T(n)≤8T(n/2)+O(n3)
Describe, what is going on when we run the Mergesort algorithm for the array
[11, 31, 13, 23, 17, 37, 19, 29]
Merge two sorted arrays shown below
[11, 31, 35, 43, 61, 79] and [12, 14, 15, 37, 41, 73]
1. Design an algorithm and the corresponding flowchart for finding the sum of
the numbers 2, 4, 6, 8, …, n
2. Using flowcharts, write an algorithm to read 100 numbers and then display the
sum.
3. Write an algorithm to read two numbers then display the largest.
4. Write an algorithm to read two numbers then display the smallest
5. Write an algorithm to read three numbers then display the largest.
6. Write an algorithm to read 100 numbers then display the largest.