Question: Implement count_pairs Given the PyDev module List_array.py, implement the count_pairs method. This method counts the number of pairs in a List. A pair consists

Implement count_pairs Given the PyDev module List_array.py, implement the count_pairs method. This method

Implement count_pairs Given the PyDev module List_array.py, implement the count_pairs method. This method counts the number of pairs in a List. A pair consists of two List elements with the same value beside each other in the List. Any run of n elements with the same value counts as n-1 pairs. The following example shows a List with a triplet (three 5s in a row) and a pair (two 6s), thus the count is three pairs: source: [3, 5, 5, 5, 8, 6, 6, 9] source.count_pairs() -> 3 Requirements . This method must extend the List class definition. You should be coding it at the lowest possible level. i.e. you should be working directly with _values for the List involved, not using high-level / public methods. . Do not add any imports to the List class and remove any bad imports added by mistake. . Do not create new nodes or delete existing nodes . Do not use extra data structures, such as a Python list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the countpairs method as described you can extend the List class definition and work di... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!