Question: Homework 06 Q1 50 PointsGrading comment: Consider the following definition of a struct: struct lnode { char *str; // points to 14-character string int size;

Homework 06

Q1

50 PointsGrading comment:

Consider the following definition of a struct:

struct lnode { char *str; // points to 14-character string int size; // size of the string struct lnode *next; // points to next node address struct lnode *prev; // points to prev node address };

We know from the source code that the variable "list" is the start of a linked list. We can execute the following command in gdb to find the start of the linked list:

(gdb) print list $1 = (struct lnode *) 0x55555555b2b0

We can also look at the memory where the list resides

(gdb) x/80xg 0x55555555b2b0 0x55555555b2b0: 0x000055555555b2e0 0x000000000000000d 0x55555555b2c0: 0x000055555555b300 0x0000000000000000 0x55555555b2d0: 0x0000000000000000 0x0000000000000021 0x55555555b2e0: 0x656e6f207473754a 0x0000006c616d7320 0x55555555b2f0: 0x0000000000000000 0x0000000000000031 0x55555555b300: 0x000055555555b330 0x000000000000000d 0x55555555b310: 0x000055555555b350 0x000055555555b2b0 0x55555555b320: 0x0000000000000000 0x0000000000000021 0x55555555b330: 0x697469736f70206c 0x0000006874206576 0x55555555b340: 0x0000000000000000 0x0000000000000031 0x55555555b350: 0x000055555555b380 0x000000000000000d 0x55555555b360: 0x000055555555b3a0 0x000055555555b300 0x55555555b370: 0x0000000000000000 0x0000000000000021 0x55555555b380: 0x6e6920746867756f 0x0000002065687420 0x55555555b390: 0x0000000000000000 0x0000000000000031 0x55555555b3a0: 0x000055555555b3d0 0x000000000000000d 0x55555555b3b0: 0x000055555555b3f0 0x000055555555b350 0x55555555b3c0: 0x0000000000000000 0x0000000000000021 0x55555555b3d0: 0x20676e696e726f6d 0x00000063206e6163 0x55555555b3e0: 0x0000000000000000 0x0000000000000031 0x55555555b3f0: 0x000055555555b420 0x000000000000000d 0x55555555b400: 0x000055555555b440 0x000055555555b3a0 0x55555555b410: 0x0000000000000000 0x0000000000000021 0x55555555b420: 0x6f792065676e6168 0x0000006877207275 0x55555555b430: 0x0000000000000000 0x0000000000000031 0x55555555b440: 0x000055555555b470 0x000000000000000d 0x55555555b450: 0x000055555555b490 0x000055555555b3f0 0x55555555b460: 0x0000000000000000 0x0000000000000021 0x55555555b470: 0x2e79616420656c6f 0x000000209480e220 0x55555555b480: 0x0000000000000000 0x0000000000000031 0x55555555b490: 0x000055555555b4c0 0x000000000000000b 0x55555555b4a0: 0x0000000000000000 0x000055555555b440 0x55555555b4b0: 0x0000000000000000 0x0000000000000021 0x55555555b4c0: 0x614c2069616c6144 0x000000000000616d 0x55555555b4d0: 0x0000000000000000 0x000000000001eb31 0x55555555b4e0: 0x0000000000000000 0x0000000000000000 0x55555555b4f0: 0x0000000000000000 0x0000000000000000 0x55555555b500: 0x0000000000000000 0x0000000000000000

Given this information, answer the following questions about the linked list.

Q1.1

10 PointsGrading comment:

Give the starting address of the first node of the linked list (as a hexadecimal address).

Save Answer

Question 1.1:

Q1.2

10 PointsGrading comment:

Give the size of a single node of the linked list (in bytes)

Save Answer

Question 1.2:

Q1.3

10 PointsGrading comment:

Give the starting address of the last node in the linked list (as a 64-bit hexadecimal address).

Save Answer

Question 1.3:

Q1.4

10 PointsGrading comment:

How many nodes are there in the linked list?

Save Answer

Question 1.4:

Q1.5

10 PointsGrading comment:

What is the string that is stored in the linked list (across all the nodes)?

Save Answer

Question 1.5:

Q1.6

0 PointsGrading comment:

Upload your work for question 1 here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!