Comments (10)
Hello, I also had a question about the output in the console and asked during office hours.
Assuming you didn't modify testRuntime() in TernaryHeapQuizTest:
If you look at the line that starts with 1000 the 47 is how long it takes to add using a binary heap and the 62 is how long it takes to add using a ternary heap. The 94 is how long binary heap took to remove and 126 is how long ternary heap took to remove. All time units are in milliseconds.
from dsa-java.
Hello TFloyd. What really helped me was running the test in two different runs. Like in separate lines. If you read the documentation. I believe the first line is the time for add and the second line is the time for remove. If ran by itself. I am not sure if binary heap or trenary heap is either/or. In this case, the chart created is comparing the add methods of both binary/trenary heap, then the remove methods of binary/trenary heap.
from dsa-java.
Thanks for your guys' reponses.
Below is the code what Abner3 tries to refer to:
@SafeVarargs
final void testRuntime(AbstractPriorityQueue<Integer>... queues) {
final int begin_size = 1000;
final int end_size = 10000;
final int inc = 1000;
final Random rand = new Random();
for (int size = begin_size; size <= end_size; size += inc) {
// JVM warm-up
benchmark(queues, size, 10, rand::nextInt);
// benchmark all priority queues with the same keys
Time[] times = benchmark(queues, size, 1000, rand::nextInt);
StringJoiner joiner = new StringJoiner("\t");
joiner.add(Integer.toString(size)); // size of heap
joiner.add(Arrays.stream(times).map(t -> Long.toString(t.add)).collect(Collectors.joining("\t"))); // "add" of the input heaps
joiner.add(Arrays.stream(times).map(t -> Long.toString(t.remove)).collect(Collectors.joining("\t"))); // "remove" of the input heaps
System.out.println(joiner.toString());
}
}
I added some comments in the above code around the joiner.add
and hope it helps.
So in the end, if you are comparing 2 heaps, it will become:
size, heap1 add, heap2 add, heap1 remove, heap2 remove
from dsa-java.
Oh okay thank you all. Should the binary heap add and remove be faster than the ternary heap add and remove?
from dsa-java.
As for plotting, you can do it either way by using an Excel or some online graph tools where you can input your data.
from dsa-java.
As for which is faster, please refer to the course notebook to find the answer and I believe you can find it out!
from dsa-java.
According to the notebook log base 3(1000) for ternary > log 10(1000) binary. This is correct?
from dsa-java.
@TFloyd1989 Sorry, we can not answer the question that is directly related to quiz questions
from dsa-java.
According to the notebook log base 3(1000) for ternary > log 10(1000) binary. This is correct?
However, for binary it should be log base 2(n)
This is depicted in the textbook
A binary heap is a PQ that takes
O(logn)
for both add() and remove()
And in computer science, if the base of log
is ignored, it typically means log base 2.
from dsa-java.
Hello, I also had a question about the output in the console and asked during office hours.
Assuming you didn't modify testRuntime() in TernaryHeapQuizTest:
If you look at the line that starts with 1000 the 47 is how long it takes to add using a binary heap and the 62 is how long it takes to add using a ternary heap. The 94 is how long binary heap took to remove and 126 is how long ternary heap took to remove. All time units are in milliseconds.
@Abner3 thanks for answering this but figuring out the output format of this method is a part of assignment so I'm closing this issue.
from dsa-java.
Related Issues (20)
- [QZ1] Gradle Version? HOT 3
- Office Hours Passcode? HOT 1
- [QZ1] build.gradle, sourceCompatibility and targetCompatibility question HOT 1
- [QZ0] Didn't see the output
- [QZ0]java version
- Lecture Recordings HOT 1
- [QZ1] On "0" and "-0" as well as unit testing
- [QZ1] Regarding the Quiz1 submission
- zoom recording for 01/25 HOT 1
- [Quiz2] Submitting report on canvas?
- [HW1] How to know which specific test case we failed on and further debug? HOT 1
- [HW1] What is a sample criteria for "fast"?
- [QZ3] Testing Question
- Homework 2 Test case question
- Tries 03/01 lecture link missing
- [HW#2] Reading in the dictionary file
- [QZ5] Trie of countries?
- [HW2] Test HOT 1
- [HW3] Is it possible to know the running results of gold of MSTAllHwTest?
- [QZ9] Can an augmenting path contain cycle? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsa-java.