Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Exercise: As a completion of the Unsorted List implementation as array, implement the following two methods: find(e): Search for an element e and return

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Lab Exercise: As a completion of the Unsorted List implementation as array, implement the following two methods: find(e): Search for an element e and return the index of e if exists, otherwise return -1. replace(i, e): Replace the element at index / with elemente and return the element at index i. An error condition occurs if i length() - 1.// length) is the number of elements stored in the list. #include using namespace std; template class UnsortedArrlist { private: int size; //array size int NoofElem; //Number of stored elements T* arr; public: //constructor UnsortedArrlist(int s) { size = 5; NoOfElem = 0; arr = new T(S); } //--- //length function int length() { return NoofElem; } //--- //isEmpty function bool isEmpty() 1 return (Nooftlen): ) //isFull function bool IsFull) return (Noofelen -- size); > 11. //display function void display() { for (int 1 . ; 1 NoOfElen; 1=+) cout 1- //getFirst function T getFirst) { return arre > // //getlast function get last return arr[Noofeler-1]; > 11. //get Function T get(int.) 1 Cisempty()) cout else return arr); > //add function void add(int Te if (isFullo) cout 1/03>***?*/; 3--) ar[s] arts - 1); arr[1] = 0; NoofElen. > remove function void remove(int i) { if (isempty()) cout

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions