Day 93: More Analogies and Concatenation

Continued my second reading of the asynchronous section and it’s still messy. I just want to finish this up and move on. On a more positive note, I learned about string concatenation in C and got my first value in the first row of my tree stored in an array of strings. So far so good. This is extremely slow but it’s progress nonetheless

TLDR;

Okay, so here are the highlights of what I did:

  • Continued my work on my binary tree’s Horizontal Pretty Print function. I added the concatenation step in my collectValues function. This step involved adding the separator character (in this case a ',') to the string representing the row.
  • Continued my second read through of chapter 11 of “Eloquent JavaScript” by Marijn Haverbeke. I am still struggling with the Crows analogy but I have to keep pushing forward.

Update on Collect Values function in tree C

// Collect values in tree using a Pre order traversal
void collectValues(treenode* root){
  /*
   * Steps:
   *   0. Reset string for row
   *   1. Get Node value 
   *   2. convert to string
   *   3. concatenate with separator
   *   4. append to the end of the treeVals row
   * */
  char treeVals[10][COLUMNS];
  int level = 0;
  char separator = ',';
  char nodeValueStr[10];

  // 0. Reset string for row
  paintStringBlank(nodeValueStr, 10);

  // 1. Get node value (For now do it manually - later make it recursive)
  // 2. Convert to String
  sprintf(nodeValueStr, "%i", root->value);
  printf("result: %s\n", nodeValueStr);

  // 3. and 4. are combined here. concatenate value with separator and append to treeVals row.
  // Since this is the first value in the row we must copy and not append to the row
  strcpy(treeVals[0], strcat(nodeValueStr, ","));
  printf("First Row: %s", treeVals[0]);

# Output with one node with a value of 15

result: 15
First Row: 15,


Goal For Round 6 of the #100DaysofCode Challenge

This is my sixth round of the “#100daysofcode” challenge. I will be continuing my work from round five into round six. I am currently working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal is to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in term derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.

I have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects.