Question

In: Computer Science

If the items in a list are floats taking 8 memory locations each, compare the amount...

If the items in a list are floats taking 8 memory locations each, compare the amount of space required altogether if (a) the list is kept contiguously in an array 80 percent full (b) the list is kept contiguously in an array 60 percent full and (c) the list is kept as a linked list where the pointers take two memory locations each

Solutions

Expert Solution

Let us consider an array of maximum size 100. Then

a) The list which is 85% full will take 400*85 = 34000 memory locations to store defined values. But the net size altogether will be 100*400 = 40000 memory loactions, since the rest 15 undefined values will also exist and take up memory since the size of the array is fixed.

b) The list which is 60% full will take 400*60 = 24000 memory locations to store defined values. But the net size altogether will be 100*400 = 40000 memory loactions, since the rest 40 undefined values will also exist and take up memory since the size of the array is fixed.

c) If the list is kept as a linked list where the pointers take two mwmory locations each, then 2 pointers will be required per Node in a linked list. Thus the net size of each node in a linked list will be 400+2+2, (here size of each pointer is 2). So for n elements in the list, the memory required is non-contiguous and will be of net size (n*404)

Thus we can see from the above comparison that in an array type list, the size required to store is constant and is always equal to the size of the array no matter what the size of the list is. But in a linked list type list, the size required to store the list increases linearly with the size of the list.


Related Solutions

The amount of iron ore (in tons) which can be mined each day at various locations...
The amount of iron ore (in tons) which can be mined each day at various locations is known to be approximately normally distributed. Building a mine at any location is economically feasible if the mean production at that location is at least 20 tons per day. Samples of daily production at each of two locations are shown below. Location 1 sample daily production = {14, 16, 19, 26, 13} Location 2 sample daily production = {20, 24, 21, 11} Find...
For each of the following items, calculate the amount of revenue or expense that should be...
For each of the following items, calculate the amount of revenue or expense that should be recognized on the income statement for Pelkey Co. for the year ended December 31, 2016:   Required: a. Cash collected from customers during the year amounted to $878,000, and accounts receivable increased by $46,300. How much were sales on account for the year ended December 31, 2016?. b. Cash payments for income taxes during the year were $189,000, and income taxes payable increased by $39,500....
Suppose we have 4 memory modules and each module has 8 addresses. Draw the memory modules...
Suppose we have 4 memory modules and each module has 8 addresses. Draw the memory modules with the addresses they contain using: a) High-order Interleaving and b) Low-order interleaving.
list of approved POCT locations in hospital and what kind of POC each one do?
list of approved POCT locations in hospital and what kind of POC each one do?
Agua Ole is a distributor of bottled water. For each of the​ items, compute the amount...
Agua Ole is a distributor of bottled water. For each of the​ items, compute the amount of cash receipts or payments Agua Ole will budget for September. The solution to one item may depend on the answer to an earlier item. ​ a. Management expects to sell equipment that cost $ 21,000 at a gain of $4,000. Accumulated depreciation on this equipment is $4,000. a. The amount of cash receipts the company will budget for the sale of the equipment...
/** * Loads a list of items from the given file. Each line is in the...
/** * Loads a list of items from the given file. Each line is in the format * <item type>~<item data>. The createFromString() methods in the item * classes will be used to parse the item data. * @param filename the filename * @return the list of items * @throws IOException if the file can't be opened */ public static List<Item> loadItems(String filename) throws IOException { List<Item> items = new ArrayList<>(); Scanner inPut = new Scanner(new FileReader(filename));        while(inPut.hasNextLine())...
Sepsis List each type of sepsis, identify causes of each, list prevention techniques, and compare and...
Sepsis List each type of sepsis, identify causes of each, list prevention techniques, and compare and contrast each type.
List the items under each main BoP account and explain each bygiving examples.
List the items under each main BoP account and explain each by giving examples.
In your home, choose five food items and five non-food items Make a list of these ten items and classify each item as:
In your home, choose five food items and five non-food items Make a list of these ten items and classify each item as: Made of cells or not made of cells? If not made of cells, of what is it made? If made of cells, are the cells dead or alive (in your best judgement)
Pick two items each from the 4 risk-weight categories of assets (so 8 items in total)...
Pick two items each from the 4 risk-weight categories of assets (so 8 items in total) and explain why they receive that particular weighting. What do you believe has been the biggest plus and the biggest minus of the effects of technology on the banking industry? (Please support each answer with examples)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT