Day 37: Linked List Node Construction

Continued work on Linked Lists. I reviewed the next step in constructing a Linked List data structure in C. This involved abstracting the initialization of new nodes so that my program can construct as many nodes as I need as opposed to a pre-determined amount like in my first program.

TLDR;

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

  • Continued work on the “Technical Questions” section of the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. Continued my study of Linked Lists. I am trying to improve on my first example while noting what I am changing and how the improvements help improve the quality of my code.

Node Construction Function

struct node {
  int value;
  struct node* next;
};

// Allows us to write out node_t instead of struct node every time we use that type.
typedef struct node node_t;

node_t create_new_node(int value){
  node_t *result = malloc(sizeof(node_t));
  result->value = value;
  result->next = NULL;
  return result;
}

Conclusion

That’s all for today. 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.