What is the size of a node? and where are the data recorded?
source link: https://www.codesd.com/item/what-is-the-size-of-a-node-and-where-are-the-data-recorded.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What is the size of a node? and where are the data recorded?
As the question implies,what's the size of usual node:
struct node{
int data;
node* next;
};
If the struct holds the data and the address of next node, what's the size of the pointer address(not what it points to)? Is there a difference if the next points to NULL?
where is the data(which is not a pointer) saved, stack or heap, if I made "new node":
node* linkednode= new node;
Are the answers change if I made class node?
You can easily check those using the sizeof()
function applying it not only to your int
and pointer variables but for the node itself. Usually int
s and pointers are 4 bytes on 32 bit platforms, so this is implementation defined and might vary on other platforms. The total size of node
might be equal to 8 but might not due to the cause specified above and\or data alignment.
Related Articles
What is the data type of 'MyActivity.this' - Android
How to recover / restore the data (records) of my MySQL database on a corrupted hard disk?
What are the imported class files and where are they imported from?
What is the difference in the purpose of TO and MAKE, and where are they documented?
Java: What is index-based access to arrays and why are they fast?
What is the data structure behind the Clojure sets?
Python: for-iteration through a string utf-8 - & gt; What is the data / coding type of the iterators?
What is the date format for & ldquo; From & rdquo; Annotation in javadoc?
How to update the data record using angularJS and Laravel?
What is the data structure of this variable in Perl?
What does the data-url attribute in jquery mobile do?
How to keep node and npm up to date? (nodesource ppa)
What is the data structure of the Inode number?
What does the data type specification '9 (7) V9T' mean?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK