Day 92: Painting and Converting is Done

Started my second read through of the Async chapter on JavaScript and it’s definitely a “re-write and re-phrase” topic. Also got back to my tree data structure. Now I know about painting arrays and type conversion. Time to keep it moving.

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 paint string step along with my type conversion step when collecting values from my tree. Also I now realize that I should not try to return an array from the function but rather pass in the target array I want the output placed in from the tree traversal. Slowly I’m getting there. Working in C is definitely different from JavaScript where Pure functions are preferred (At least that’s what I think is preferred, it could just be popular right now).
  • Started my second read through of chapter 11 of “Eloquent JavaScript” by Marijn Haverbeke. This chapter covers Asynchronous Programming. I struggled with my first read. I started re-writing some of the content in my own words and so far it has helped with my comprehension. Hopefully I can power through it tomorrow or in the next few days.

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
  printf("String before paint: '%s'\n", nodeValueStr);
  paintStringBlank(nodeValueStr, 10);
  printf("String after paint: '%s'\n", nodeValueStr);

  // 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);

# Output with one node with a value of 15

String before paint: ''
String after paint: '         '
result: 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.