Implement the array-backed list method del_span, which accepts parameters idx and n, and removes n elements starting at index idx.
View the step-by-step solution to:

Question

1. Implement the array-backed list method del_span, which accepts parameters idx and n, and removes n elements

starting at index idx. Your implementation should not use any other array-list methods, and may only perform the following operations on the backing list (named data in the provided skeleton code):

• len(self.data) • Accessing a valid list index i, e.g., self.data[i] • self.data.append(None) • del self.data[len(self.data)-1]

E.g., calling del_span(2, 5) on the list with elements [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] results in the list being shortened to [0, 1, 7, 8, 9].

E.g., calling del_span(7, 1) on the list with elements [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] results in the list being shortened to [0, 1, 2, 3, 4, 5, 6, 8, 9].

Top Answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question