Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING C++ ONLY!!!! Design lower level functions to do the heavy lifting of moving data around, Do not forget to write a CopyList and a

USING C++ ONLY!!!!

  • Design lower level functions to do the "heavy lifting" of moving data around,
  • Do not forget to write a CopyList and a Search function along with an Allocate, Initialize, and print functions for your list.
  • I do not want to see a bunch of for loops in your AddEntry, DeleteEntry or in main()
  • IMPORTANT:

    • Rather than adding one to the capacity of the list, double the capacity when you run out of room. This is a much more realistic method. On remove_entry, reallocate half the space when the size reaches 1/4 of the capacity.
  • IMPORTANT:

    • Set your capacity to 3. Have a debug boolean flag allow printing of a clear message that more space is being allocated whenever you are about to exceed the capacity. A message should also display when you allocate a smaller space for your list. Your output MUST allow me to see when memory management is taking place.

Function Prototypes:

T* add_entry(T* list, const T& new_entry, int& size, int& capacity); T* remove_entry(T* list, const T& delete_me, int& size, int& capacity); T* allocate(int capacity); void copy_list(T *dest, T* src, int many_to_copy); T* search_entry(T* list, const T& find_me, int size); void print_list(T* list, int size); void test_string();

void test_string(){ int capacity = 3; int size = 0; T* list = allocate(capacity); list = add_entry(list, "Erika", size, capacity); print_list(list, size); list = add_entry(list, "Red", size, capacity); print_list(list, size); list = add_entry(list, "Bo", size, capacity); print_list(list, size); list = add_entry(list, "Pierson", size, capacity); print_list(list, size); list = add_entry(list, "Maher", size, capacity); print_list(list, size); list = add_entry(list, "Mac", size, capacity); print_list(list, size); list = add_entry(list, "Paula", size, capacity); print_list(list, size); cout<<"Deleting Erika"< 

The allocate function:

Very simple, but just to keep the confusion level down:

T* allocate(int capacity){ const bool debug = false; if (debug) cout<<"allocate: capacity: "<                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions