Question
Hello in next program SLListADT::~SLListADT() { for(node *p;!isEmpty();) { p = head->next; delete head; head = p; } } bool SLListADT::isEmpty() { return head ==
Hello
in next program
SLListADT::~SLListADT()
{
for(node *p;!isEmpty();)
{
p = head->next;
delete head;
head = p;
}
}
bool SLListADT::isEmpty()
{
return head == NULL;
}
int SLListADT::countNodes()
{
return count;
}
void SLListADT::printList()
{
if(count > 0)
{
for(node *tmp = head; tmp!= NULL; tmp = tmp->next)
{
cout << tmp->info << "\t";
}
cout << endl;
}
}
void SLListADT::initList()
{
for (node *p; !isEmpty(); )
{
p = head->next;
delete head;
head = p;
}
count = 0;
head = NULL;
tail = NULL;
}
void SLListADT::insertToHead(int a)
{
head = new node(a, head);
if (tail == NULL)
tail = head;
count++;
}
void SLListADT::insertToTail(int b)
{
if (tail != NULL)
{
tail->next = new node(b);
tail = tail->next;
}
else
head = tail = new node(b);
count++;
}
int SLListADT::removeFromHead()
{
if(!isEmpty())
{
int vla = head;
}
}
int SLListADT::removeFromTail()
{
}
bool SLListADT::find(int c) const
{
}
i want ask how to do the function for:
int removeFromHead(); // function to remove the head and return its info;
int removeFromTail(); // function to remove the tail and return its info;
bool find(int) const; // function to check if at-least one instance of given value exists in the list
void insertAt(int, int); // function to insert a value at the given position in the list
void removeAt(int); // function to remove a node from the list at given position
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