3.) Two structures (structs) of the same data set are declared. One of the struc
ID: 3562553 • Letter: 3
Question
3.) Two structures (structs) of the same data set are declared. One of the structures has a selfreferential pointer member and the other does not have a self-referential data member. The structure with a self-referential data member is used to create a linked-list of 10,000 elements. The structure without a self-referential member is used to create an array of 10,000 elements. Suppose the data members of the structure take up 50 bytes and the self-referential pointer member takes up 4 bytes.
(a) Calculate the memory requirements of the two data structures.
(b) Hence explain the advantage of one data structure over the other.
Explanation / Answer
A
1
With self referencing pointer
data
pointer
50 4
Each node require 54 byte
10000 element will require 54*10000=540000 byte memory.
2-
Without self referencing pointer
data
50
Each member require 50 byte
10000 member require 50*10000=500000byte
b)
it is true that 1 implementation take more space then second but still it has more advantages
With self reference(linked list)
Without self reference(array)
540000 memory it not necessarily require in successive locations
But a great amount 500000 successive byte must be available
Insertion deletion efficiently performed
Insertion deletion not efficiently performed
Number of elements can be increased or decreased easily due to dynamic memory allocation
Number of elements can not be increased or decreased easily due to static memory allocation
data
pointer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.