Yeh page ek drill hai. Hum parent topic ke do formulas lete hain aur unhe har tarah ke input ke against beat karte hain — clean numbers, exact fits, tiny processes, huge processes, degenerate "one hole" case, ek word problem, aur ek exam trap.
Shuru karne se pehle, teen symbols poore page ko carry karte hain. Hum inhe zero se define karte hain:
⌈⌉ marks ceiling hain — "agale pure number tak upar round karo". Hum ⌈2.44⌉=3 ko padhte hain: "2.44 blocks exist nahi karta, isliye tumhe 3 pure blocks chahiye." Upar kyun aur neeche kabhi nahi? Kyunki neeche rounding karne se process ke kuch bytes bina ghar ke reh jaate — yeh illegal hai. Har bacha hua byte ek naya block force karta hai.
Total free:40+30+50=120 K.
Yeh step kyun? Ratio sabse bada usable piece ko sari free memory se compare karta hai.
Largest block:max(40,30,50)=50 K (figure mein amber bar).
Ratio:1−50/120=1−0.4167=0.5833.
Yeh step kyun? 1 ke karib ratio matlab free memory buri tarah shattered hai; yahan aadhe se zyada 50 K se upar kisi bhi request ke liye unusable hai.
100 K request:ek contiguous hole mein land karni chahiye. Largest 50 K <100 K hai → fail, chahe 120>100.
Yeh step kyun? Process ko di jaane wali memory contiguous honi chahiye; tum ek request ke liye teen alag holes ko nahin jod sakte.
Verify:0.5833≈7/12; aur indeed 1−50/120=(120−50)/120=70/120=7/12. ✓ Request fail hoti hai kyunki koi single hole ≥100 K nahi hai.
A, B, C ko front par slide karo: saare used blocks ek end ke against pack ho jaate hain (figure ka top → bottom).
Yeh step kyun? Compaction physically allocated blocks ko saath copy karta hai; iske liye run-time relocatable addresses chahiye (ek base/relocation register), warna copied code galat jagahon ko point karega.
Holes merge ho jaate hain: freed space ek block of 40+30+50=120 K ban jaata hai.
Yeh step kyun? Kuch free ya create nahi kiya gaya — wahi same 120 K ab scattered ki jagah contiguous hai.
Naya ratio:1−120/120=0.
100 K request:120≥100ek block mein → succeed karti hai.
Yeh step kyun? Ab ek single hole kaafi bada hai, jo bilkul wahi hai jo request ko chahiye.
Verify: total free unchanged (120 K pehle aur baad mein — compaction move karta hai, delete nahi); ratio 0.5833→0 drop hua. ✓ Aur 120≥100, isliye success. Note karo A, B, C ke andar internal waste untouched hai — compaction sirf external theek karta hai.
Internal formula ::: ⌈S/B⌉B−S; zero sirf tab jab SB ka multiple ho; worst case B−1; system total = tails ka sum (average mein ≈B/2 each).
External ratio ::: 1−total freelargest free block; ek hole ke liye 0, memory shatter hone par 1 ki taraf badhta hai; compaction ise 0 kar deta hai total free ko change kiye bina.