Write a class to represent a dynamically sized array

Assignment Help Data Structure & Algorithms
Reference no: EM131320343

CPSC Program

This is the program

Write a class to represent a dynamically sized array of integers. Name it DynArray.

submit: a file named dynarray.h that contains all of your class code

Class specifications:

Private data members:

data arraysize datasize

- a pointer to integer array data

- an integer representing the array size (allocated space) - an integer representing the amount of data stored in the array Public member functions:

default constructor: Sets the array size to be 10 elements, the data size to be 0, and dynamically allocates the 10 element array space.

constructor receiving size: Checks the size parameter value to make sure that it is a positive (>0) value. If the value is positive, it
becomes the array size.

If the value is not legal, the array size should be set to 10. After setting the array size, the data size is set to 0, and the dynamic allocation is performed.

copy constructor: Receive one DynArray object as a parameter and make the new object a copy of that object with its own separately allocated memory space, but with the same sizes and same data.

destructor: Dynamically de-allocate the array space and set the pointer value to NULL.

setArraySize: This function receives a size value. If the parameter value is

greater than the existing array size, change the array size, allocate a new array space, copy all of the data values to the new space, and deallocate the old array space.

If the size value is invalid (smaller than current size), do nothing.

getArraySize: Return a copy of the array size field.

getDataSize: Return a copy of the data size field.

addValue: Receives an integer value. If there is currently room in the

allocated array space, then store the value into the array. If there is not space, then relocate the array to another location with twice as much space as before, and then store the parameter value into the array.

= operator: Receives one DynArray object as a parameter and makes the current object a copy of that parameter object with its own separately allocated array space. Make sure to de-allocate the current array space before dynamically allocating a new one.

Reference no: EM131320343

Questions Cloud

Discuss the difference in social structure and social class : There are many theories regarding the social construction of serial killers. Discuss the difference in social structure, social class, social process, neutralization, social control, and labeling theories as they relate to serial killers
Implement a 3-to-8 decoder using two 2-to-4 decoders : Implement a 3-to-8 decoder using NOT and AND gates in Logisim. Show that it is correct by showing it generates the same output as a 3-to-8 Decoder found in the Plexors menu of Logisim.
Discuss the beginnings of the cold war : Discuss the beginnings of the Cold War. From the position of a Soviet ruler, how might you have viewed the situation following WWII? How did the Truman administration attempt to handle it? (Include as many of the following as you can: containm..
Defining the problem and analysis of the situation : US photovoltaic company panel installation in Asia.US clothing retailer into Central America. Coffee shop entry into western Africa.Your analysis should be of adequate length to address all areas.
Write a class to represent a dynamically sized array : Write a class to represent a dynamically sized array of integers. Name it DynArray. An integer representing the array size (allocated space) - an integer representing the amount of data stored in the array Public member functions:
What is the new equity value of tyler : What is the new equity value of Tyler on its balance sheet - How much goodwill will Talmadge enter on its balance sheet as a result of this merger?
How use of digital media was used to communicate information : In this assignment, you will locate examples of how the use of digital media was used to communicate information to achieve a specific goal of an organization or individual.
Explain the contributions of three abolitionists : Name and explain the contributions of three Abolitionists that supported and helped African Americans before the Civil War fight slavery?
Toward american independence : What were the key events that marked the move toward American Independence?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Program to implement a stack and a queue

Write a C/C++ program to implement a stack and a queue as applications of LL.

  Consider a queue data structure

Consider a queue data structure, where the two operations of interest are enqueue (at the back of the queue) and dequeue (from the front of the queue). A queue is thus a FIFO (first in-first out) structure. Suppose we implement a queue by using tw..

  Calculate the usable area in square feet of house.

Calculate the usable area in square feet of house. Assume that the house has a maximum of four rooms, and that each room is rectangular.

  Design algorithm that computes how many steps it will take

Will the viruses eventually kill all the bacteria? If so, design an algorithm that computes how many steps it will take. How does the running time of your algorithm depend on n?

  Briefly define the caesar cipher

What are the two basic functions used in encryption algorithms and how many keys are required for two people to communicate via a cipher?

  Data analysis and application template

Data Analysis and Application Template.

  Write at least a one-page critic of the cisc approach

write at least a one-page critic of the CISC approach showing its disadvantages while showing the advantages of the RISC approach. You may want to use real-life example machine performance as a support for your support of the RISC philosophy.

  Determine the number of four-vertex tournaments

A. Draw all the 3-vertex tournaments whose vertices are u,v,x.B. Determine the number of 4-vertex tournaments whose vertices are u,v,x,y.

  Suppose you develop an algorithm that processes the first

consider searching algorithms on the following array of data 22 21 9 4 16 2 10 14 20 31 26 19 17 28 8 13 suppose you

  Calculate the size of the state space as a function of n

n vehicles occupy squares (1, 1) through ( n , 1) (i.e., the bottom row) of an n × n grid. The vehicles must be moved to the top row but in reverse order

  Discuss the advantages of declaring and instantiating data

Discuss the advantages of declaring and instantiating data in multidimensional arrays. Show an example that you can use in one of your programs or any program.

  Define difference between algorithm and heuristic

Please explain in detail the Difference Between the following terms Algorithm and Heuristic

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd