• edited by
25,251 views
72 72 votes

The following are the starting and ending times of activities $A, B, C, D, E, F, G$ and $H$ respectively in chronological order: $“a_s \: b_s \: c_s \: a_e \: d_s \: c_e \: e_s \: f_s \: b_e \: d_e \: g_s \: e_e \: f_e \: h_s \: g_e \: h_e”$. Here, $x_s$ denotes the starting time and $x_e$ denotes the ending time of activity X. We need to schedule the activities in a set of rooms available to us. An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration. What is the minimum number of rooms required?

  1. $3$
  2. $4$
  3. $5$
  4. $6$

13 Answers

3 3 votes

 This type of problem can be solved by array representation of starting time  ( taking +1) and ending time (taking -1 )

+1 +1 +1 -1 +1 -1 +1 +1 -1 -1 -1 -1 -1 -1 -1 -1

now taking sequence from array and sum  them for getting largest positive no 

+1 +1 +1 -1 +1 -1 +1 +1

this array is 1st 8 sequences of original array and sum is 1+1+1-1+1-1+1+1=4

so ans is 4

1 flag:
✌ Edit necessary (Sharad Kumar)
0 0 votes

This problem can be solved using a simple timeline (parenthesis) approach. We plot the start and end time of each activity on a single time axis, where the start of an activity represents its entry into a room and the end represents leaving the room. An activity occupies a room for its entire duration, so if multiple activities overlap at the same time, they must be assigned to different rooms.

By observing the diagram, we count how many activity lines overlap at any instant. The maximum overlap occurs when activities b, d, e, and f are running simultaneously, giving an overlap count of 4. Hence, the minimum number of rooms required to schedule all activities without conflict is 4.

Final Answer

Minimum number of rooms required = 4

Answer:
Position:
Show:

Related questions

61 61 votes
5 answers 5 answers
14.8k
14.8k views
Kathleen asked Sep 17, 2014
14,816 views
A program consists of two modules executed sequentially. Let $f_1(t)$ and $f_2(t)$ respectively denote the probability density functions of time taken to execute the two ...
94 94 votes
11 answers 11 answers
31.8k
31.8k views
go_editor asked Apr 24, 2016
31,764 views
In a permutation $a_1\ldots a_n$, of $n$ distinct integers, an inversion is a pair $(a_i, a_j)$ such that $i < j$ and $a_i a_j.$What would be the worst case time complex...
70 70 votes
9 answers 9 answers
20.4k
20.4k views
Kathleen asked Sep 17, 2014
20,387 views
In the following $C$ program fragment, $j$, $k$, $n$ and TwoLog_n are integer variables, and $A$ is an array of integers. The variable $n$ is initialized to an integer $\...
75 75 votes
5 answers 5 answers
29.2k
29.2k views
Kathleen asked Sep 17, 2014
29,206 views
Let $G= (V,E)$ be a directed graph with $n$ vertices. A path from $v_i$ to $v_j$ in $G$ is a sequence of vertices ($v_{i},v_{i+1}, \dots , v_j$) such that $(v_k, v_{k+1})...