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

Login to view and/or buy answers.. or post an answer
Additional Instructions:

Related Questions

Similar orders to Compact String using Doubly Linked Lists
20
Views
0
Answers
introduction to programming fundamentals -
Problem Description Every business needs a mechanism to manage and track its transactions, which should be robust and efficient. You are hired by a new high-street clothing brand to develop software that manages and tracks every transaction. You are requi...
18
Views
0
Answers
Simple Python Work
To create the task shown in the screenshot: Create Number 9...
15
Views
0
Answers
Python assignment
At least 2/3 of the assignment done please...
26
Views
0
Answers
Python assigment, 3 questions and 55 marks total
There are three questions, and it would be great to have at least 2/3 of the questions completed....