Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A . Ordered Record Array ( 3 0 pt ) Modify the OrderedRecordArray class ( Listing 2 - 8 and Listing 2 - 9 )
AOrdered Record Array pt
Modify the OrderedRecordArray class Listing and Listing so that requests to delete records that have duplicate keys correctly find the target records and delete them if present.
Make sure you test the program thoroughly so that regardless of the number of records with duplicate keys or their order within the internal list, your modified version finds the matching record if it exists and leaves the list unchanged if it is not present.
B OddEven Sort pt
Another simple sort is the oddeven sort. The idea is to repeatedly make two passes through the array. On the first pass, you look at all the pairs of items, aj and aj where j is odd j If their key values are out of order, you swap them. On the second pass, you do the same for all the even values j
You do these two passes repeatedly until the array is sorted. Add an oddEvenSort method to the Array class in the SortArray.py module Listing Perform the outer loop until no swaps occur to see how many passes are needed; one pass includes both oddpair and evenpair swapping. Make sure it works for varying amounts of data and on good and bad initial orderings.
After testing how many passes are needed before no more swaps occur, determine the maximum number of passes of the outer loop based on the length of the input array.
The oddeven sort is actually useful in a multiprocessing environment, where a separate processor can operate on each odd pair simultaneously and then on each even pair. Because the odd pairs are independent of each other, each pair can be checkedand swapped, if necessaryby a different processor. This makes for a very fast sort..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started