We mentioned the first fit and best fit as applied to finding parking spaces at a mall. (a) Write a first-fit car parking algorithm. Here first-fit means the first spot we find. (b) Write a best-fit car parking algorithm. Here best-fit means the spot closest to the front door. (c) In your own words, explain why first fit might be a better algorithm on average to minimize the time to get to the door of the mall.

Q&A Education