mod m will help in traversing the blocks from starting block after we reach the end .
j = ( j + 1 ) % m NEW_LINE print ( " Process ▁ No . ▁ Process ▁ Size ▁ Block ▁ no . " ) NEW_LINE for i in range ( n ) : NEW_LINE print ( i + 1 , " ▁ " , processSize [ i ] , end = " ▁ " ) NEW_LINE if allocation [ i ] != - 1 : NEW_LINE print ( allocation [ i ] + 1 ) NEW_LINE else : NEW_LINE print ( " Not ▁ Allocated " ) NEW_LINE