Preview

Lab1

Good Essays
Open Document
Open Document
911 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Lab1
Lab 03
Simple Sorting Methods (Buble Sort, Selection Sort, Insertion Sort)
1. ssObjectives
a. Know how, in reality, three simple sorting methods work.
b. Know how to use analysis tool to compare performance of sorting algorithms

2. Problem statement
a. Write a Java program to measure time (in seconds) needed for each simple sorting algorithms applying on the same random array of integer values. Sizes of arrays are accordingly 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000 and 50000. Each time, you write down the measured time in following table.
Table 1 - Experiment 1: Simple sorting on random data

Bubble Sort
Selection Sort
Insertion Sort
10000
556ms
210ms
149ms
15000
1257ms
467ms
341ms
20000
2231ms
842ms
608ms
25000
3486ms
1297ms
937ms
30000
5110ms
1899ms
1395ms
35000
6906ms
2564ms
1871ms
40000
9294ms
3472ms
2511ms
45000
11514ms
4273ms
3087ms
50000
14553ms
5467ms
3871ms

b. Based on above table, give your comments on real complexity of the three simple sorting algorithms. (Remember, all of them are O(n^2) in theory).

3. Instruction: (Follow instructions step-by-step)
a. Take a look at sample source files and read it carefully. There are three files:
i. Array.java: contains class Array, ii. TimeUtils.java: contains class TimeUtils and iii. SortingApp.java: contains main() method.

Class Name
Typical Method
Notes
Array.java
Array
public void randomInit(int numElements)
Create an array of random long-integer values with size specified by numElements.

public void bubbleSort()
Bubble sorting method.

public void selectionSort()
Selection sorting method. You will add its code by yourself (textbook).

public void insertionSort()
Insertion sorting method. You will add its code by yourself (textbook).
TimeUtils
.java
TimeUtils
public static long now()
Get current time in milli-seconds since epoch.
SortingApp.java
SortingApp public static void main(String[] args)
Main method used to measure time.

Class Diagram
b. The Array class is highly similar

You May Also Find These Documents Helpful

  • Good Essays

    Lab 5

    • 2594 Words
    • 10 Pages

    In gymnosperms, pollination is the transfer of pollen (Fig. 2) from male cones (where pollen is produced) to female cones, which house eggs. In these plants, pollen is carried from male cones to female cones by wind - gymnosperms were the first plants to evolve that did not need free water to transfer sperm to egg, and were therefore able to thrive in terrestrial habitats. Pollen grains are also protected by tough coats. After fertilization, seeds are produced with developing embryos…

    • 2594 Words
    • 10 Pages
    Good Essays
  • Powerful Essays

    lab 1

    • 636 Words
    • 3 Pages

    Are there any safety concerns associated with this exercise? If so, list what they are and what precautions should be taken.…

    • 636 Words
    • 3 Pages
    Powerful Essays
  • Good Essays

    lab 4

    • 527 Words
    • 3 Pages

    The shielding also makes the cable heavier and stiffer. Thus, it is more difficult to handle.…

    • 527 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Lab 3

    • 789 Words
    • 4 Pages

    To predict caloric expenditure you can plug in a measured heart rate and calculate the predicted VO2 (L/min). Then using the predicted VO2 and an estimated thermal equivalent (4.825 kcal/LO2), you can estimate the caloric expenditure. Nonetheless, each individual’s heart rate varies. These can be attributed to gender differences, physical activity and physical training. So, if the person is of the same gender and is as healthy as you are and does the same amount of exercise then it could be possible to use their regression line to estimate your own caloric expenditure however the limitations would be possibly the difference in size of the lungs for the estimation of VO2 max. Weight would be important, as it is required to calculate the predicted caloric expenditure. However if your weight can be misleading because one can simply weigh more because they are taller, not because they are bigger. Height does not play such an important role. When you are taller, your body does need to pump more blood throughout the body. This means that they will pump more blood per beat but not that they would have a higher heart rate. It is important to remember that a linear relationship exists between…

    • 789 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 1

    • 567 Words
    • 3 Pages

    Attacker would avoid detection by covering tracks step of the hacking process where they cover up their tracks in the system they hacked into.…

    • 567 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Lab 2

    • 639 Words
    • 2 Pages

    with varying amounts of data. In order for scanners to detect this type of virus,…

    • 639 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    lab 2

    • 398 Words
    • 2 Pages

    1. Compare the hash values calculated for example.txt that you documented during this lab. Explain in your own words why the hash values will change when the data is modified.…

    • 398 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Lab2

    • 520 Words
    • 3 Pages

    On your own and without assistance, complete this Lab 2 Answer Form electronically and submit it via the Assignments Folder by the date listed on your Course Schedule (under Syllabus).…

    • 520 Words
    • 3 Pages
    Good Essays
  • Good Essays

    LAB 5

    • 31937 Words
    • 128 Pages

    experiences. The laboratory manual included with a LabPaq is intended for the sole use by that…

    • 31937 Words
    • 128 Pages
    Good Essays
  • Good Essays

    Lab 4

    • 575 Words
    • 3 Pages

    1.List four cell structures that were common to both plant and animal cells. (4 points)…

    • 575 Words
    • 3 Pages
    Good Essays
  • Good Essays

    lab 5

    • 718 Words
    • 3 Pages

    What is Authorization and how is this concept aligned with Identification and Authentication? Authorization is a set of rights defined for a subject and an object; this concept is aligned with Identification and Authentication because these are the 3 steps to the access control process…

    • 718 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Lab 1

    • 414 Words
    • 2 Pages

    4. Why would you use a tool like DevManView while performing a computer forensic investigation?…

    • 414 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    lab 4

    • 451 Words
    • 2 Pages

    Compare the portions that address Internet and e-mail access of at least three different companies.…

    • 451 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    lab 5

    • 337 Words
    • 1 Page

    2 Have the subject blow air through the straw into the water and keep blowing into the water for 2 minutes inhaling between exhalations. The subject should be breath as normal as possible while doing this activity. Measure and record the pH of the water in the glass.…

    • 337 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    lab 5

    • 440 Words
    • 2 Pages

    How many different protocols (layer 3, layer 4, etc.) did your protocol capture session have? What function in Wireshark provides you with a breakdown of the different protocol types on the LAN segment?…

    • 440 Words
    • 2 Pages
    Satisfactory Essays