2 complex Vector

 can you do this for sure and if so how will you start doing i just want make sure you will be able to do it because a lot people here say they can than after i accept the bid before the due date by few hours they say sorry i cant do the assignment it one will be based on array and with size dynamically expanding and shrinking Another one based on linkedlist.
Use a simple vector you created before to create two other more complex vectors with
   1) Memory allocation that doubles size of memory when end reached, and 1/2’s memory when the size reaches 1/4.
   2) Implemented with a singularly linked list.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Main.cpp
#include <cstdlib>
  #include “SimpleVector.h”
  //System Libraries
  #include <iostream> //Input/Output Library
  using namespace std;
  //User Libraries
  //Global Constants, no Global Variables are allowed
  //Math/Physics/Conversions/Higher Dimensions – i.e. PI, e, etc…
  //Function Prototypes
  void fillVec(SimpleVector<int> &);
  void addVec(SimpleVector<int> &);
  void delVec(SimpleVector<int> &);
  void prntVec(SimpleVector<int> &,int);
  //Execution Begins Here!
  int main(int argc, char** argv) {
      //Declare Variables
      int size;
      //Read in the size
      cout<<“What size vector to test?”<<endl;
      cin>>size;
      SimpleVector<int> sv(size);
      //Initialize or input i.e. set variable values
      fillVec(sv);
      //Display the outputs
      prntVec(sv,10);
      //Add and subtract from the vector
      addVec(sv);
      //Display the outputs
      prntVec(sv,10);
      //Add and subtract from the vector
      delVec(sv);
      //Display the outputs
      prntVec(sv,10);
      //Exit stage right or left!
      return 0;
  }
  void addVec(SimpleVector<int> &sv){
      int add=sv.size()*0.1;
      for(int i=1;i<=add;i++){
          sv.push_front(i+add-1);
          sv.push_back(i-add);
      }
  }
  void delVec(SimpleVector<int> &sv){
      int del=sv.size()*0.2;
      for(int i=1;i<=del;i++){
          sv.pop_front();
          sv.pop_back();
      }
  }
  void fillVec(SimpleVector<int> &sv){
      for(int i=0;i<sv.size();i++){
          sv[i]=i%10;
      }
  }
  void prntVec(SimpleVector<int> &sv,int n){
      cout<<endl;
      for(int i=0;i<sv.size();i++){
          cout<<sv[i]<<” “;
          if(i%n==(n-1))cout<<endl;
      }
      cout<<endl;
  }
SimpleVector.h
// SimpleVector class template
  #ifndef SIMPLEVECTOR_H
  #define SIMPLEVECTOR_H
  #include <iostream>
  #include <new>       // Needed for bad_alloc exception
  #include <cstdlib>   // Needed for the exit function
  using namespace std;
