title: B-tree in pseudocode
body: <p>In order to understand B-tree-algorithms I'm trying to write such in C style pseudocode. I suppose a B-tree algorithm is like a linked list but with an array of pointers and an integer that with the value of the length of the array. Am I right? Below is pseudocode for a linked list and my understanding of a B-tree. The problem I got with my B-tree-algorithm is that it only works for the first generation of children. Does anyone have any idea what is wrong?</p>
  
  <p>Thanks in advance for help! </p>
  
  <p><em>Linked list:</em></p>
  
  <pre>
  
      struct node
          datatypes for content...
          struct node *next;
  
      struct node* head = NULL
      struct node* p = NULL
      struct node* n = NULL
  
      head = malloc(sizeof *head)
      head→next = malloc(sizeof(struct node))
      p = head→next
      p→content = malloc(sizeof string)
      while (...)
          input content
          p→next = malloc(sizeof(struct node))
          n = p→next
          n→content = malloc(sizeof content)
          p=n
  
  </pre>
  
  <p><em>B-tree:</em></p>
  
  <pre>
  
      struct node
          datatypes for content...
          int children
          struct node *next [children]
      struct node* head = NULL
      struct node* p = NULL
      struct node* n = NULL
      head = malloc(sizeof *head);
      int children = input a value
      for i in length of children
          head→next[i] = malloc(sizeof(struct node));
          head→next = malloc(sizeof(struct node));
          p = head→next;
          p→content = malloc(sizeof content);
      while (...)
          input content
          p→next = malloc(sizeof(struct node))
          n = p→next;
          n→children = input a value
          for i in length of children
                 p→next[i] = malloc(sizeof(struct node))
                 p→content = malloc(sizeof content)
                 p=n
  
  </pre>