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

C++: Design a Basic Link List class to hold a series of integers. Implement the

ID: 655658 • Letter: C

Question

C++:

Design a Basic Link List class to hold a series of integers.

Implement the following member functions:

1. Append

2. Prepend

3. Constructor

4. Destructor

5. RemoveFront

6. RemoveBack   

7. Print List (in rows of ten values)

8. ClearList

Test/Demonstrate ALL methods.

Populate your list with 50 scores between 30 and 95.

Use random generator to create scores.

Design a Sorted Link List class to hold a series of integers.

You may use Composition or Inheritance.

Implement the additional member functions:

1. Insert Node

2. Delete Node

Test/Demonstrate ALL methods.

Populate your list with 50 scores between 30 and 95.

Use random generator to create scores.

Design a List Analysis class to hold a series of integers.

You may use Composition or Inheritance.

Implement the additional member functions:

1. getCount

2. getHighValue

3. getLowValue

4. getAverage

5. getMedian

Test/Demonstrate ALL methods.

Generate a random number of scores between 25 and 65.

Populate your list with score values between 30 and 95.

Use random generator to create scores.

I'm primarily concerned with how to go about creating the base link list class working with non-contiguous memory and memory management.

Explanation / Answer

#include <stdlib.h> /* srand, rand */
class node
{
protected:
int info;
node * next;
public:
node()
{
info=-1;
next=null;
}

class list:public node
{
private:
node *head;
public:
list()
{
head=null;
}
~ list()
{
}
void append(int);
void prepend(int);
void RemoveFront();
void RemoveBack();
void display();
void clearlist();
}
void list::append(int item)
{
node *temp=head;
node * ob=new node();
ob->info=item;
if(head!=null)
{
for(;temp->next!=null;temp=temp->next);
temp->next=ob;
else
head=ob;
}
void list:prepend(item)
{
node * ob=new node();
ob->info=item;
if(head!=null)
{
ob->next=head;
head=ob;
}
else
head=ob;
}
void RemoveFront()
{
if(head!=null)
{
cout<<"item value is"<<head->next;
head=head->next;
}
}
void RemoveBack()
{
node * temp=head;
node *temp1;
if(head!=null)
{
for(;temp->next!=null;temp=temp->next)
{
temp1=temp;
}
temp1->next=null;
delete temp;
}
}
void display()
{
node *temp=head;
for(int i=0;i<5;i++)
{
for(int j=0;j<10;j++)
{
cout<<temp->info<<" ";
temp=temp->next;
}
cout<<" ";
}
}
void clearlist()
{
node *temp=head;
node *temp1;
if(head!=null)
for(;temp->next!=null;temp=temp-next)
{
temp1=temp;
delete temp;
}
delete temp;
}

void main()
{
int item;
list ob=new ob();
for(int i=0;i<25;i++)
{
item = rand() % 66+ 30;   
ob.append(item);
}
for(int i=0;i<25;i++)
{
item = rand() % 66+ 30;   
ob.prepend(item);
}
ob.display();
ob.RemoveFront();
ob.RemoveBack();
ob.ClearList();
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote