SlideShare a Scribd company logo
1 of 3
Download to read offline
could you draw a uml diagram for this code
import struct
import math
import os
def compress(uncompressed):
"""Compress a string to a list of output symbols."""
# Build the dictionary.
dict_size = 256
dictionary = {chr(i): i for i in range(dict_size)}
w = ""
result = []
for c in uncompressed:
wc = w + c
if wc in dictionary:
w = wc
else:
result.append(dictionary[w])
# Add wc to the dictionary.
dictionary[wc] = dict_size
dict_size += 1
w = c
# Output the code for w.
if w:
result.append(dictionary[w])
return result
def decompress(compressed):
"""Decompress a list of output ks to a string."""
from io import StringIO
# Build the dictionary.
dict_size = 256
dictionary = {i: chr(i) for i in range(dict_size)}
# use StringIO, otherwise this becomes O(N^2)
# due to string concatenation in a loop
result = StringIO()
w = chr(compressed.pop(0))
result.write(w)
for k in compressed:
if k in dictionary:
entry = dictionary[k]
elif k == dict_size:
entry = w + w[0]
else:
raise ValueError('Bad compressed k: %s' % k)
result.write(entry)
# Add w+entry[0] to the dictionary.
dictionary[dict_size] = w + entry[0]
dict_size += 1
w = entry
return result.getvalue()
# Open the file in read modef
with open('filename.txt', 'r') as f:
# Read the entire contents of the file
data = f.read()
print("inpur/original data:", data)
# Compress the data
compressed = compress(data)
# Print the compressed data
print("Compressed data:", compressed)
# Decompress the data
decompressed = decompress(compressed)
# Print the original data
print("Decompressed data:", decompressed)
# How to use:
data = "TOBEORNOTTOBEORTOBEORNOT"
print("input data:",data)
compressed = compress(data)
print("compressed_data: ", compressed)
decompressed = decompress(compressed)
print("decompressed_data : ",decompressed)
# Example usage:
data = "TOBEORNOTTOBEORTOBEORNOT"
compressed = compress(data)
print('Compressed data:', compressed)
# Calculate code length and compression ratio
#uncompressed_size = os.path.getsize(file_path)
#compressed_size = os.path.getsize(compressed_file_path)
#code_length = compressed_size * 8
#compression_ratio = uncompressed_size / compressed_size
#print ('the length of the code: ',code_length)
#print ('compression ratio: ',compression_ratio)
#return compressed_file_path

More Related Content

Similar to could you draw a uml diagram for this codeimport structimport ma.pdf

ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfgopalk44
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray EnginePVS-Studio
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfaksachdevahosymills
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppttocidfh
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docxMehwishKanwal14
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdfchoconyeuquy
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CEleanor McHugh
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
Computer science project work on C++
Computer science project work on C++Computer science project work on C++
Computer science project work on C++NARESH KUMAR
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
C++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPAC++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPAIsabella789
 
The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212Mahmoud Samir Fayed
 

Similar to could you draw a uml diagram for this codeimport structimport ma.pdf (20)

C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Ch3
Ch3Ch3
Ch3
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docx
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
Csharp_Chap06
Csharp_Chap06Csharp_Chap06
Csharp_Chap06
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 
Arrays & Strings.pptx
Arrays & Strings.pptxArrays & Strings.pptx
Arrays & Strings.pptx
 
C Programming
C ProgrammingC Programming
C Programming
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
Computer science project work on C++
Computer science project work on C++Computer science project work on C++
Computer science project work on C++
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPAC++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPA
 
The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212
 

More from murtuzadahadwala3

Create an Executive Summary using the following report on investing .pdf
Create an Executive Summary using the following report on investing .pdfCreate an Executive Summary using the following report on investing .pdf
Create an Executive Summary using the following report on investing .pdfmurtuzadahadwala3
 
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdf
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdfCreate a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdf
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdfmurtuzadahadwala3
 
Create an Executive Summary using the following information for the .pdf
Create an Executive Summary using the following information for the .pdfCreate an Executive Summary using the following information for the .pdf
Create an Executive Summary using the following information for the .pdfmurtuzadahadwala3
 
Create a python program that creates a database in MongoDB using API.pdf
Create a python program that creates a database in MongoDB using API.pdfCreate a python program that creates a database in MongoDB using API.pdf
Create a python program that creates a database in MongoDB using API.pdfmurtuzadahadwala3
 
Create a Java application that uses card layout with four cards with.pdf
Create a Java application that uses card layout with four cards with.pdfCreate a Java application that uses card layout with four cards with.pdf
Create a Java application that uses card layout with four cards with.pdfmurtuzadahadwala3
 
Create a Class Diagram for a Rectangle class that has one constructo.pdf
Create a Class Diagram for a Rectangle class that has one constructo.pdfCreate a Class Diagram for a Rectangle class that has one constructo.pdf
Create a Class Diagram for a Rectangle class that has one constructo.pdfmurtuzadahadwala3
 
