Computer Science > Research Paper > University of the People - JAVA CS 1103 PRWritten Assignment Unit 1 (All)
This week's assignment is Part 1: Benchmarking Sorting Algorithms from Lab 2 of this unit. Below are the code I used to test the speed of the two sorting methods. To test the time of 1000, 10000, a... nd 100000 long arrays I simply added 0 to the necessary places instead of writing a new line of code for it. The sorting functions are copied from chapter 7.4 of the textbook with a few variables changed here and there. import java.lang.Math; public class Trial1 { public static void main(String[] args) { //================================================================= ====== //creating two integer arrays with 10 slots each int a[] = new int[1000]; int b[] = new int[1000]; // using while loop to create random number and inserting it into both arrays. int i = 0; while(i != 1000) //while i is not equal to 1000 { int an = (int) (Math.random()*1000); //generate number between 0 and 1000 a[i] = an; //inserting number in to array a int bn = (int) (Math.random()*1000);//generate number between 0 and 1000 b[i] = bn; //inserting number in to array b i++; //+1 to i [Show More]
Last updated: 2 years ago
Preview 1 out of 6 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Apr 10, 2021
Number of pages
6
Written in
This document has been written for:
Uploaded
Apr 10, 2021
Downloads
0
Views
458
In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·