Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q2: Assuming that we have an array of game entries as follows (Paul, 250), (Mary

ID: 3585621 • Letter: Q

Question

Q2: Assuming that we have an array of game entries as follows (Paul, 250), (Mary, 230), (John, 200), (Vini, 150), (Max, 100) a) How many elements in the array will need to be moved to insert an entry for (Tina, 125) b) How many entries need to move if the array can hold 6 elements using the insertion sort if the array can contain a maximum of 5 elements? algorithm? Q3: What is the content of the list after the following lines of code executes on an empty circularly linked list object called C? C.add(20); C.add(30); C.advance0; C.add(19); C.advance) C.remove(); C,add(12);

Explanation / Answer

1 a) The list is sorted in descending order.

Only one element (Tina,125) needs to move to index 5 space in an array of 5 elements so (max,100) will be removed from array.

(Paul,250) , (Mary,230) , (John,200) , (Vini,150), (Tina,125)

b) Only one element (Max,100) needs to move to the right side at index 6(starting from 1) to make place for (Tina,125)

(Paul,250) , (Mary,230) , (John,200) , (Vini,150), (Tina,125) , (Max,100)

2

circular linked list

20

20 -> 30

20 -> 30 -> advance() method will go to the next address

20 -> 30 -> ->19

20 -> 30 -> -> 19-> advance() will go to the next address leaving space vacant for data

20 -> 30 -> -> 19 remove will go back to the previous address removing the space

20 -> 30 -> -> 19 -> 12

last element 12 will point to the first element 20 as it is circular linked list

------------------------<------------------

| ->20 -> 30 -> -> 19 -> 12 -> |