Crane Company began the month of June with 1,630 units in beginning .pdf
Crane Company began the month of June with 1,630 units in beginning .pdfCrane Company began the month of June with 1,630 units in beginning .pdf
Crane Company began the month of June with 1,630 units in beginning .pdfmurtuzadahadwala3
 
Count the number of occurrences of an item in a matrix. Create a Pyt.pdf
Count the number of occurrences of an item in a matrix. Create a Pyt.pdfCount the number of occurrences of an item in a matrix. Create a Pyt.pdf
Count the number of occurrences of an item in a matrix. Create a Pyt.pdfmurtuzadahadwala3
 
could you draw uml diagram for this code from PIL import Image, Im.pdf
could you draw uml diagram for this code from PIL import Image, Im.pdfcould you draw uml diagram for this code from PIL import Image, Im.pdf
could you draw uml diagram for this code from PIL import Image, Im.pdfmurtuzadahadwala3
 
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdf
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdfCOUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdf
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdfmurtuzadahadwala3
 
convert the following C code to Mips assembly with steps and comment.pdf
convert the following C code to Mips assembly with steps and comment.pdfconvert the following C code to Mips assembly with steps and comment.pdf
convert the following C code to Mips assembly with steps and comment.pdfmurtuzadahadwala3
 
copyReverse.c code please do not change anything in the code bes.pdf
copyReverse.c code please do not change anything in the code bes.pdfcopyReverse.c code please do not change anything in the code bes.pdf
copyReverse.c code please do not change anything in the code bes.pdfmurtuzadahadwala3
 
