Questions tagged [parallel-arrays]

Use for questions about using in separate array per field (I.e. `name[10], subject[10], grade[10]`.) to store structured records instead of array of objects with fields/properties.

This tag is for questions that concern usage of multiple (parallel) arrays to store records in array-per-field manner (vs. using classes to store fields of an entity together and than have a single array of such entities). See Wikipedia for more information.

Example of parallel arrays (JavaScript-like language):

   var names = ["Bob", "Alice"];
   var subject = ["Crypto", "Compression"];
   var grades = [9002, 9001];

Same data as objects:

   var students = [
     {name:"Bob", subject: "Crypto", grade: 9002},
     {name:"Alice", subject: "Compression", grade: 9001}
   ];

Cases when you would use parallel arrays:

  • arrays is the only data structure you know or "should" know depending on how far you in the programming course. If that is the case make sure to clearly spell out in the question, especially if assignment in question calls for using arrays.
  • your specific case shows significant benefits of using parallel array to store the data. Add reasoning and, ideally, performance measurements to the question. Expect alternative suggestions to represent the data as valid answers.
71 questions
0
votes
0 answers

Parallel Arrays Parent-Child Pairs C++

I'm working on a program that sorts children alphabetically and lists their parents. It should allow one to enter a parent name, the number of children, and then the childrens's names. The output is supposed to look like this: This program prints…
user5354764
0
votes
1 answer

need help to write this code to parallel arrays in classic ASP

if anyone can please help to convert this if else statements in to parallel array to find out calculate the discounts. Parallel Arrays is a data structure for representing arrays of records. It keeps a separate, homogeneous array for each field of…
pan
  • 53
  • 8
0
votes
0 answers

Outputting array values with a constant size declarator

In my program 3 out of the 4 functions will not run all the way through and it seems to have something to do with my arrays. They all seem to fail when it tries to out put the array that contains names. I was wondering if I could some how be trying…
0
votes
3 answers

How to retrieve an element from an array based on an input?

I am currently working on a program and I was wondering if there was anyway to input an element FROM an array and find an element in the same location of a parallel array. string names[3]={"Jim", "John", "Jeff"}; int num[3]={1,2,3}; cout<<"Enter…
0
votes
2 answers

C++ Parallel Arrays

In this Parallel Array I can not see or figure out why I am printing the memory address instead of the values Entered. I ask the C++ gods to enlighten me and Point me to some good tutorials about this issue so that I can learn from. Code is…
0
votes
2 answers

divide parallel arrays C++

I have a question about dividing parallel arrays. I'm fairly new to C++. In my program I'm dividing parallel arrays (atBats[] and hits[], and storing the results in an empty array (batAvg[]. When I divide, the new array remains blank even though the…
0
votes
1 answer

How to split a full name into two strings without using split method and storing the two strings into two parallel arrays

So my goal here is to pull the first name and last name from a full name entered into a textbox. I think I have pulled the first name correctly but I am having issues pulling the last. I do not want to use the Split method. Then I am going to store…
Samantha
  • 3
  • 2
0
votes
2 answers

Selection Sort Parallel Arrays in ++

Disclaimer: I know that parallel arrays are awful and should be avoided and that selection sort is not the most efficient sort, but in this case that's the way the boss man wants it done. I have looked at a lot of different websites and none that…
Oryn
  • 5
  • 1
  • 6
0
votes
3 answers

How can I access the full contents of a parallel array in java?

I am trying access the full contents of a parallel array by having the user enter an identification number. The array only seems to return results for the first four items [0-3]. The remainder are returned as not found. Using Eclipse, I tried to…
noSpaces
  • 1
  • 2
0
votes
6 answers

Comparing With an ArrayList

My program calls for being able to delete a name and number from a phone book. I have gotten the deleting to work but it only deletes the index from the ArrayList that the text box corresponds to. I need to be able to delete both the name and the…
0
votes
3 answers

Check if index of one array is equal to index of another

Basically I have two arrays, One containing 1-30 in french and the other containing 1-30 in english. What i've been trying to do is check if the user picks the right translation for the french number. This is done in the format of a select menu. 5…
James111
  • 15,378
  • 15
  • 78
  • 121
0
votes
1 answer

Searching Names and phonenumbers

mine is homework question in response to the previous Question i posted on this site: i redid the code to the following: import re people = ["Karen", "Peter", "Joan", "Joe", "Carmen", "Nancy", "Kevin"] phonenumbers = ["201-222-2222",…
0
votes
0 answers

selection sort error with 3 parallel arrays in c++

Am using 3 parallel arrays and using a selection sort that is to sort by miles in descending order. It does sort in descending order but when for example i enter data in the input file as follows: NC 33.9 5 VA 22.2 0 etc. Then the program will…
user3317020
  • 45
  • 1
  • 2
  • 10
0
votes
2 answers

c++ reading data from input file into 3 parallel arrays based on data type

Having trouble sorting the data in the input file into the designated array. The input file contains a string, double, and int. TN 54.5 7 KY 65.6 23 PA 123.3 30 etc. There are 14 lines of type string, double, int data types. The data is to be…
user3317020
  • 45
  • 1
  • 2
  • 10
0
votes
1 answer

how to write a parallel array

hi everyone I'm just curious on how one would write a code for an array that will sort indexes in order to match a previous array's inputs. Example of what i mean: If array 1 had inputs in this order: 1,2,3,4 How the indexed variables would look…
CriCri
  • 191
  • 1
  • 10