Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the pseudocode of the two functions, addRecord and deleteRecord, to add/de

ID: 3851523 • Letter: W

Question

Write the pseudocode of the two functions, addRecord and deleteRecord, to add/delete a record to/from a linked list of records.

Assume the following variables are already defined, initialized and available for you to use:

start: The pointer to the first record of the list (or NULL)

uaccountno: The user's account number (integer)

uname: a character array containing the user's name

uaddress: a character array containing the user's address

Assume the following struct definition:

    struct record
    {
        int               accountno;
        char              name[25];
        char              address[80];
        struct record*    next;
    };

Requirements:

Write the pseudocode for the following two functions:

addRecord: Must add a record to the end of the linked list of records

deleteRecord: Must delete ALL records (including duplicates) based on the account number

There must be no use of any C code in the algorithm

You may only use the allowed vocabulary from the list below with variations to accommodate different memory locations

The functioning code can be less than 20 lines for each function. Pseudocode with more than 30 lines for each function is not acceptable.

Vocabulary list:

replace the bold parts with your variables and expressions.

define a pointer to record called variable_name

note: you cannot define any other data type.

example:
define a pointer to record called temp

allocate space on the heap and store its address into variable_name

note: variable_name must be a pointer to record.

example:
allocate space on the heap and store its address into temp

release the space whose address is in variable_name

note: variable_name must be a pointer to record.

example:
release the space whose address is in temp

copy from variable_name1 to variable_name2

This copies the value in variable_name1 to variable_name2.
If the variables are character arrays, you can assume you can directly copy the characters.

example:
copy from temp1 to temp2
copy from string1 to string2

field_name in the record whose address is in variable_name

By this expression, you can access a field inside the record.

note1: field_name must be one of the fields in strecut record.
note2: variable_name must be a pointer to record.

example:
copy from name in the record whose address is in temp to val
copy from val to name in the record whose address is in temp

while( variable_name1 is / is not variable_name2 )

note1: inside a while loop, put 4 white spaces for indents
note2: you CANNOT use a break statement.

example:
while( accountno in the record whose address is in temp is 0 )
    ...

while( accountno in the record whose address is in temp is not 0 )
    ...

if( variable_name1 is / is not variable_name2 )

note1: inside an if statement, put 4 white spaces for indents
node2: you can use "else".

example:
if( var is not 0 )
    ...
else
    ...

Your submission should include the following:

Pseudocode (.txt) for the addRecord and deleteRecord functions described above. Since lines of code could be very long, the file must be plain text. See the template below.

Traces that verify the algorithm for the following test cases:

Add a record to empty list

Add a record to the list with 2 records

Delete account number that matches first record from the list with 3 records

Delete account number that matches second record from the list with 3 records

Explanation / Answer

void addRecord() //Function For Adding Record at last in a SinglyLinkedList
{
struct record* newRecord,*current,*start,*temp; //Declare
Structure Record Variables,
newRecord=(struct record *)malloc(sizeof(struct record)); //Allocating
Dynamic Memory Location
if(newRecord == NULL) //Check If Memory Allocation was Success or not
printf("Failed to Allocate Memory");
else
{
printf("Enter the Record Details: "); //Reading The Record Details
printf("Enter Account number:");
scanf("%d",&newRecord->accountno);
printf("Enter The Name:");
scanf("%s",&newRecord->name);
printf("Enter The Address");
scanf("%s",&newRecord->address);
newRecord->next=NULL; //Pointing to Next Record to NULL
if(start==NULL)
{
start=newRecord; //Pointing Starting
Record if Starting record is NULL
current=newRecord; //Current Record
Becomes First Record
}
else
{
temp = start;
while(temp->next!=NULL)
{
temp = temp->next;
}
temp->next = newRecord;
}
}
}

int deleteRecord(int accountno) //Function For deleteRecord from a
SinglyLinkedList
{
struct record *temp, *prev; //Declare Structure Record Variables
temp=head; //Assiging Record details to temp
while(temp!=NULL) //check Whether List containing Record or Not,if
Not Not Possible to deleteRecord
{
if(temp->accountno==accountno) //Check Accountno Exist or Not
{
if(temp==head)
{
head=temp->next;
free(temp); //Deleting The Memory Location(releasing The Memory
return 1;
}
else
{
prev->next=temp->next;
free(temp);
return 1;
}
}
else //Moving To Next Record For Check if Accountno is Exist
{
prev=temp;
temp= temp->next;
}
}
return 0;