Sale!

Assignment #2 – 8000 randomly generated integers

$30.00

Category:
Rate this product

Assignment #2 (10 points)

1. For this problem our task is to store 8000 randomly generated integers in the range of 1 to 1000 inclusively using different languages/methods.

Task 1: C++. declare a stack dynamic array and store randomly generated numbers one by one to the array. Sample stack dynamic array declaration:
const int SIZE = 8000;
int numbers[SIZE];
Task 2: C++. Same as above but using a heap dynamic array, i.e.
int *num_ref = new int [SIZE];
Task 3: Java. Same as above but now using a Java array.
Task 4: Same as above but now using a Java ArrayList.
Note: in all above tasks store element one by one.

Calculate the average computation time for each of above tasks by running the code 10 times and then take the average of the 10 test runs.

(1) Task 1 vs. Task 2. Which one is easier to program? Which task runs faster or are they similar in performance? Why? i.e. Describe your observation and then briefly justify your answer.
(2) Task 3 vs. Task 4. Which one is easier to program? What’s the advantage of using ArrayList? Which task runs faster or are they similar in performance? Why? i.e. Describe your observation and then briefly justify your answer.

2. C++, Java, Python. Assume we have two sequences of values S1 containing 1, 5, 3, 6, 7, 8 while S2 containing 2, 5, 6, 9, 7. We’d store these two sequences as sets and performance set intersection and set difference. Write C++, Java, Python codes to do that respectively. Compare and contrast the readability and writability.

Open chat
Need help?
Hello
Can we help you?