bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 6PP

Chapter 9, Problem 6PP, One problem with dynamic arrays is that once the array is created using the new operator, the size

One problem with dynamic arrays is that once the array is created using the new operator, the size cannot be changed. For example, you might want to add or delete entries from the array as you can with a vector. This project asks you to create functions that use dynamic arrays to emulate the behavior of a vector.

First, write a program that creates a dynamic array of five strings. Store five names of your choice into the dynamic array. Next, complete the following two functions:

string* addEntry(string *dynamicArray, int &size, string

newEntry);

This function should create a new dynamic array one element larger than dynamicArray, copy all elements from dynamicArray into the new array, add the new entry onto the end of the new array, increment size, delete dynamicArray, and return the new dynamic array.

string* deleteEntry(string *dynamicArray, int &size, string

entryToDelete);

This function should search dynamicArray for entryToDelete. If not found, the request should be ignored and the unmodified dynamicArray returned. If found, create a new dynamic array one element smaller than dynamicArray. Copy all elements except entryToDelete into the new array, delete dynamicArray, decrement size, and return the new dynamic array. Test your functions by adding and deleting several names to the array while outputting the contents of the array. You will have to assign the array returned by addEntry or deleteEntry back to the dynamic array variable in your main function.

Blurred answer
Students have asked these similar questions
Help writing a program in c++ that asks a user for a number (variable num) and then takes that number input to print out the nth term of a sequence? The sequence begins with 1 and then every number after is a prime factor of 3, 4, or 6. This needs to be done without using vectors or arrays.   .   .   .   For example:   Sequence is : 1, 3, 4, 6, 8, 9, 12, 16, 18, 20, ... (cont.)   User input (num) is : 6   Output : 12 (6th term)   .   .   Please add comments explaining the code for better understanding if possible, thank you!!
Write in a programming language (PL), a program to fill an NxN two- dimensional array, in a circular (spiral) pattern, with numbers from 1 to N2 as described below. You can do that by writing first the following functions/procedures which you will call in the main program. The procedure FillRowForward(A, top, left, right, z) which takes the array A the top, left and right as parameters and iterates through top row from left to right to fill the row. z is as used in the algorithm.
Write a function called largest_sum_sequence() that accepts an array of signed integers and the number of items in the array as parameters, and returns the largest sum of a sequence of numbers in the array. A sequence is defined as a single item or multiple items that are in consecutive adjacent memory locations. Example 1: 9  3  -1  7 -12                   largest sum in sequence is 18 [9, 3, -1, 7] Example 2: -77  3  -2  1                      largest sum in sequence is 3 [3]
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License