Skip to content

Commit

Permalink
add more tree tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
witek-formanski committed Nov 29, 2023
1 parent 0e30e37 commit e736287
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/cw8/count_symmetrical_nodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ policz węzły drzewa które mają tyle samo kroków do korzenia
co do najgłębszego liścia
*/


#include <stdlib.h>
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

typedef struct bin_tree bin_tree;

Expand Down
23 changes: 23 additions & 0 deletions src/cw8/zad10/is_ultraleftist.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdbool.h>

typedef struct node* bin_tree;

struct node {
int val;
bin_tree left, right;
};

bool is_ultraleftist(bin_tree t, int depth, int* depth_last) {
if (!t) return true;

if (!t->left && !t->right) {
if (*depth_last < depth)
return false;

*depth_last = depth;
return true;
}

return is_ultraleftist(t->left, depth + 1, depth_last)
&& is_ultraleftist(t->right, depth + 1, depth_last);
}
10 changes: 10 additions & 0 deletions src/cw8/zad12/cut_tree_into_two.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
typedef struct node* bin_tree;

struct node {
int val;
bin_tree left, right;
};

// policz rozmiar drzewa: int size

// przejdź przez drzewo postorderem
Empty file added src/cw8/zad7/general_tree.c
Empty file.
2 changes: 0 additions & 2 deletions src/cw8/zad8/jump_traversal.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <stdlib.h>

typedef struct bin_tree bin_tree;

struct bin_tree {
Expand Down

0 comments on commit e736287

Please sign in to comment.