Program to generate Cantor ternary set
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Program to generate Cantor ternary set
◆ free_memory()
Clear memory allocated by propagate function.
- Parameters
-
head | pointer to first allocated instance. |
void free_memory(CantorSet *head)
Clear memory allocated by propagate function.
Definition: cantor_set.c:72
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition: malloc_dbg.h:26
◆ print()
Print sets in the current range to stdout
- Parameters
-
head | pointer to first set in the current level |
61 printf(
"[%lf] -- ", temp->start);
62 printf(
"[%lf]", temp->end);
structure to define Cantor set
Definition: cantor_set.c:12
◆ propagate()
Iterative constructor of all sets in the current level.
This function dynamically allocates memory when creating new sets. These are freed by the function free_memory.
- Parameters
-
head | pointer to interval set instance to update |
35 double diff = (((temp->end) - (temp->start)) / 3);
39 temp->end = ((temp->start) + diff);
node * newNode(int data)
The node constructor, which receives the key value input and returns a node pointer.
Definition: binary_search_tree.c:28
void propagate(CantorSet *head)
Iterative constructor of all sets in the current level.
Definition: cantor_set.c:23
#define malloc(bytes)
This macro replace the standard malloc function with malloc_dbg.
Definition: malloc_dbg.h:18