Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dyn_huffman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC3
compression
dyn_huffman
Commits
6aa28209
Verified
Commit
6aa28209
authored
2 months ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
feat: looks like known characters are working
parent
8cf6c914
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dyn_huffman.py
+8
-15
8 additions, 15 deletions
dyn_huffman.py
with
8 additions
and
15 deletions
dyn_huffman.py
+
8
−
15
View file @
6aa28209
...
...
@@ -13,21 +13,8 @@ class Node:
right
:
Node
|
None
=
None
def
char_in_tree
(
tree
:
Node
,
char
:
str
)
->
Node
|
None
:
if
tree
.
left
!=
None
:
char_in_tree
(
tree
.
left
,
char
)
elif
tree
.
right
!=
None
:
char_in_tree
(
tree
.
right
,
char
)
if
tree
.
value
==
char
:
return
tree
else
:
return
None
def
swap
(
tree
:
Node
):
if
tree
.
left
and
tree
.
right
:
# print("weeeeeeeeeeeeeeesh")
if
tree
.
left
.
weight
>
tree
.
right
.
weight
:
print
(
f
'
(
{
tree
.
left
.
weight
}
,
{
tree
.
right
.
weight
}
)
'
)
tmp
=
tree
.
right
...
...
@@ -35,6 +22,12 @@ def swap(tree: Node):
tree
.
left
=
tmp
def
insert_char
(
tree
:
Node
,
char
:
str
):
if
tree
.
left
:
if
tree
.
left
.
value
==
char
:
tree
.
left
.
weight
+=
1
tree
.
weight
+=
1
return
# Leaf case
if
tree
.
left
==
None
and
tree
.
right
==
None
:
tree
.
left
=
Node
()
...
...
@@ -49,10 +42,10 @@ def insert_char(tree: Node, char: str):
if
tree
.
right
:
insert_char
(
tree
.
right
,
char
)
tree
.
weight
+=
1
swap
(
tree
)
def
compute_vitter_params
(
m
:
int
)
->
(
int
,
int
):
e
=
math
.
floor
(
np
.
log2
(
m
))
r
=
m
-
(
2
**
e
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment