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

Simple Linked List Class Using an appropriate definition of ListNode, design a s

ID: 650792 • Letter: S

Question

Simple Linked List Class
Using an appropriate definition of ListNode, design a simple linked list class with only
two member functions and a default constructor:
void add(double x);
boolean isMember(double x);
LinkedList( );
The add function adds a new node containing x to the front (head) of the list, while the isMember function tests to see if the list contains a node with the value x. Test your linked list class by adding various numbers to the list and then testing for membership.

Recursive Member Check
Modify the list class you created in the previous programming challenges to use a recursive method to check for list membership. Test your class.


List Member Deletion
Modify the list class you created in the previous programming challenges by adding a function to remove an item from the list, and by adding a destructor:
void remove(double x);
~LinkedList();
Test the class by adding by a sequence of instructions that mixes operations for adding items, removing items, and printing the list.


List Reverse
Modify the list class you created in the previous programming challenges by adding a member function for reversing the list:
void reverse();
The member function rearranges the nodes in the list so that their order is reversed. You should do this without creating or destroying nodes.

Explanation / Answer

hope it will helps you i tried my best ..

woking fine when i ran it in my IDE.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
struct NODEEE
{
   int info;
   struct NODEEE *next;
};
typedef struct NODEEE NODEEEe;

class simplelist
{
    NODEEEe *f;
    public:
    simplelist()
    {
      f=NULL;
    }
    void insert(int);
    void del();
    void disp();
};
void simplelist::insert(int num)
{
    NODEEEe *p=new NODEEEe;
    p->info=num;
    p->next=f;
    f=p;
}
void simplelist::del()
{
    clrscr();
    NODEEEe *temp=f;
    if(f==NULL)
    cout<<" The list is empty";
    else
    {
  
      f=f->next;
      delete temp;
      cout<<" Deletion done";
    }
    return;
}
void simplelist::disp()
{
    NODEEEe *temp=f;
    if(f==NULL)
    cout<<" The list is empty";
    else
    {
      cout<<" The elements :";
        while(temp!=NULL)
      {
        cout<<" "<<temp->info;
        temp=temp->next;
      }
    }
}
void main()
{
int num,ch=1;
simplelist ob;
clrscr();
while(ch)
{
    <<" Enter 1 to pushed "
    <<" Enter 2 to delete "
    <<" Enter 3 to display "
    <<" Enter 4 to exit "
    <<" Enter your choice: ";
    cin>>ch;
    switch(ch)
    {
    case 1:clrscr();
      cout<<"number to be inserted ";
      cin>>num;
      ob.insert(num);
      ob.disp();
      break;
    case 2:clrscr();
      ob.del();
      ob.disp();break;
    case 3:clrscr();
      ob.disp();break;
    case 4:exit(0);
    default : cout<<"wrong choice";
    }
}
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