Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
algorithme
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
PREMIERE
ALGO
algorithme
Commits
21435537
Commit
21435537
authored
3 years ago
by
jonas.stirnema
Browse files
Options
Downloads
Patches
Plain Diff
Added compression functions
parent
b5c8b2a1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
quad_tree/cours.md
+16
-0
16 additions, 0 deletions
quad_tree/cours.md
quad_tree/quad_tree.c
+49
-0
49 additions, 0 deletions
quad_tree/quad_tree.c
with
65 additions
and
0 deletions
quad_tree/cours.md
+
16
−
0
View file @
21435537
```
c
tree
tree_compress
(
tree
)
{
if
!
is_leaf
(
tree
)
{
tree
->
left
=
tree_compress
(
tree
->
left
);
tree
->
right
=
tree_compress
(
tree
->
right
);
if
(
tree
->
left
==
tree
->
right
)
{
tree
=
tree
->
left
;
}
}
}
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
quad_tree/quad_tree.c
+
49
−
0
View file @
21435537
...
@@ -5,6 +5,7 @@ typedef int value_t;
...
@@ -5,6 +5,7 @@ typedef int value_t;
typedef
struct
node_
typedef
struct
node_
{
{
value_t
value
;
value_t
value
;
value_t
sqared_avg
;
node_
*
child
[
4
]
node_
*
child
[
4
]
}
node_t
;
}
node_t
;
...
@@ -142,3 +143,51 @@ node_t *tree_vert_sym(node_t *tree)
...
@@ -142,3 +143,51 @@ node_t *tree_vert_sym(node_t *tree)
tree
=
fill_tree
(
m
);
tree
=
fill_tree
(
m
);
return
tree
;
return
tree
;
}
}
/**
* @brief Lossless tree compression
*
* @param tree
* @return node_t*
*/
void
tree_lossless_compress
(
node_t
*
tree
)
{
if
(
!
is_leaf
(
tree
))
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
tree
->
child
[
i
]
=
tree_lossless_compress
(
tree
->
child
[
i
]);
}
if
(
last_branch
(
tree
)
{
if
(
tree
->
child
[
0
]
==
tree
->
child
[
1
]
==
tree
->
child
[
2
]
==
tree
->
child
[
3
])
{
tree
->
data
=
tree
->
child
[
0
]
->
data
;
free
(
tree
->
child
);
}
}
}
}
#define DIFF 4
standard_deviation
=
Racine
de
la
moyenne
des
elements
au
carr
é
void
tree__lossy_compression
(
node_t
*
tree
)
{
if
(
!
is_leaf
(
tree
))
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
tree
->
child
[
i
]
=
tree_lossy_compress
(
tree
->
child
[
i
]);
}
if
(
last_branch
(
tree
))
{
if
(
sqrt
(
tree
->
sqared_avg
-
tree
->
value
*
tree
->
value
)
<
DIFF
)
{
free
(
tree
->
child
);
}
}
}
}
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