Question: Question: A team must optimize context switching between processes. There are n segments where a thread is assigned to each segment. The maximum stack size

Question: A team must optimize context switching between processes. There are n segments where a thread is assigned to each segment. The maximum stack size of a thread assigned in the ith segment is denoted by "threadSizeli],"for all 1sis n.For any high-priority process, some stack size of the segments must be increased. A segment /is said to be special when
A team must optimize context switching between processes. There are n segments where a thread is assigned to each segment. The maximum stack size of a thread assigned in the ith segment is denoted by threadSize[I]
For all 1<=I<=n
For any high priority process, some stack size of the segments must be increased. A segment is said to be special when threadSize[i-1]threadsize[I+1]
The segments at each end cannot be special. The stack sizes must be modified in such a way as to maximize the number of special segments. To do so
choose any segment and increase the stack size by x
More formally,
1Choose an index i and an integer x where 0<=x<=10~18
2. Increase the stack size of th segment from threadSize[I]= threadSize[I]+x
Find the minimal total increase in the stack size of segments
Eg n =6
[3,1,4,5,5,2]
Its is optimal to add 2 and 1 to third and fifth segments. The final stack looks like [3,1,6,5,6,2]
Answer is 2+1=3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!