Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help implementing this ordered linked list in C++. I am especially confused on some of the methods that are needed to return an

I need help implementing this ordered linked list in C++. I am especially confused on some of the methods that are needed to return an integer.

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() {

// default constructor // initializes the list to an empty state // Postcondition: first = NULL, last = NULL, count = 0; 

} 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) {

// Function to insert newItem in the ordered list // Key values should be used exclusively to find appropriate // location for inserted object // Postcondition: first points to the new list, newItem // is inserted at the proper place in the list, and // count is incremented by 1 // Return: Key value of item inserted on the list 

return -1; } template Type* LinkedList::get(int dest) const {

// Function to find the object at a specific location on the list // For example, if location = 0, find the first item on the list // If location = 4, find the fifth item on the list // Postcondition: Status of list not changed // Return: Object if found, NULL if object not found or if // location value is <= 0. 

return nullptr; } template Type* LinkedList::find(int dest) const {

// Function to find the object by key in the list // For example, find the item with key=1123 in the list // Postcondition: Status of list not changed // Return: Object if found, NULL if object not found 

return nullptr; } template int LinkedList::remove(int key) {

// Function to remove an item with key == keyValue from the list // Key values should be used exclusively to identify // object to be removed // Postcondition: if found the node with key == keyValue is // removed from the list; // first points to the first node of the new list; count is // decremented by 1. // Return: If item is in list, return key, else return -1. 

return 0; } template void LinkedList::clear() { } template int LinkedList::size() const {

return -1; } template void LinkedList::print() const { }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions