C code for this: The Monk is trying to explain to its users that even a single
Fantastic news! We've Found the answer you've been seeking!
Question:
C code for this:
Transcribed Image Text:
The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task. There are N processes to be completed by you, the chosen one, since you're Monk's favorite student. All the processes have a unique number assigned to them from 1 to N. Now, you are given two things: • The calling order in which all the processes are called. • The ideal order in which all the processes should have been executed. Now, let us demonstrate this by an example. Let's say that there are 3 processes, the calling order of the processes is: 3 -2-1. The ideal order is: 1-3-2, i.e., process number 3 will only be executed after process number 1 has been completed; process number 2 will only be executed after process number 3 has been executed. • Iteration #1: Since the ideal order has process #1 to be executed firstly, the calling ordered is changed, i.e., the first element has to be pushed to the last place. Changing the position of the element takes 1 unit of time. The new calling order is: 2 -1 - 3. Time taken in step #1: 1. • Iteration #2: Since the ideal order has process #1 to be executed firstly, the calling ordered has to be changed again, i.e., the first element has to be pushed to the last place. The new calling order is: 1 - 3- 2. Time taken in step # 2: 1. Iteration #3: Since the first element of the calling order is same as the ideal order, that process will be executed. And it will be thus popped out. Time taken in step #3: 1. • Iteration #4: Since the new first element of the calling order is same as the ideal order, that process will be executed. Time taken in step #4: 1. Iteration #5: Since the last element of the calling order is same as the ideal order, that process will be executed. Time taken in step #5: 1. The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task. There are N processes to be completed by you, the chosen one, since you're Monk's favorite student. All the processes have a unique number assigned to them from 1 to N. Now, you are given two things: • The calling order in which all the processes are called. • The ideal order in which all the processes should have been executed. Now, let us demonstrate this by an example. Let's say that there are 3 processes, the calling order of the processes is: 3 -2-1. The ideal order is: 1-3-2, i.e., process number 3 will only be executed after process number 1 has been completed; process number 2 will only be executed after process number 3 has been executed. • Iteration #1: Since the ideal order has process #1 to be executed firstly, the calling ordered is changed, i.e., the first element has to be pushed to the last place. Changing the position of the element takes 1 unit of time. The new calling order is: 2 -1 - 3. Time taken in step #1: 1. • Iteration #2: Since the ideal order has process #1 to be executed firstly, the calling ordered has to be changed again, i.e., the first element has to be pushed to the last place. The new calling order is: 1 - 3- 2. Time taken in step # 2: 1. Iteration #3: Since the first element of the calling order is same as the ideal order, that process will be executed. And it will be thus popped out. Time taken in step #3: 1. • Iteration #4: Since the new first element of the calling order is same as the ideal order, that process will be executed. Time taken in step #4: 1. Iteration #5: Since the last element of the calling order is same as the ideal order, that process will be executed. Time taken in step #5: 1.
Expert Answer:
Related Book For
Cost Management Measuring, Monitoring and Motivating Performance
ISBN: 978-1119185697
3rd Canadian edition
Authors: Leslie G. Eldenburg, Susan K. Wolcott, Liang-Hsuan Chen, Gail Cook
Posted Date:
Students also viewed these algorithms questions
-
Write a C code for this question. Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the...
-
C code for this You and your friend are on a treasure hunt and you decided to split your search. After some systematic searching based on techniques you've learned in ES242, you find a box of gold...
-
Please write a C Code for this problem. Please do not submit C++ or Python Code.
-
Use normal job-order costing to calculate the balance in the ending Work-in-Process account and the Cost of Goods Sold account on 31 December 20X3 after any necessary adjustment(s). Sweet Memories...
-
Explain how an organization determines whether a hedge is sufficiently effective to justify hedge accounting?
-
1. Using a spreadsheet, compare the hedging alternatives for the Thai baht with a scenario under which Blades remains unhedged. Do you think Blades should hedge or remain unhedged? If Blades should...
-
Let \(X\) denote the time between detections of a particle with a Geiger counter and assume that \(X\) has an exponential distribution with \(E(X)=1.4\) minutes. The probability that we detect a...
-
The following table shows the transactions experienced by J G Gutter Works (JGGW) during Year 7. The table contains missing data which are labeled with alphabetic characters (a) through (j). Assume...
-
Blossom Company must perform an impairment test on its equipment. The equipment will produce the following cash flows: Year 1, $37,000; Year 2, $40,000; Year 3, $64,500. The discount rate is 12%....
-
The management of Zigby Manufacturing prepared the following balance sheet for March 31. Cash Accounts receivable Raw materials inventory Assets ZIGBY MANUFACTURING Balance Sheet March 31 Liabilities...
-
https://www.youtube.com/watch?v=tblmslbnnFc Develop a checklist of the 6 you should not do
-
Use the Second Derivative Test to find and classify the critical points of the function f(x,y)=6xy-x2y-xy. Find the maximum and minimum values of the function f(x) = res on the curve C, where C is...
-
A tech company updates phones and wants to make an aggregate production plan. Each worker on average can update 15 phones per hour. Each worker will receive a wage of 20 an hour and will work for 10...
-
The partner has requested that you draft a letter to Jerry which explains how Jerry should have recorded the refrigerated van. The partner has asked that you refer to the going concern assumption,...
-
The table below gives the distances in kilometres between seven localities, A, B, C, D, E, F, G. Find a minimum weight spanning tree joining these localities and give its weight. A B C D EFG A B C D...
-
How much is the present value of loan as of December 31, 2025? How much is the lifetime expected credit losses of loan during 2022? How much is the 12-month expected credit losses of loan during...
-
Vaughn Manufacturing had 829000 shares of common stock issued and outstanding at December 31, 2017. On July 1, 2018, an additional 41600 shares of common stock were issued for cash. Vaughn also had...
-
For Problem estimate the change in y for the given change in x. y = f(x), f'(12) = 30, x increases from 12 to 12.2
-
The sales forecast for ceramic pottery handcrafted by Fergie Industries follows. Beginning inventory for the year is expected to be 1,000 ceramic bowls, and the production manager prefers to maintain...
-
Georgette Rheingold owns and operates a fruit smoothie manufacturing operation, Nutri-smoothie. She processes fruit and adds it to yogurt to produce fruit smoothies, the main product. She sells the...
-
The following is the cost data per unit for KopyKat Companys single product, the Kat: Prime cost ................................................. $ 13 Variable manufacturing overhead .................
-
Find one solution for each of the difference equations below: (a) \(y(n)+2 y(n-1)+y(n-2)=0, y(0)=1\) and \(y(1)=0\) (b) \(y(n)+y(n-1)+2 y(n-2)=0, y(-1)=1\) and \(y(0)=1\).
-
We define the even and odd parts of a sequence \(x(n), \mathcal{E}\{x(n)\}\) and \(\mathcal{O}\{x(n)\}\) respectively, as \[\begin{aligned}\mathcal{E}\{x(n)\} & =\frac{x(n)+x(-n)}{2}...
-
Find the general solution for the difference equation in Example 1.9 when \(a=b\). Example 1.9. Solve the difference equation y(n) + ay(n 2) = b" sin(n)u(n) assuming that ab and y(n) = 0, for n < 0....
Study smarter with the SolutionInn App