## Implementing the Linear Array Algorithm/Data Structure

Solution

In this tutorial, we will learn how to implement a Linear Array Data Structure/Algorithm.

Using some of the OOP concepts to implement the Algorithm, we will use the likes of classes and functions.

What we will learn:

• How to implement the insert functionality
• How to implement the  edit functionality
• How to implement the display functionality

The code snippet below:

 class LinearArray{ public:     void LinearArrayMenu(){     //int n;     //cin >> n;     int n,x,i,flag=0;     cout<<"How many elements: ";     cin>>n;     string name[n];     int arr[n], listitems[n];     for(i=0;i>name[i];         listitems[i] = arr[i];     }     cout << "Your list of items: ";     for(i=0; i> k;     int j = n - 1;     cout << "\nelements after inserting new elements" << endl;     while (j >= k) {     name[j] = name[j - 1];     j = j - 1;   }     cout << "Enter new item: ";     cin >> new_item;     name[k] = new_item;     for (int i = 0; i < n; i++) {     cout <<"\nposition" << "(" << i << "): " << name[i] << "\n";     }         } };

CSC305 Exam Focus/Materials 4/4/2021 Seth 0 Answer(s) 108 views

Seth 1413