Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 ( 1 pt ) Consider a program with the following struct and variables: struct node { int data; / / 4 bytes struct

Problem 1(1 pt) Consider a program with the following struct and variables:
struct node {
int data; //4 bytes
struct node * link; //4 bytes
};
struct node * head;
struct node ** ptr;
Assume that a struct node variable has its members stored in consecutive words in memory. (Note: this may
not be true in real systems. In certain cases, the data alignment of the members may different, e.g., to
improve pipeline performance.)
Suppose after the running the program for a bit, the memory looks like the following, where variable head is
at memory location 500.
Address Contents Data Type Variable
10004 struct node
10043000
5001000 struct node * head
20007 struct node
20040
30009 struct node
30042000
Next suppose the following instructions are executed. Answer the following questions
Instructions Questions
ptr = &head; After the instruction, what is the value in ptr?
What is the value of *ptr?
What is the value of (*ptr)->data?
ptr = &((*ptr)->link) After the instruction, what is the value in ptr?
What is the value of *ptr?
What is the value of (*ptr)->link?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

What were some important milestones in psychologys early history?

Answered: 1 week ago

Question

the mportant takeaways Manager in country manager simulation

Answered: 1 week ago