Question
Can someone fix my pseudocode so it will make sense? The goal is to have an addRecord function that adds the account number, name, and
Can someone fix my pseudocode so it will make sense? The goal is to have an addRecord function that adds the account number, name, and address to the record.
This is my pseudocode:
define a pointer to record called temp allocate a heap space and store its address into temp
/* Allows user's account number to be stored in the record, else it would look if the address match a previous address by copying addresses in start and temp to avoid duplicates */
if( start is not equal to NULL ) if( uaccountno is not equal to accountno in the record whose address is in temp)
copy from uaccountno to accountno in the record whose address is in temp
copy from uname to name in the record whose address is in temp
copy from uaddress to address in the record whose address is in temp copy from NULL to next in the record whose address is in temp
else
copy from accountno in the record whose address is in start to accountno in the record whose address is in temp
copy from name in the record whose address is in start to name in the record whose address is in temp
copy from address in the record whose address is in start to address in the record whose address is in temp
copy from next in the record whose address is in start to next in the record whose address is in temp
/* head points to temp in the linked list whose accountno is either equal or smaller to uaccountno, and tail points to temp just before head. This way we get the linked list sorted */
define a pointer to record call head copy from start to head
define a pointer to record called tail copy from NULL to tail
while ( accountno in the record whose address is in head is greater to uaccountno )
copt from head to tail
copy from next in the record whose address is in head to head
copy from next in record whose address is in tail to next in the record whose address is in temp
copy from temp to next in the record whose address is in tail
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