template <class T>
  class SimpleVector
  {
  private:
     T *aptr;          // To point to the allocated array
     int arraySize;    // Number of elements in the array
     void memError(); // Handles memory allocation errors
     void subError(); // Handles subscripts out of range
public:
     // Default constructor
     SimpleVector()
        { aptr = 0; arraySize = 0;}
     // Constructor declaration
     SimpleVector(int);
     // Copy constructor declaration
     SimpleVector(const SimpleVector &);
     // Destructor declaration
     ~SimpleVector();
     //Adding and subtracting from the Vector
     void push_front(T);
     void push_back(T);
     T    pop_front();
     T    pop_back();
     // Accessor to return the array size
     int size() const
        { return arraySize; }
     // Accessor to return a specific element
     T getElementAt(int position);
     // Overloaded [] operator declaration
     T &operator[](const int &);
  };
  // Constructor for SimpleVector class. Sets the size of the *
  // array and allocates memory for it.                       *
  template <class T>
  SimpleVector<T>::SimpleVector(int s)
  {
     arraySize = s;
     // Allocate memory for the array.
     try
     {
        aptr = new T [s];
     }
     catch (bad_alloc)
     {
        memError();
     }
     // Initialize the array.
     for (int count = 0; count < arraySize; count++)
        *(aptr + count) = 0;
  }
  // Copy Constructor for SimpleVector class. *
  template <class T>
  SimpleVector<T>::SimpleVector(const SimpleVector &obj)
  {
     // Copy the array size.
     arraySize = obj.arraySize;
 
   // Allocate memory for the array.
     aptr = new T [arraySize];
     if (aptr == 0)
        memError();
 
   // Copy the elements of obj’s array.
     for(int count = 0; count < arraySize; count++)
        *(aptr + count) = *(obj.aptr + count);
  }
  // Add 1 or Delete 1 front or back for SimpleVector class. *
  template<class T>
  void SimpleVector<T>::push_front(T val){
      // Allocate memory for the array.
      T *newarr = 0;
      try
      {
          newarr = new T [arraySize + 1];
      }
      catch (bad_alloc)
      {
          memError();
      }
      *(newarr) = val;//Add value to the front of the new array
      // Copy previous array contents.
      arraySize++;//Increment array size
      for (int count = 1; count < arraySize; count++)
          *(newarr + count) = *(aptr + count – 1);
      delete aptr;//Delete previous array
      aptr = newarr;
  }
  template<class T>
  void SimpleVector<T>::push_back(T val){
      // Allocate memory for the array.
      T *newarr = 0;
      try
      {
          newarr = new T [arraySize + 1];
      }
      catch (bad_alloc)
      {
          memError();
      }
      // Copy previous array contents.
      for (int count = 0; count < arraySize; count++)
          *(newarr + count) = *(aptr + count);
      *(newarr + arraySize) = val;//Add value at back of the array
      arraySize++;//Increment array size
      delete aptr;//Delete previous array
      aptr = newarr;
  }
  template<class T>
  T SimpleVector<T>::pop_front(){
      T dummy = 0;
      if(arraySize != 0)//If array is not empty then only pop
      {
          dummy = *aptr;
          if(arraySize == 1){
              delete aptr;
              aptr = 0;
          }
          else {
              // Allocate memory for the array.
              T *newarr = 0;
              try {
                  newarr = new T[arraySize – 1];
              }
              catch (bad_alloc) {
                  memError();
              }
            // Copy previous array contents.
              for (int count = 1; count < arraySize; count++)
                  *(newarr + count – 1) = *(aptr + count);
              delete aptr;//Delete previous array
              aptr = newarr;
          }
          arraySize–;//Decrease array size
      }
      return dummy;//Return popped value
  }
  template<class T>
  T SimpleVector<T>::pop_back(){
      T dummy = 0;
      if(arraySize != 0)//If array is not empty then only pop
      {
          dummy = *(aptr + arraySize – 1);
          if(arraySize == 1){
              delete aptr;
              aptr = 0;
          }
          else {
              // Allocate memory for the array.
              T *newarr = 0;
              try {
                  newarr = new T[arraySize – 1];
              }
              catch (bad_alloc) {
                  memError();
              }
            // Copy previous array contents.
              for (int count = 0; count < arraySize – 1; count++)
                  *(newarr + count) = *(aptr + count);
              delete aptr;//Delete previous array
              aptr = newarr;
          }
          arraySize–;//Decrease array size
      }
      return dummy;//Return popped value
  }
  //**************************************
  // Destructor for SimpleVector class. *
  //**************************************
  template <class T>
  SimpleVector<T>::~SimpleVector()
  {
     if (arraySize > 0)
        delete [] aptr;
  }
  // memError function. Displays an error message and
  // terminates the program when memory allocation fails.
  template <class T>
  void SimpleVector<T>::memError()
  {
     cout << “ERROR:Cannot allocate memory.\n”;
     exit(EXIT_FAILURE);
  }
  // subError function. Displays an error message and         *
  // terminates the program when a subscript is out of range. *
  template <class T>
  void SimpleVector<T>::subError()
  {
     cout << “ERROR: Subscript out of range.\n”;
     exit(EXIT_FAILURE);
  }
  // getElementAt function. The argument is a subscript. *
  // This function returns the value stored at the sub-   *
  // cript in the array.                                  *
  template <class T>
  T SimpleVector<T>::getElementAt(int sub)
  {
     if (sub < 0 || sub >= arraySize)
        subError();
     return aptr[sub];
  }
  // Overloaded [] operator. The argument is a subscript. *
  // This function returns a reference to the element     *
  // in the array indexed by the subscript.               *
  template <class T>
  T &SimpleVector<T>::operator[](const int &sub)
  {
     if (sub < 0 || sub >= arraySize)
        subError();
     return aptr[sub];
  }
  #endif

Fountain Essays
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.