You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Lafore's Java applet, there was a radio button to allow or disallow duplicate values in the array. That concept needs to be added in order to show its impact on find and delete operations (and maybe insert as well).
Add a checkbox with the label "Duplicates Allowed" that is initially unchecked and enabled for use. When it is checked, the find function should find all values that match the input search value. Keep the highlight on all matching values after scanning the full array. Similarly, the delete function should delete all matching values. This should be done by changing the algorithm for deleting an item to
initialize a shift amount to 0
initialize an index pointer to 0
while the index pointer is less than the number of elements in the array:
compare the item at the index with the value to delete
if the values match,
remove the current item with an animation
increment the shift amount
if the values don't match
if the shift amount is greater than 0, shift the indexed cell by the shift amount
increment the index pointer
while the shift amount is greater than 0:
decrement the index pointer
clear the cell indexed by the pointer (reducing the number of active elements by 1)
decrement the shift amount
While it might be wise to include a check for duplicates before inserting a new value when the checkbox is unchecked, don't implement one. There will be some exercises for students to do to see what happens if duplicates are inserted when the data structure is not expecting them.
Place the checkbox in a pane below the 4 other operations (find, insert, delete value, and delete rightmost). It's an option that applies to all the the operations, so it can stay inside the labeled "Operations" box.
Highlighted items that remain after a find operation is completed should be cleared before starting a new find, insert, or delete operations.
The text was updated successfully, but these errors were encountered:
JMCanning78
changed the title
Add a Duplicates Allowed checkbox
Add a Duplicates Allowed checkbox in Array.py
Mar 5, 2019
In Lafore's Java applet, there was a radio button to allow or disallow duplicate values in the array. That concept needs to be added in order to show its impact on find and delete operations (and maybe insert as well).
Add a checkbox with the label "Duplicates Allowed" that is initially unchecked and enabled for use. When it is checked, the find function should find all values that match the input search value. Keep the highlight on all matching values after scanning the full array. Similarly, the delete function should delete all matching values. This should be done by changing the algorithm for deleting an item to
While it might be wise to include a check for duplicates before inserting a new value when the checkbox is unchecked, don't implement one. There will be some exercises for students to do to see what happens if duplicates are inserted when the data structure is not expecting them.
Place the checkbox in a pane below the 4 other operations (find, insert, delete value, and delete rightmost). It's an option that applies to all the the operations, so it can stay inside the labeled "Operations" box.
Highlighted items that remain after a find operation is completed should be cleared before starting a new find, insert, or delete operations.
The text was updated successfully, but these errors were encountered: