java

java

Questions:
3. CleverRandomCount Logbook exercise
. (a) SimpleRandomCountisnotanefficientimplementationoftheabstractRandomCount class. Design and implement a better solution. Call this class CleverRandomClass. ?
. (b) Add a timing method to the RandomCount class, and use this to compare the efficiency of the two extensions of this class. ?
This is this (and next) week’s logbook exercise. You should include details of your solution to this exercise in your logbook. Your work will be assessed on:
• Documentation • Structure?• Naming?• Testing
Introduction:
Algorithms in general are basically procedures that solve an issue in an efficient way. Hence, as a programmer, every application or program we build should be following a very efficient organize steps in order to professional as possible, also, helping our needs of editing it that might needed in the future.
Aim:
The aim of this exercise is implement a new timer search interface that consider as a clever solution compared to given SimpleRandomCount class.
Solution:
By looking to the given codes, SimpleRandomCount class is create another array, then taking an element randomly and copy it in the new array, then start locking again in the whole array and take another element randomly expect the taken element and copy it in the new array, so it is continue like that till he finish filling the new array. As a result,this way of randomizing array elements has considered as an efficient way and takes a quite long time.

Hence, as an answer I implemented java class named CleaverRandomSearch. Basically, it is swapping the elements inside the array itself without need of creating a new array.

Figure (1.1) CleaverRandomSearch class codes page.

Figure (1.2) outline when CleaverRandomSearch class run.

Figure (1.3) Test class.

Test class used to compare a time taken by both CleaverRandomSearch and SimpleRandomCount. However, as the figure below shows the different, which is not that much 331 seconds for CleaverRandomSearch and 354 seconds for SimpleRandomCount.

Figure (1.4) Result of test class.

Conclusion:
In conclusion, on my eyes CleaverRandomSearch is actually doing much better than the SimpleRandomCount as it does not need to a second array meaning taking less time to do the function.
Week 2: Java revision and testing.
This week has no practical exercises.
Week 3: Generics:
Questions:
1. Swap Logbook question
Write a generic method to exchange two elements of an array. The method should take an array, and two integer indices into the array, and swap the two entries in the array at those indices.

TAKE ADVANTAGE OF OUR PROMOTIONAL DISCOUNT DISPLAYED ON THE WEBSITE AND GET A DISCOUNT FOR YOUR PAPER NOW!

© 2020 customphdthesis.com. All Rights Reserved. | Disclaimer: for assistance purposes only. These custom papers should be used with proper reference.