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...
-
Describe the process of periodontal disease.
-
Which of the following business gifts are fully deductible? a. A gift to a client costing $35 b. A gift to an employee, for 10 years of continued service, costing $250 c. A gift to a client and her...
-
Let x represent the number of registers in use at a departmental store. Determine whether the random variable x is discrete or continuous. Explain.
-
Haifa Instruments, an Israeli producer of portable kidney dialysis units and other medical products, develops an 8-month aggregate plan. Demand and capacity (in units) are forecast as shown in the...
-
Titleist Inc produces two types of golf balls for the retail consumer. They want to know which golf ball produces the greatest profit and they want to maintain at least $1.50 of profit per golf ball,...
-
During a baseball practice session, the cutoff man A executes a throw to the third baseman B. If the initial speed of the baseball is v 0 = 130 ft/sec, what launch angle is best if the ball is to...
-
Express the compression C in the hydraulic cylinder of the car hoist in terms of the angle ?. The mass of the hoist is negligible compared with the mass m of the vehicle. 26 -L-
-
How does the playwright navigate the intricacies of internal conflict within the protagonist's psyche, employing dramatic irony and soliloquy to underscore the tension between duty and desire?
-
You the director of a center with 4 classrooms; each has one lead teacher and one assistant at all times. Several of the teachers and assistants are veteran teachers of at least 10 years; two are...
-
What relationships are now being regulated as a result of underfunded pension plans?
-
The Course Project consists of 12 Requirements for you to complete. There are eight worksheets in the workbook you will need to complete. A list of March transactions A Chart of Accounts reference...
-
For the following list of topics, think about how you could take the same topic and adjust it for each of the different general purposes (inform, persuade, and entertain). Write out the specific...
-
3. Suppose that factory A produces 12 tables and 6 chairs per hour, while factory B produces 8 tables and 4 chairs per hour. How many hours should each factory work to produce 48 tables and 24...
-
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 .................
-
How can you identify a real option in a decision tree?
-
In 2022, Costco Wholesale Corporation had a market capitalization of \($238\) billion, debt of \($6.5\) billion, cash of \($12\) billion, and EBIT of about \($8\) billion. If Costco were to increase...
-
In what circumstances does the real option add value?
Study smarter with the SolutionInn App