SEG2105-Assignment 1

docx

School

University of Ottawa *

*We aren’t endorsed by this school

Course

2105

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by DrEnergyHippopotamus29

Report
SEG2105 Assignment 1 300317493 Exercise 2 Question 1 (10 Points) Design # Pros Cons Design 1 Relatively simple which enhances maintainability. Can directly calculate Polar from Cartesian points and vice versa. Difficult making changes to code in the future. Duplicated code. The conversion is duplicated between the points. Relatively higher memory usage compared to other designs. Design 2 Uses less memory (stores only polar points). Polar points are created more efficiently. The rotatepoint() method is more efficient Simpler design Bad performance when trying to get cartesian coordinates. Creating an instance of PointCP2 and then converting to cartesian is not efficient. Hard to make changes in the future Design 3 Uses less memory (stores only Cartesian points). Cartesian points are created more efficiently. The getDistance() method is more efficient. Simpler Design Bad performance when trying to get polar coordinates. Creating an instance of PointCP3 and then converting to polar is not efficient. Hard to make changes in the future Design 4 Computational Simplicity Easier to modify in the future Highest memory usage compared to other designs. Might cause errors if modified in the future as one would need to check if every method is synchronized Design 5 Abstract class, it will be easier to modify the program in future instances. Efficiency in getting each point and its corresponding method i.e. getDistance() & rotatePoint() Most computationally efficient The need for multiple override methods can cause problems in the future. Relatively higher memory usage compared to other designs.
SEG2105 Assignment 1 300317493 Question 2 (30 Points) I conducted two experiments exactly as followed in the assignment handout. “For the first experiment, during program execution, I continuously created points and called their public methods. I measured the number of points I was able to create in t seconds. I varied t from 5 to 30 seconds in steps of 5 seconds (see Table 1). Moreover, to conduct a basic statistical analysis, I measured the number of points I was able to create in 10 seconds over 20 runs and calculated the median, maximum, and minimum number of points created (see Table 2). Tables 1 and 2 reveal that I was able to consistently create more objects for design compared to design. For the second experiment, during program execution, I created m points and called their public methods. I measured the amount of time (in milliseconds) required to create and call all m points (see Table 3). Furthermore, to conduct a basic statistical analysis, I measured the amount of time (in milliseconds) required to create 100,000 points over 20 runs and calculated the median, maximum, and minimum amount of time required (see Table 4). Tables 3 and 4 summarize my results which reveal that I was able to complete the task faster for design compared to design.” (Page 2, Assignment 1 Guidelines) Based on the results of my experiments, I conclude that in terms of the number of points generated and the time needed to produce and call points, Design 5 outperforms Design 1. A performance analysis confirms that Design 5 outperformed Design 1 in the carried-out experiments. Table 1 – Number of points created and called with respect to time for both designs. Time (seconds) Number of Points Created and Called Design 1 Design 5 5 168149964 258131488 10 337059980 514890076 15 506658553 608377204 20 673898543 811251901 25 829975233 1007533919 30 977819906 1538752931 Table 2 – Statistical analysis for the number of points created during 10 seconds of execution Design Number Median (Points) Maximum (Points) Minimum (Points) Design 1 321140257 331866299 318154769 Design 5 383117313 490622076 365191502
SEG2105 Assignment 1 300317493 Table 3 – Time necessary to create and call m number of points Number of Points Time Elapsed in milliseconds Design 1 Design 5 100 0 0 1000 0 0 10000 1 1 100000 5 4 1000000 50 15 10000000 163 54 Table 4 – Statistical analysis for the time (milliseconds) required to create 100,000 points Design Number Median (milliseconds) Maximum (milliseconds) Minimum (milliseconds) Design 1 5 9 4 Design 5 4 6 2 Exercise 3 (20 points) Elements ArrayList Linked List Array
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
SEG2105 Assignment 1 300317493 Adding elements Calculating the sum of elements Adding elements Calculating the sum of elements Adding elements Calculating the sum of elements 10000 1 millisecond 1 millisecond 1 millisecond 2 milliseconds 0 milliseconds 0 milliseconds 100000 6 milliseconds 5 milliseconds 5 milliseconds 5 milliseconds 2 milliseconds 3 milliseconds 1000000 17 milliseconds 9 milliseconds 50 milliseconds 9 milliseconds 21 milliseconds 5 milliseconds 10000000 136 milliseconds 14 milliseconds 495 milliseconds 33 milliseconds 343 milliseconds 8 milliseconds 100000000 1312 milliseconds 64 milliseconds java.lang.OutOf MemoryError: java.lang.OutOf MemoryError: 4069 milliseconds 38 milliseconds 1000000000 java.lang.OutO fMemoryError: java.lang.OutO fMemoryError: java.lang.OutOf MemoryError: java.lang.OutOf MemoryError: 39346 milliseconds 570 milliseconds Conclusion There are several important factors to consider when comparing how well ArrayList, LinkedList, and Array perform while adding elements and calculating the total sum of those elements. ArrayList: An ArrayList can get the add items efficiently in most situations. It's also a great option for situations involving relatively large datasets and frequent element access. One drawback of ArrayList is that it struggles with very big datasets, as seen by the sharp increase in processing times and occurrences of Out of Memory Errors for items with 100,000,000 and 1,000,000,000 entries. LinkedList: A LinkedList is consistent but performs slowly while adding entries and computing sums. It also consumes more memory than other data sets. Array: Out of the three, Arrays are the most memory-efficient, however, they may cause problems with huge datasets and, for larger datasets, resizing processes take longer. One advantage of arrays is that they add items efficiently, especially for smaller datasets.