Parking Order
Algorithm
Input Number of parking slots and wake up sequence.
Output Parking order.
Complexity O(m).
Parking()
1. Set m= number of parking slots.
2. Set A[] wake up sequence.
3. Set b[i] = stores the parking order.
4. Repeat for i=1 to m.
Do If ( b[a[i]]==0 )
then Set b[a[i]] = i.
Else
Repeat for j=a[i] + 1 to m
If b[j] == 0 then : Set b[j] : = i and goto label out.
End of for loop.
Label out : continue.
5. Return
Algorithm Description
Algorithm determines the sequence of the order in which the car should be parked on the basis of the number of parking slots(m) available and input wake up sequence.