Question

In: Computer Science

How many cost units are spent in the entire process of performing 40 consecutive append operations...

How many cost units are spent in the entire process of performing 40 consecutive append operations on an empty array which starts out at capacity 4, assuming that the array will double in capacity each time a new item is added to an already full dynamic array? As N (i.e., the number of appends) grows large, under this strategy for resizing, what is the average big-O complexity for an append?

How many cost units are spent in the entire process of performing 40 consecutive append operations on an empty array which starts out at capacity 4, assuming that the array will grow by a constant 2 spaces each time a new item is added to an already full dynamic array? As N (i.e., the number of appends) grows large, under this strategy for resizing, what is the average complexity for an append?

Solutions

Expert Solution

Question 1 :

- 40 consecutive push operations
- array of initial capacity 4
- double in capacity every time item added to full dynamic array
- what is big-o complexity?

Push Operations Cost Description
1 1
2 1
3 1
4 1
5 5 Copying Old 4 elements to new array, and appending new element , so total cost = 5 and New Size = 8
6 1
7 1
8 1
9 9 New Size = 16
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 17 New Size = 32
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 33 New Size = 64
34 1
35 1
36 1
37 1
38 1
39 1
40 1
Total Cost 100

Average Time Complexity for append operation : O(1)

Worst case Time Complexity for append Operation : O(n) where n = number of elements in the array

Question 2 :

- 40 consecutive push operations
- array of initial capacity 4
- grows by 2 elements in size every time item added to full dynamic array
- what is big-o complexity?

Push Operations Cost Description
1 1
2 1
3 1
4 1
5 5 Total Cost = 5 ( 4 + 1 -> Copy 4 elements and append 1 element ) New Size = 6
6 1
7 7 New Size = 8
8 1
9 9 New Size = 10
10 1
11 11
12 1
13 13
14 1
15 15
16 1
17 17
18 1
19 19
20 1
21 21
22 1
23 23
24 1
25 25
26 1
27 27
28 1
29 29
30 1
31 31
32 1
33 33
34 1
35 35
36 1
37 37
38 1
39 39
40 1
Total Cost 418

For all most half of the elements (n/2 ) elements, New array is being created and all the existing elements are being copied.

Average case time of append operation : O ( n/2) which is equivalent to O(n)  asymptotic time.


Related Solutions

. Summarize the process of performing a cost-benefit analysis to determine the efficient level of pollution...
. Summarize the process of performing a cost-benefit analysis to determine the efficient level of pollution abatement. Identify common difficulties as well as shortcomings and positive aspects of such an analysis.
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 9,000 units, 65% completed 31,635 To Finished Goods, 207,000 units ? Direct materials, 212,000 units @ $1.5 318,000 Direct labor 492,900 Factory overhead 191,685 Bal. ? units, 45% completed ? a. Based on the above data, determine the...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 3,000 units, 75% completed 9,450 To Finished Goods, 69,000 units ? Direct materials, 71,000 units @ $1.8 127,800 Direct labor 93,700 Factory overhead 36,450 Bal., ? units, 35% completed ? Cost per equivalent units of $1.80 for Direct...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 7,000 units, 70% completed 28,210 To Finished Goods, 161,000 units ? Direct materials, 165,000 units @ $2 330,000 Direct labor 363,100 Factory overhead 141,270 Bal. ? units, 60% completed ? a. Based on the above data, determine the...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 6,000 units, 70% completed16,140To Finished Goods, 138,000 units? Direct materials, 141,000 units @ $1.5211,500   Direct labor178,700   Factory overhead69,430   Bal., ? units, 45% completed?   Cost per equivalent units of $1.50 for Direct Materials and $1.80 for Conversion Costs. a....
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 6,000 units, 75% completed 25,500 To Finished Goods, 138,000 units ? Direct materials, 141,000 units @ $1.7 239,700 Direct labor 372,400 Factory overhead 144,860 Bal. ? units, 70% completed ? a. Based on the above data, determine the...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 7,000 units, 45% completed 16,660 To Finished Goods, 161,000 units ? Direct materials, 165,000 units @ $1.3 214,500 Direct labor 306,800 Factory overhead 119,340 Bal., ? units, 55% completed ? Cost per equivalent units of $1.30 for Direct...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 6,000 units, 70% completed16,140To Finished Goods, 138,000 units? Direct materials, 141,000 units @ $1.5211,500   Direct labor178,700   Factory overhead69,430   Bal., ? units, 45% completed?   Cost per equivalent units of $1.50 for Direct Materials and $1.80 for Conversion Costs. a....
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 2,000 units, 75% completed 10,000 To Finished Goods, 46,000 units ? Direct materials, 47,000 units @ $2 94,000 Direct labor 139,600 Factory overhead 54,330 Bal. ? units, 20% completed ? a. Based on the above data, determine the...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a...
Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 6,000 units, 35% completed 13,590 To Finished Goods, 138,000 units ? Direct materials, 141,000 units @ $1.6 225,600 Direct labor 200,200 Factory overhead 77,900 Bal. ? units, 35% completed ? Cost per equivalent units of $1.60 for Direct...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT