Worst Fit Algorithm in Operating System

Worst Fit Algorithm in Operating System

The processes need empty memory slots during processing time. This memory is allocated to the processes by the operating system which decides depending on the free memory and the demanded memory by the process in execution. The three most common memory allocation schemes are first fit, best fit, and worst fit algorithm in Operating System.

Worst fit algorithm in os

How Worst Fit Works?

Worst fit works in the following way, for any given process Pn.

The algorithms searches sequentially starting from first memory block and searches for the memory block that fulfills the following condition –

  • Can accommodate the process size
  • Leaves the largest wasted space (fragmentation) after the process is allocated to given memory block

Worst Fit Allocation in OS

Worst Fit allocation in OS 2

Algorithm for Worst Fit Memory Management Scheme


  • Step 1: Input memory block with a size.
  • Step 2: Input process with size.
  • Step 3: Initialize by selecting each process to find the maximum block size that can be assigned to the current process.
  • Step 4: If the condition does not fulfill, they leave the process.
  • Step 5: If the condition is not fulfilled, then leave the process and check for the next process.
  • Step 6: Stop.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription