A municipality stored details about every house in its pervi
A municipality stored details about every house in its perview as a ‘structure'. each containing a large number of details. These are to be sorted. The best approach is
Answer: store pointers to them in an array and sort the array
Explanation:
In general, an array of pointers can be used to point to an array of data items with each element of the pointer array pointing to an element of the data array. Data items can be accessed either directly in the data array, or indirectly by dereferencing the elements of the pointer array. The advantage of a pointer array is that the pointers can be reordered in any manner without moving the data items.
For example, the pointer array can be reordered so that the successive elements of the pointer array point to data items in sorted order without moving the data items. Reordering pointers is relatively fast compared to reordering large data items such as data records or strings. This approach saves a lot of time, with the additional advantage that the data items remain available in the original order.
All Comments