Question

Instead of using a parallel array to store values, one should consider converting this into an...

Instead of using a parallel array to store values, one should consider converting this into an array of objects. Briefly, list two challenges one might encounter when using parallel arrays that are solved when using an array of objects.

Homework Answers

Answer #1

Parallel arrays are an implicit data structure that uses two or more arrays to represent a singular array of records. Using Parallel array is a bad idea as it makes the code more fragile.

Whenever we want to add a new field , we need to add new array. If we want to pass the whole entity to another function, we need to pull all the items.

Secondly, in case of performing swap, we need to swap all the array pairs individually.

These can be overcome by using Array of objects.

As name implies Array of object stores the objects in array. An object can be represented as a single record in memory, so for multiple records array of objects must be created. The array not only hold the objects but can hold references to the object.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
USING JAVA ONLY - THE NEW ARRAY IS NOT JUST THE VALUES IN INCREASING ORDER Merge...
USING JAVA ONLY - THE NEW ARRAY IS NOT JUST THE VALUES IN INCREASING ORDER Merge two 1D arrays into a single array. take one value from each array at a time. The new array takes a value from array 1, than one from array two, and keeps repeating until all values are in the new array. Sample: array 1: 1,2,3,4,5 array 2: 2,4 new array: 1,2,2,4,3,4,5 Sample 2: array 1: is 8,2,4,7,2,6,2 array 2: 4,7,3 new array: 8,4,2,7,4,3,7,2,6,2
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++ 11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume First array 04 Second array Result array that one array doesn’t contain two copies of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Goal:   Manage the inventory of objects sold in an online or brick and mortar store. If...
Goal:   Manage the inventory of objects sold in an online or brick and mortar store. If you can't implement all of the features of Project described in this document, implement what you can. Start by implementing the StockItem class, and its derived classes. Then add in the InventoryManager class later. In each case, the test files must be in separate classes. UML Diagram: Use Violet or other drawing software to draw the UML diagrams of each class that you use...
C++ Goals  Build single linked lists using pointers  Learn how to manipulate linked lists...
C++ Goals  Build single linked lists using pointers  Learn how to manipulate linked lists In this lab, you will create simple single linked structures consisting of Node objects. Each node will have a pointer to the next node. You will use a head pointer to keep track of the first node in the linked list, and a tail pointer to keep track of the last node in the linked list. Set both head and tail to NULL when...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b, where a – b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a – b = 3 A = [10, 4, 6, 16, 1, 6, 12, 13] Then your method should return the following pairs: 4, 1 15, 12 13, 10 A poor solution: There are...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called keys with other objects called values. It is implemented as a Java class that uses arrays internally. 1. Theory. A map is a set of key-value pairs. Each key is said to be associated with its corresponding value, so there is at most one pair in the set with a given key. You can perform the following operations on maps. You can test if...
There are two ways to write loops: (1) iterative, like the for-loops we're used to using,...
There are two ways to write loops: (1) iterative, like the for-loops we're used to using, and (2) recursive. Your prerequisite preparation for this course should have exposed you to both, although your working knowledge of recursive loops may not be as strong as that of iterative loops. Consider the following iterative function that prints an array of characters backward: #include <iostream> #include <cstring> // print an array backwards, where 'first' is the first index // of the array, and...
Cooperative Education--Discussion Question #1--Spring, 2018 COLLAPSE SPECIAL NOTE: You will have two weeks, instead of one,...
Cooperative Education--Discussion Question #1--Spring, 2018 COLLAPSE SPECIAL NOTE: You will have two weeks, instead of one, to complete this particular discussion question. This discussion question assignment can earn you 105 huge points, depending on the quality and timeliness of your comments and how well you follow the instructions for this assignment. Within the two weeks time period you should answer my specific discussion question (all parts of it) AND also respond to at least two other students’ comments. This will...
Base Conversion One algorithm for converting a base 10 number to another base b involves repeatedly...
Base Conversion One algorithm for converting a base 10 number to another base b involves repeatedly dividing by b. Each time a division is performed the remainder and quotient are saved. At each step, the dividend is the quotient from the preceding step; the divisor is always b. The algorithm stops when the quotient is 0. The number in the new base is the sequence of remainders in reverse order (the last one computed goes first; the first one goes...