Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Advanced Algorithms - Assignment 1

Name: Tanay Gangey


USN: PES1201700144

Instructions:
● This document must be submitted along with your implementation file.
● You are required to run at least 3 test cases with your implementation and
fill in the tables given.
● You may add more columns in case you have run more test cases
● Reallocation threshold is the percentage of the array filled after which your
implementation reallocates memory
● Deallocation threshold is the percentage of the array emptied after which
your implementation deallocates memory.
● Vary the thresholds in the test cases and note the time taken for the basic
operation
● The final section is optional and can be used if you would like to give the
evaluators additional information about your assignment

1) Dynamic Table with Structure Hacking

Test Case 1 Test Case 2 Test Case 3

Reallocation 1 1 0.5
Threshold

Deallocation 0.25 0.5 0.25


Threshold

Number of times 9 13 11
copy was called

Total time 443762ns 522397ns 484557ns

Average time 8875.24ns 10447.94ns 9691.14


taken

2) Dynamic Table without Structure Hacking


Test Case 1 Test Case 2 Test Case 3
Reallocation 1 1 0.5
Threshold

Deallocation 0.25 0.5 0.25


Threshold

Number of times 9 13 11
copy was called

Total time 482491ns 610701ns 481640ns

Average time 9649.82ns 12214.02ns 9632.80ns


taken

3) Splay Tree

Test Case 1 Test Case 2 Test Case 3

Number of 67 63 71
rotations

Total time 46026ns 23135ns 60115ns

Average time 1841ns 925ns 2404ns


taken

4) Additional details:
For dynamic table in both implementations I’m first checking the size
against the capacity (and shrinking array if needed) followed by deletion,
instead of first deleting then shrinking the array, moreover:
Test 1: New capacity= ½ * original capacity, N(pushes) = N(pops) = 25
Test 2: New capacity = ¾ * original capacity, N(pushes) = N(pops) = 25
Test 3: New capacity= ½ * original capacity, N(pushes) = N(pops) = 25

You might also like