Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Assignment main of the program can be found here : http://staffwww.fullcoll.edu/aclifton/cs133/files/assign1_test.cpp Some hints Here are some things that dont work: Creating the array as

C++ Assignment

image text in transcribed

image text in transcribed

image text in transcribed

main of the program can be found here: http://staffwww.fullcoll.edu/aclifton/cs133/files/assign1_test.cpp

Some hints

Here are some things that dont work:

Creating the array as a global variable. The test runner will create more than one instance of ordered_array and expects all instances to be independent.

Assuming that 0, -1, or some other value will never be stored into the array (and hence can be used as a marker for the end of the array or something). All ints are valid values in the array. (Note that NULL is equal to 0.)

Assuming that all inserts will be performed at once. The test code may mix up a sequence of insert and removes.

In this assignment, youllimplement a simple data structure which maintains a sorted array. This is essentially just a simple wrapper around a dynamically-allocated array of int (you can also use a vector ) which allows the user to insert and remove values. The elements of the array should always be sorted in ascending order this means that when you add new elements, you need to figure out where they go in the array, shift everything after them up, and then drop the new element into place. Likewise, when you remove an element, you have to find it, and then shift everything after it down. The ordered array has a maximum size known as its capacity which is specified when it is created, and fixed from that point forward. This is the maximum number of elements that can be insert-ed into the array, if none are renove-d, before the array is full. The number of elements currently in the array is its size. Member functions .size() and .capacity() provide access to both these values. Note that an array's size is always 20 and its capacity. The size of an ordered array should be O when it is first created. Use the following class definition, supplying definitions for the the various member functions, and adding whatever private members you need

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions