Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Set Up 1. Make a new main class called IA4_ParallelBubbleSort_LastName.java. 2. Copy an applicable sort method from a previous assignment and then alter it to

 



Set Up 1. Make a new main class called IA4_ParallelBubbleSort_LastName.java. 2. Copy an applicable sort method from a previous assignment and then alter it to take in a String Array for sorting plus a double array and a second String array. It should then sort the first STRING array and update the other 2 arrays to match. 3. Download the "PeriodicTableData" ZIP folder from D2L, extract it, then place the extracted folder, into a "Data" folder, in your assignment project folder. (You can find the location of your assignment project folder by either hovering your cursor over the project, or right-clicking -> Properties -> Sources -> Project Folder:)



Main Method a) Make and load the data for the following arrays, each of which has a corresponding file:

  • Names (from the elementNames.txt file)
  • Atomic weights (from the elementWeights.txt file)
  • Symbols (from the elementSymbols.txt file)

You will need to use the loadArr() methods from the Files.java class we used in the Data Structures module from Comp. Sci. 20. You can find the Files class, along with Example 5: Countries in the "Old Examples and Video Lessons from the Comp Sci 20 Data Structures Module" folder on D2L. Feel free to copy the relevant arrays into your program, or just refer to them in the Files class. Finally, make sure your parameters for the methods look like "Data/PeriodicTableData/elementNames.txt". If you use something different, your code won't work properly when Ms. Wiebe marks it. Check with her if you are struggling with this.

b) Print all the data, one array per line, elements separated by commas. c) Sort the data by the names array. d) Print all the data again. e) Ask the user for an element name. f) Run a binary search on the names array and then print the atomic weight and symbol. g) Sort it again, this time by symbol. You should be able to use the same search method and just pass in the parameters in a different order. h) Repeat steps e and f but asking and searching for the symbol this time.





Parallel Bubble Sort Example code:

public class Ex1_BubbleSortParallelArrays { public static void main(String[] args) {

String[] courses = {"Math", "Social", "Science", "English"}; String[] dates ={"19/06/19", "24/06/19", "21/06/19","20/06/19"}; boolean[] isMorning = {true, true, false, false}; int[] room = new int[4]; room[0] = 202; room[1] = 134; room[2] = 220; room[3] = 142; sortByRoom(courses,dates,isMorning,room); for (int i = 0; i < courses.length; i++) { System.out.println(room[i] +" " + courses[i] + " " + dates[i]); } }//end main public static void sortByRoom(String[] courses,String[] dates,boolean[] isMorning, int[] room ){ boolean swap = true; while (swap){ swap = false; for (int i = 0; i < room.length-1; i++) { if(room[i] > room[i+1]){

int temp = room[i]; room[i] = room[i+1]; room[i+1] = temp;

String temp2 = courses[i]; courses[i] = courses[i+1]; courses[i+1] = temp2;

temp2 = dates[i]; dates[i] = dates[i+1]; dates[i+1] = temp2;

boolean temp3 = isMorning[i]; isMorning[i] = isMorning[i+1]; isMorning[i+1] = temp3;

swap = true; } } } }//end sortbyRoom }//end class


The zipfile (I am not sure how put the zipfile in the questionso here, also there 3 different text documents)


{

Hydrogen Helium Lithium Beryllium Boron Carbon Nitrogen Oxygen Fluorine Neon Sodium Magnesium Aluminum Silicon Phosphorus Sulfur Chlorine Argon Potassium Calcium Scandium Titanium Vanadium Chromium Manganese Iron Cobalt Nickel Copper Zinc Gallium Germanium Arsenic Selenium Bromine Krypton Rubidium Strontium Yttrium Zirconium Niobium Molybdenum Technetium Ruthenium Rhodium Palladium Silver Cadmium Indium Tin Antimony Tellurium Iodine Xenon Cesium Barium Lanthanum Cerium Praseodymium Neodymium Promethium Samarium Europium Gadolinium Terbium Dysprosium Holmium Erbium Thulium Ytterbium Lutetium Hafnium Tantalum Wolfram Rhenium Osmium Iridium Platinum Gold Mercury Thallium Lead Bismuth Polonium Astatine Radon Francium Radium Actinium Thorium Protactinium Uranium Neptunium Plutonium Americium Curium Berkelium Californium Einsteinium Fermium Mendelevium Nobelium Lawrencium Rutherfordium Dubnium Seaborgium Bohrium Hassium Meitnerium Darmstadtium Roentgenium Copernicium Nihonium Flerovium Moscovium Livermorium Tennessine Oganesson }


{

1.007 4.002 6.941 9.012 10.811 12.011 14.007 15.999 18.998 20.18 22.99 24.305 26.982 28.086 30.974 32.065 35.453 39.948 39.098 40.078 44.956 47.867 50.942 51.996 54.938 55.845 58.933 58.693 63.546 65.38 69.723 72.64 74.922 78.96 79.904 83.798 85.468 87.62 88.906 91.224 92.906 95.96 98 101.07 102.906 106.42 107.868 112.411 114.818 118.71 121.76 127.6 126.904 131.293 132.905 137.327 138.905 140.116 140.908 144.242 145 150.36 151.964 157.25 158.925 162.5 164.93 167.259 168.934 173.054 174.967 178.49 180.948 183.84 186.207 190.23 192.217 195.084 196.967 200.59 204.383 207.2 208.98 210 210 222 223 226 227 232.038 231.036 238.029 237 244 243 247 247 251 252 257 258 259 262 261 262 266 264 267 268 271 272 285 284 289 288 292 295 294

}


{

H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og

}

Helpful Video: https://youtu.be/Fs_elYHrTHU

Step by Step Solution

3.33 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

To tackle this task lets break it down step by step Create the IA4ParallelBubbleSortLastNamejava main class You can create a new Java class named IA4ParallelBubbleSortLastName and include a main metho... 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

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions