Readme_10_06

pdf

School

University of Texas, Arlington *

*We aren’t endorsed by this school

Course

3318

Subject

Computer Science

Date

Nov 24, 2024

Type

pdf

Pages

2

Uploaded by AmbassadorMule1343

Report
1 New test files provided Document created 10/6/2023 Start with a valid heap. Repeatedly add to the heap an new item that bigger than anything else in the heap. It resizes the heap 3 times: a2.txt , a2_eo.txt Try to remove from empty heap: r_empty.txt , r_empty_eo.txt Last stone weight: w21.txt , w21_eo.txt w31.txt , w31_eo.txt w41.txt , w41_eo.txt A single file loads multiple arrays. For each array it calls heapsort(), array2heap() and last_stone(). l3_shw0.txt , l3_shw0_eo.txt Tips and Fixes: 1. On 10/06 @ 8pm fixed in the heap.c file : there was a mix of spaces and tabs for indentation, which would be penalized in coding style. I fixed it now to be all tabs . 2. On 10/06 @ 8pm fixed in the heap.c file : in function remove_top(), at line 87 of the original file heap.c, I added a \n to produce a consistent output. In the updated file on the web it will show: printf("Empty heap. no remove performed. \n "); \\ Updated 10\06\2023: \n added here 3. Remember that you should NOT write C code that reads from files. It should read from the user. The input redirection, <, will make it use the file instead of the keyboard. 4. The 0 or 1 that you see at the name of some data files (e.g. i1.txt or l3_shw0.txt) indicate the value used for print_on in that file (1 or 0). 5. Since the command q ends the loop that keeps reading data, what is written after the q command, will not affect the program behavior. In some of the new files, I used that space to describe the test. E.g.
2 p 1 q what I put here is not processed. 6. In the remove_top() function, when I remove the top item, I swap the first and the last items and then decrement the heap size and call sink_down(). You will also have to do this swap (in particular to get the top item copied on the last index before decrementing the heap size ). If the array that is printed after the call to solve last stone weight (w) does not match your array, one possible cause is this. 7. For sink_down(), if the node is less than it’s children and the children are equal, the left child should be picked. See d_tie.txt 8. We will NOT test cases a case where a function is called and the array is NULL. E.g. we would not test : p 1 s d 2 25 q where s and d are called without an array being loaded. 9. For the d (decrease value) and i (increase value) tests, we will NOT test that the heap is fixed if the opposite is done. For example for d (decrease value) we will test for the case when value of a node is decreased and in travels 0, 1, or more nodes down. But we will not test a case where the d operation in fact increased the value (and the value would have to swim_up to go to the correct place). For example we will NOT run a test like this: p 1 l 10 13 9 11 7 5 10 3 2 4 6 d 2 25 i 3 1 q here the d 2 25 will replace the value at index 2 (value 11) with new value 25 which is in fact and increase in value at that index, nota decrease. Similar i 3 1 is supposed to increase the value at index 3, but it would replace value 7 with value 3 which is in fact a decrease. We will not test any of these cases. The reason is that I created the d and i commands only to test sink_down() and swim_up(). 10.
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