0
0
DSA Cprogramming~10 mins

Minimum Number of Platforms in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read the number of trains.

DSA C
int n;
scanf("%[1]", &n);
Drag options to blanks, or click blank then click option'
Ad
Bf
Cs
Dc
Attempts:
3 left
💡 Hint
Common Mistakes
Using %f or %c instead of %d for integer input.
Forgetting the ampersand (&) before the variable.
2fill in blank
medium

Complete the code to sort the arrival times array.

DSA C
qsort(arrival, n, sizeof(int), [1]);
Drag options to blanks, or click blank then click option'
Acompare_ints
Bcmpfunc
CcompareInts
Dcompare
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL or wrong function name to qsort.
Not defining the comparison function properly.
3fill in blank
hard

Fix the error in the loop condition to find minimum platforms.

DSA C
while (i < n && j [1] n) {
    if (arrival[i] <= departure[j]) {
        platforms++;
        i++;
    } else {
        platforms--;
        j++;
    }
    if (platforms > max_platforms)
        max_platforms = platforms;
}
Drag options to blanks, or click blank then click option'
A<=
B>
C<
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than or equal operators causing infinite loops.
Using logical OR instead of AND.
4fill in blank
hard

Fill both blanks to correctly compare arrival and departure times.

DSA C
if (arrival[[1]] <= departure[[2]]) {
    platforms++;
    i++;
} else {
    platforms--;
    j++;
}
Drag options to blanks, or click blank then click option'
Ai
Bj
Ck
Dm
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong indices causing incorrect comparisons.
Mixing up arrival and departure indices.
5fill in blank
hard

Fill all three blanks to initialize variables correctly.

DSA C
int i = [1], j = [2], platforms = [3];
Drag options to blanks, or click blank then click option'
A0
B1
Attempts:
3 left
💡 Hint
Common Mistakes
Starting indices at 1 causing out-of-bound errors.
Initializing platforms to 1 instead of 0.