I NEED THIS SOLVED QUICK AS POSSIBLE PLEASE Use the space equation of Section 4.
ID: 3681403 • Letter: I
Question
I NEED THIS SOLVED QUICK AS POSSIBLE PLEASE
Use the space equation of Section 4.1.3 to determine the break-even point for an array-based list and linked list implementation for lists when the sizes for the data field, a pointer, and the array-based list’s array are as specified. State when the linked list needs less space than the array.
(a) The data field is eight bytes, a pointer is four bytes, and the array holds twenty elements.
(b) The data field is two bytes, a pointer is four bytes, and the array holds thirty elements.
(c) The data field is one byte, a pointer is four bytes, and the array holds thirty elements.
(d) The data field is 32 bytes, a pointer is four bytes, and the array holds forty elements.
Explanation / Answer
a)
Space required by array =20*8=160 bytes
Space required by one node of linked list =12 bytes
Hence when number of elements n*12<=160 then we can use linked list i.e
n<=13 we can use linked list
b)
Size of array=60
Size of one node=6bytes
hence n*6<=60
n<=10 we can use linked list
c)
Similarly
array=30 bytes
Size of one node=5
n*5<=30
n<=6
d)
Array=32*40 bytes
and size of node=36bytes
Hence n*36<=32*40
n<=35
DO give a thumbs up
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.