1.4.36 space cost of the lower-pressure stack. Explain the data in the following table. It shows the general space cost of implementing various lower-pressure stacks. The node of the linked list is a static nested class, thus avoiding the overhead of non-static Nested classes.
1) The Int element type based on the linked list. N nodes are required for N values. Each node requires 16 bytes of object overhead + two 8-byte references, a total of 32 bytes, N nodes need 32 N bytes.
2) The integer element type based on the linked list. N nodes and N integers are required for N values. Each node needs 32 bytes and 32 bytes, an integer requires 16 bytes of object overhead + 4 bytes of int + 4 bytes to fill in a total of 24 bytes requires 24 n Bytes, a total of 56 bytes.
3) Based on the int element type of the variable-size array, the minimum length of the array is N for N values, and the longest array is 4 N (when the contraction point is reached). An int needs 4 bytes, it must be 4 to 16 n Bytes. An array object requires a 16-Byte object overhead and an int4-byte storage length overhead. A total of lg4n array objects are created, totaling 16lgn to 16lg4n bytes. The final length is about 4 N to 16 n Bytes.
4) based on the integer element type of the variable-size array, the minimum length of the array is N for N values, and the longest array is 4 N (when the contraction point is reached). An integer must be 24 bytes, an integer needs an 8-byte reference to point to it, so an element needs 32 bytes, and n elements need 32 N bytes. When the length of the array is 4 N, there are 3 n Array elements that do not point to integer, a reference is 8 bytes, and a 3N reference is a total of 24 n Bytes, then 32n + 24N = 56n bytes are required.
Space cost of Algs4-1.4.36 down-pressure Stack