Jim's
Tutorials

Spring 2018
course
site

Things we've covered this year

>>> gcc family-tree.c -o family-tree
void selectionSort(int arr[], int n);

void insertionSort(int arr[], int n);

void bubbleSort(int arr[], int n);
typedef struct _node *node;
struct _node{
  char name[20];
  int child_amount;
  node mother;
  node father;
  node spouse;
  node *children;
};
node newNode(char *title){
  node person = malloc(sizeof(struct _node));
  person->children = malloc(sizeof(node) * 10);
  strncpy(person->name, title, 20);
  person->mother = NULL;
  person->father = NULL;
  person->spouse = NULL;
  int child_amount = 0;
  return person;
};
node newNode(char *title){
  node person;
  strncpy(person->name, title, 20);
  person->mother = NULL;
  person->father = NULL;
  person->spouse = NULL;
  int child_amount = 0;
  return person;
};

Using Recursion

>>> ./family-tree
greg Spouse: laurie
   nate Spouse: wifey
     child1
       childOfChild1
         childOfChildOfChild1
    child2
 caitlin
https://cs.marlboro.college /cours /spring2018 /jims_tutorials /web_tech /c_may3
last modified Sat April 27 2024 12:51 am

attachments [paper clip]

  last modified size
TXT family-tree.c Sat Apr 27 2024 12:51 am 3.0K