Answered step by step
Verified Expert Solution
Question
1 Approved Answer
0 ) Write a simple loop that, for each record r in the list L , changes r . dat to be r . dat
Write a simple loop that, for each record r in the list L changes rdat to be rdat plus all of the dat
values in the records that precede r in the original list L
So if the numbers in the list are then they are changed to
Solution:
sum ; So sum is a local identifier
L; where L was defined earlier. The assignment to keeps L pointing at the front of the list
while Nil do You might prefer null
sum sum dat
dat sum;
next
endwhile;
Write a simple sequence of instructions that processes two singly linked lists Y and M by removing the
first record in Y if Y Nil and prepending that record at the front of list M so that M now has this
new element as the first record followed by the old M and Y no longer contains what had been its first
record. In other words, you have a list Y and I have a list M Present instructions that pull off your head,
and place it on top of mine.
Write a simple loop that reverses the list Y and gives this new list the name Y
Does part i make this easier?
Give a simple, highlevel three line description do this, do that, do this of an iterative method to modify
L so that for each record r in the list, rdat is changed to be rdat plus all of the dat values in the
records that follow succeed r in the original list L
So if the numbers in the list are then they are changed to
Detailed pseudocode is unnecessary for this part. Does part ii make this easier? Your answer could be
no
Find a simple, twopass iterative solution ie which processes all of L twice to modify L to have the
sums as requested in but without ever changing any of its pointers. You can present the pseudocode,
or explain your answer at a higher level.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started