Implementing a circular data structure using lists


Category:
Scripts
Python
Requirements:
Seller:
Price:
-
System:
Rating:
4.6
License:

Description - Implementing a circular data structure using lists



In some applications, it`s advantageous to be able to define a circular data structure (a structure in which the last element is a pointer to the first). Python lists make it easy to make such a beast. A list is an ordered sequence of elements, so implementing a "ring" as a Python list is easy. "Turning" the ring consists of removing the last element from the list and placing it in the list`s beginning slot. We can encapsulate this behavior in a class, which is shown below as the "Ring" class.



More in Python-Implementing a circular data structure using lists

Last Element Circular Data Circular Data Structure