I have a binary tree where I need to have it sorted inside an array and then return it. This is the function and where I am currently
struct treeNode
{
int data;
struct treeNode* left;
struct treeNode* right;
};
typedef struct treeNode* BSTree;
static int* writeSortedToArray(const BSTree tree)
{
int i=0;
int leng = numberOfNodes(tree);
int *arrayBST = malloc(leng*sizeof(int));
}
I dont know how to continue or if even the allocation part is correct any advice on how to make this work would be appreciated and if similar question has been asked before I would love it if anyone would guide me to it.