UniversityEssayServices

If Python did not already have a List data type, you might need to implement a data structure such as the dynamic array or vector described in this chapter. In this exercise you will explore how this can be done. Begin by creating the following class defi nition: class Vector (object): def __init__ (self): self.data = [ None ] * 5 self.size = 0 self.capacity = 5 def add (self, newValue): # add an element to the collection pass def insert (self, I, newValue): # insert at location i pass def remove (self, i): # remove value at location i pass def test (self, testValue): # see if collection contains element pass def __iter__(self): return self.data.__iter__() def size (self): return self.size Implement the functions add and insert. The add function places the new element at the end of the collection, while insert places the new element at a specifi c point. Both functions need to check that the size does not exceed the capacity before placing the value. If it does, the size of the array stored in self.data should be doubled and the capacity modifi ed appropriately. The remove method should delete an element at the given location. This reduces the size, but not the capacity. The test method should see if the value is held in the collection.

Found something interesting ?

• On-time delivery guarantee
• PhD-level professional writers
• Free Plagiarism Report

• 100% money-back guarantee
• Absolute Privacy & Confidentiality
• High Quality custom-written papers

Related Model Questions

Feel free to peruse our college and university model questions. If any our our assignment tasks interests you, click to place your order. Every paper is written by our professional essay writers from scratch to avoid plagiarism. We guarantee highest quality of work besides delivering your paper on time.

Sales Offer

Coupon Code: SAVE25 to claim 25% special special discount
SAVE