Question: I need help correcting the code to a logical order instead of a physical order deletion. Please help. This is the prompt Make a linked
I need help correcting the code to a logical order instead of a physical order deletion. Please help. "This is the prompt Make a linked list using arrays and no pointers consisting of the following items, D GJMRW Show the list before the link list is created. Next show me the list pointer, the array list and the link list next to each item using the table below as an example.
Next write the code to add B and delete M Make the code so when I run the program, I can add and delete an item."
#include
using namespace std;
const int N ; Maximum number of elements
char listN; Array to store elements
int linkN; Array to store the index of the next element
int first ; Index of the first element
void initializeList
listD; link;
listG; link;
listJ; link;
listM; link;
listR; link;
listW; link;
void addchar item
int i first;
while linki
i linki;
for int j ; j N; j
if listj
listj item;
linki j;
linkj;
break;
void deleteElementchar item
int i first;
int prev ;
while i
if listi item
if prev
linkprev linki;
else
first linki;
listi;
break;
prev i;
i linki;
void displayTable
cout "Position List Link
;
cout
;
for int i ; i N; i
if listi
cout i listi linki endl;
int main
initializeList;
cout "Initial table:
;
displayTable;
int choice;
do
cout
Menu:
Add element
Delete element
Exit
Enter your choice: ;
cin choice;
if choice
char element;
cout "Enter element to add: ;
cin element;
addintelement;
displayTable;
else if choice
char element;
cout "Enter element to delete: ;
cin element;
deleteElementintelement;
displayTable;
while choice ;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
