Recall that offsets within a record or struct must sometimes be adjusted upward due to alignment restrictions. Thus in the following two C structs, S1 requires 6 bytes whereas S2 requires only 4 bytes.
![1007_45cb2fb8-4f25-429f-ad9b-4caf6c0e0619.png](https://secure.tutorsglobe.com/CMSImages/1007_45cb2fb8-4f25-429f-ad9b-4caf6c0e0619.png)
Assume we have a list of the fields in a record or struct. Each is characterized by its size and alignment restriction 2a. (A field with an alignment restriction 2a must be assigned an offset that is a multiple of 2a). Give an algorithm that determines an ordering of fields that minimizes the overall size of a record or struct while maintaining all alignment restrictions. How does the execution time of your algorithm (as measured in number of execution steps) grow as the number of fields increases?