Compact String using Doubly Linked Lists
I am struggling with this assignment. I can provide py files for linked lists so you can maintain consistently. Please help!
In this question, we will suggest a data structure for storing strings with a lot of repetitions of successive characters.
We will represent such strings as a linked list, where each maximal sequence of the same character in consecutive positions, will be stored as a single tuple containing the character and its count.
For example, the string "aaaaabbbaaac" will be represented as the following list:
header
W,5) ('b', 3) ('a', 3) ('c', 1)
Complete the definition of the following CompactString class: class CompactString:
def init (self, orig_str):
"' Initializes a CompactString object representing the string given in orig str'"
def add (self, other):
"' Creates and returns a CompactString object that represent the concatenation of self and other,
also of type CompactString'"
def It (self, other):
I returns True if"f self is lexicographically less
than other, also of type CompactString'"
def
le
(self, other):
returns True if"f self is lexicographically less than or equal to other, also of type CompactString'"
def gt (self, other):
I
returns True if"f self is lexicographically, greater than other, also of type CompactString'
I IF returns True ifflf self is lexicographically
greater than or equal to other, also of type
CompactString'"
def repr (self) ) :
" ' Creates and returns the string representation (of
type str) of self" '
For example, after implementing the CompactString class, you should expect the
following behavior:
>>> s 1 CompactString ( 'aaaaabbbaaac')
>>> > |
s2 CompactString ( aaaaaaacccaaaa ') |
>>> s3 = sl + s2 #in s3's linked list there will be 6 'real' nodes
>>> s1 < s2
I
False
Note: Here too, when adding and comparing two CompactString objects, DO NOT
convert the CompactString objects to s t rs, do the operation on sirs (by using Python
+, <, >, <=, >= operators), and then convert the result back to a Compacts tr ing
object. This approach misses the point of this question.
Get Help With a similar task to - Compact String using Doubly Linked Lists
Additional Instructions:
Related Questions
Tutlance Experts offer help in a wide range of topics. Here are some of our top services:
- Math homework help
- Nursing homework help
- Statistics homework help
- Nursing coursework help
- Capstone project writing services
- Essay writers for hire
- Case study writing help
- Buy college papers online
- Buy college research papers
- College homework help
- Professional resume writing services
- Programming homework help
- Coursework writing help
- Term paper writing help
- Biology homework help
- Do my physics homework
- Dissertation data analysis help
- PhD Dissertation writing services
- Chemistry homework help
Post your project now for free and watch professional experts outbid each other in just a few minutes.