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

Could somebody help me implement this header file of an ordered linked list in C

ID: 3588293 • Letter: C

Question

Could somebody help me implement this header file of an ordered linked list in C++. I am especially confused on some that are needed to return an integer. It can have 3 private variables a pointer to the first node in the list, a pointer to the last node in the list, and a count of the number of nodes. The ordered linked list methods should be implemented such that node identification is accomplished using only key comparisons.

#ifndef ORDEREDLINKEDLIST_H
#define ORDEREDLINKEDLIST_H


template
struct LinkedNode
{
Type info;
LinkedNode *next;
};




template
class LinkedList
{
public:
LinkedList();
LinkedList(const LinkedList& other);
~LinkedList();


LinkedList& operator=(const LinkedList& other);


int insert(const Type&);
Type* find(int) const;
Type* get(int) const;
int remove(int);
void clear();
int size() const;
void print() const;
};


template
LinkedList::LinkedList()
{

}


template
LinkedList::LinkedList(const LinkedList& other)
{
}


template
LinkedList::~LinkedList()
{
}


template
LinkedList& LinkedList::operator=(const LinkedList& other)
{
return *this;
}


template
int LinkedList::insert(const Type& item)
{

return -1;
}


template
Type* LinkedList::get(int dest) const
{

return nullptr;
}


template
Type* LinkedList::find(int dest) const
{

return nullptr;
}


template
int LinkedList::remove(int key)
{

return 0;
}


template
void LinkedList::clear()
{
}




template
int LinkedList::size() const
{


return -1;
}


template
void LinkedList::print() const
{
}
#endif

Explanation / Answer

class LinkedList
{
public:
LinkedList();
LinkedList(const LinkedList& other);
~LinkedList();


LinkedList& operator=(const LinkedList& other);


int insert(const Type&);
Type* find(int) const;
Type* get(int) const;
int remove(int);
void clear();
int size() const;
void print() const;
};


template
LinkedList::LinkedList()
{

}


template
LinkedList::LinkedList(const LinkedList& other)
{
}


template
LinkedList::~LinkedList()
{
}


template
LinkedList& LinkedList::operator=(const LinkedList& other)
{
return *this;
}