Contrast the location of a food distributor and a supermarket. (The .pdf
Contrast the location of a food distributor and a supermarket. (The .pdfContrast the location of a food distributor and a supermarket. (The .pdf
Contrast the location of a food distributor and a supermarket. (The .pdfmurtuzadahadwala3
 
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdf
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdfContabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdf
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdfmurtuzadahadwala3
 
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdf
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdfContaminaci�n en la cadena log�stica de productos agr�colas a granel.pdf
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdfmurtuzadahadwala3
 
Constructing Entity Relationship Diagram University workshop case st.pdf
Constructing Entity Relationship Diagram University workshop case st.pdfConstructing Entity Relationship Diagram University workshop case st.pdf
Constructing Entity Relationship Diagram University workshop case st.pdfmurtuzadahadwala3
 
Consider the international strategy of a current entrepreneurial ve.pdf
Consider the international strategy of a current  entrepreneurial ve.pdfConsider the international strategy of a current  entrepreneurial ve.pdf
Consider the international strategy of a current entrepreneurial ve.pdfmurtuzadahadwala3
 
Consider the network shown in the attached picture. Assume Distance .pdf
Consider the network shown in the attached picture. Assume Distance .pdfConsider the network shown in the attached picture. Assume Distance .pdf
Consider the network shown in the attached picture. Assume Distance .pdfmurtuzadahadwala3
 
Consider the DE PBC Article. Which of the following sources of capit.pdf
Consider the DE PBC Article. Which of the following sources of capit.pdfConsider the DE PBC Article. Which of the following sources of capit.pdf
Consider the DE PBC Article. Which of the following sources of capit.pdfmurtuzadahadwala3
 
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdf
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdfComputer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdf
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdfmurtuzadahadwala3
 

More from murtuzadahadwala3 (20)

Create an Executive Summary using the following report on investing .pdf
Create an Executive Summary using the following report on investing .pdfCreate an Executive Summary using the following report on investing .pdf
Create an Executive Summary using the following report on investing .pdf
 
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdf
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdfCreate a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdf
Create a ReportTopic Hudson Bay Mountain Estates (Smithers)The .pdf
 
Create an Executive Summary using the following information for the .pdf
Create an Executive Summary using the following information for the .pdfCreate an Executive Summary using the following information for the .pdf
Create an Executive Summary using the following information for the .pdf
 
Create a python program that creates a database in MongoDB using API.pdf
Create a python program that creates a database in MongoDB using API.pdfCreate a python program that creates a database in MongoDB using API.pdf
Create a python program that creates a database in MongoDB using API.pdf
 
Create a Java application that uses card layout with four cards with.pdf
Create a Java application that uses card layout with four cards with.pdfCreate a Java application that uses card layout with four cards with.pdf
Create a Java application that uses card layout with four cards with.pdf
 
Create a Class Diagram for a Rectangle class that has one constructo.pdf
Create a Class Diagram for a Rectangle class that has one constructo.pdfCreate a Class Diagram for a Rectangle class that has one constructo.pdf
Create a Class Diagram for a Rectangle class that has one constructo.pdf
 
Crane Company began the month of June with 1,630 units in beginning .pdf
Crane Company began the month of June with 1,630 units in beginning .pdfCrane Company began the month of June with 1,630 units in beginning .pdf
Crane Company began the month of June with 1,630 units in beginning .pdf
 
Count the number of occurrences of an item in a matrix. Create a Pyt.pdf
Count the number of occurrences of an item in a matrix. Create a Pyt.pdfCount the number of occurrences of an item in a matrix. Create a Pyt.pdf
Count the number of occurrences of an item in a matrix. Create a Pyt.pdf
 
could you draw uml diagram for this code from PIL import Image, Im.pdf
could you draw uml diagram for this code from PIL import Image, Im.pdfcould you draw uml diagram for this code from PIL import Image, Im.pdf
could you draw uml diagram for this code from PIL import Image, Im.pdf
 
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdf
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdfCOUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdf
COUNTRY IS INDIA1. Describe the legal environment of chosen countr.pdf
 
convert the following C code to Mips assembly with steps and comment.pdf
convert the following C code to Mips assembly with steps and comment.pdfconvert the following C code to Mips assembly with steps and comment.pdf
convert the following C code to Mips assembly with steps and comment.pdf
 
copyReverse.c code please do not change anything in the code bes.pdf
copyReverse.c code please do not change anything in the code bes.pdfcopyReverse.c code please do not change anything in the code bes.pdf
copyReverse.c code please do not change anything in the code bes.pdf
 
Contrast the location of a food distributor and a supermarket. (The .pdf
Contrast the location of a food distributor and a supermarket. (The .pdfContrast the location of a food distributor and a supermarket. (The .pdf
Contrast the location of a food distributor and a supermarket. (The .pdf
 
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdf
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdfContabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdf
Contabilidad del iPhone en Apple Inc. El 21 de octubre de 2008, Appl.pdf
 
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdf
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdfContaminaci�n en la cadena log�stica de productos agr�colas a granel.pdf
Contaminaci�n en la cadena log�stica de productos agr�colas a granel.pdf
 
Constructing Entity Relationship Diagram University workshop case st.pdf
Constructing Entity Relationship Diagram University workshop case st.pdfConstructing Entity Relationship Diagram University workshop case st.pdf
Constructing Entity Relationship Diagram University workshop case st.pdf
 
Consider the international strategy of a current entrepreneurial ve.pdf
Consider the international strategy of a current  entrepreneurial ve.pdfConsider the international strategy of a current  entrepreneurial ve.pdf
Consider the international strategy of a current entrepreneurial ve.pdf
 
Consider the network shown in the attached picture. Assume Distance .pdf
Consider the network shown in the attached picture. Assume Distance .pdfConsider the network shown in the attached picture. Assume Distance .pdf
Consider the network shown in the attached picture. Assume Distance .pdf
 
Consider the DE PBC Article. Which of the following sources of capit.pdf
Consider the DE PBC Article. Which of the following sources of capit.pdfConsider the DE PBC Article. Which of the following sources of capit.pdf
Consider the DE PBC Article. Which of the following sources of capit.pdf
 
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdf
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdfComputer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdf
Computer Programming Task- Assembly Language- STM32F3 DISCOVERY.pdf
 

Recently uploaded

Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

could you draw a uml diagram for this codeimport structimport ma.pdf

  • 1. could you draw a uml diagram for this code import struct import math import os def compress(uncompressed): """Compress a string to a list of output symbols.""" # Build the dictionary. dict_size = 256 dictionary = {chr(i): i for i in range(dict_size)} w = "" result = [] for c in uncompressed: wc = w + c if wc in dictionary: w = wc else: result.append(dictionary[w]) # Add wc to the dictionary. dictionary[wc] = dict_size dict_size += 1 w = c # Output the code for w. if w: result.append(dictionary[w]) return result def decompress(compressed): """Decompress a list of output ks to a string.""" from io import StringIO # Build the dictionary.
  • 2. dict_size = 256 dictionary = {i: chr(i) for i in range(dict_size)} # use StringIO, otherwise this becomes O(N^2) # due to string concatenation in a loop result = StringIO() w = chr(compressed.pop(0)) result.write(w) for k in compressed: if k in dictionary: entry = dictionary[k] elif k == dict_size: entry = w + w[0] else: raise ValueError('Bad compressed k: %s' % k) result.write(entry) # Add w+entry[0] to the dictionary. dictionary[dict_size] = w + entry[0] dict_size += 1 w = entry return result.getvalue() # Open the file in read modef with open('filename.txt', 'r') as f: # Read the entire contents of the file data = f.read() print("inpur/original data:", data) # Compress the data compressed = compress(data) # Print the compressed data print("Compressed data:", compressed)
  • 3. # Decompress the data decompressed = decompress(compressed) # Print the original data print("Decompressed data:", decompressed) # How to use: data = "TOBEORNOTTOBEORTOBEORNOT" print("input data:",data) compressed = compress(data) print("compressed_data: ", compressed) decompressed = decompress(compressed) print("decompressed_data : ",decompressed) # Example usage: data = "TOBEORNOTTOBEORTOBEORNOT" compressed = compress(data) print('Compressed data:', compressed) # Calculate code length and compression ratio #uncompressed_size = os.path.getsize(file_path) #compressed_size = os.path.getsize(compressed_file_path) #code_length = compressed_size * 8 #compression_ratio = uncompressed_size / compressed_size #print ('the length of the code: ',code_length) #print ('compression ratio: ',compression_ratio) #return compressed_file_path