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
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
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