<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: tartope</title>
    <description>The latest articles on DEV Community by tartope (@tartope).</description>
    <link>https://dev.to/tartope</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F810043%2Fca07ebc2-1b3a-4594-9e67-6785d03d66f3.jpeg</url>
      <title>DEV Community: tartope</title>
      <link>https://dev.to/tartope</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tartope"/>
    <language>en</language>
    <item>
      <title>Doubly Linked List Series: Creating insert(), remove(), and reverse() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sun, 29 Jan 2023 17:43:55 +0000</pubDate>
      <link>https://dev.to/tartope/doubly-linked-list-series-creating-insert-remove-and-reverse-methods-with-javascript-2m4p</link>
      <guid>https://dev.to/tartope/doubly-linked-list-series-creating-insert-remove-and-reverse-methods-with-javascript-2m4p</guid>
      <description>&lt;p&gt;This post will conclude what I have learned about creating various methods within a Doubly Linked List.  The methods that I will be discussing today build off of methods outlined in previous blog posts for this series.  The previous methods needed to support the methods that I will be discussing today include &lt;a href="https://dev.to/tartope/doubly-linked-list-series-creating-get-and-set-methods-with-javascript-ip1"&gt;get()&lt;/a&gt;, &lt;a href="https://dev.to/tartope/doubly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2mmd"&gt;unshift() and shift()&lt;/a&gt;, and &lt;a href="https://dev.to/tartope/doubly-linked-list-series-node-and-doubly-linked-list-classes-with-push-and-pop-methods-using-javascript-37e"&gt;push() and pop()&lt;/a&gt;.  Beginning with insert(), this method adds a node at a specified index.  This method takes in two parameters (index and value), and calls on unshift(), push(), and get() methods to support it.  Here is a visualization for creating this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Clg95Zun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxbqw4oi14es9pz4pguz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Clg95Zun--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxbqw4oi14es9pz4pguz.png" alt="Drawing for insert method" width="880" height="567"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---N_VhQNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64jg48dftpmbx9f9u1i2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---N_VhQNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64jg48dftpmbx9f9u1i2.png" alt="Drawing for insert method continued" width="880" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case 1: if the index is a negative number or greater than the length of the list, you can return false because that index is not valid.&lt;br&gt;
Edge case 2: if the index is equal to zero, you can use the unshift() method to place a node at the start of the list.&lt;br&gt;
Edge case 3: if the index is equal to the lists' length, you can use the push() method to place a new node at the end of the list.&lt;br&gt;
If none of the above cases apply, then you can follow the steps outlined above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for an insert() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NweAU9MV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocgj45xxdon3b6j93f3h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NweAU9MV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocgj45xxdon3b6j93f3h.png" alt="Insert method code" width="880" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, the remove() method will remove a node at a specified index.  This method takes one parameter (index) and makes use of shift() and pop() methods to support it.  Below is a visualization for this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GNUUGviU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1th6eh9sngs16cfkaj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GNUUGviU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1th6eh9sngs16cfkaj6.png" alt="Drawing of remove method" width="880" height="572"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--scKxFVQl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19s4we14jo4fjkxmjrn1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--scKxFVQl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19s4we14jo4fjkxmjrn1.png" alt="Drawing of remove method continued" width="880" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case 1: if the index is a negative number or greater than or equal to the length, you can return undefined because the index passed is not valid.&lt;br&gt;
Edge case 2: if the index is equal to zero, you can use the shift() method to remove a node from the start of the list.&lt;br&gt;
Edge case 3: if the index is equal to the last index of the list, you can use the pop() method to remove the last node.&lt;br&gt;
If none of the above cases apply, then you can follow the steps outlined above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a remove() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_aTU66rY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lv5pibum1jnis25tjlus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_aTU66rY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lv5pibum1jnis25tjlus.png" alt="Remove method code" width="880" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, this reverse() method will reverse a list in place and takes no parameters.  This method works by swapping the head and tail, and changing the directions of the previous and next pointers.  Below is an illustration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dYyY34bs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3sh8zge91gbdsutl40n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dYyY34bs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3sh8zge91gbdsutl40n0.png" alt="Drawing of reverse method" width="880" height="723"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J04Uvx3o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hknqdoagzzsdih4xlexe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J04Uvx3o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hknqdoagzzsdih4xlexe.png" alt="Drawing of reverse method continued" width="880" height="907"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of code for a reverse() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WSvyx9O2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4r8pmkbbnm30fekkqe3j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WSvyx9O2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4r8pmkbbnm30fekkqe3j.png" alt="Reverse method code" width="880" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity for these methods is O(1) constant time if insertion and removal occur at the start or end of the list because the number of operations remains the same.  Otherwise, time complexity will be O(n) linear time because you will need to loop through the list to insert or remove at the middle, and the number of operations increases as the list's length increase.  The reverse method is also O(n) linear time.  Hopefully, others find this representation of the code helpful as it has been for me.  There is so much to learn so please feel free to share comments or corrections if I have anything incorrect or missed anything. 🙂&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Doubly Linked List Series: Creating get() and set() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sun, 22 Jan 2023 14:09:19 +0000</pubDate>
      <link>https://dev.to/tartope/doubly-linked-list-series-creating-get-and-set-methods-with-javascript-ip1</link>
      <guid>https://dev.to/tartope/doubly-linked-list-series-creating-get-and-set-methods-with-javascript-ip1</guid>
      <description>&lt;p&gt;This post will continue to build off of the previous blog on Doubly Linked List methods - &lt;a href="https://dev.to/tartope/doubly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2mmd"&gt;linked here&lt;/a&gt;.  Today I will share how I have learned to create get() and set() methods for a Doubly Linked List.  Beginning with get(), this method accepts an index as a parameter and retrieves a node at a chosen position in the list.  Since lists are not indexed, a counter will have to be used to find the wanted node.  See an illustration below for this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oeabx0oy77e7jfr3p4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8oeabx0oy77e7jfr3p4p.png" alt="First part of drawing for get method" width="800" height="544"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjyx3qemdkl05shzf74i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjyx3qemdkl05shzf74i.png" alt="Second part of drawing for get method" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: if the index is less than zero, or greater than or equal to the length of the list, return null.  Otherwise, follow the steps listed above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a get() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1iiytd57pnddu5wvivh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1iiytd57pnddu5wvivh.png" alt="Picture of code for a get method" width="800" height="776"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The method for set() is used to change the value of a node at a chosen position in the list.  Set() accepts two parameters - an index to be found, and a value to be updated.  Creating this method is a little easier because we can use the get() method created earlier to support this method.  Below is an illustration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fny0ubg1i3g0hisw8lq1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fny0ubg1i3g0hisw8lq1s.png" alt="Drawing for get method" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example code for a set() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ncs9h8t6l87101xxnms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ncs9h8t6l87101xxnms.png" alt="Picture of code for a set method" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity for get() and set() methods in a Doubly Linked List is O(n) linear time because as the lists' length increases so does the number of operations.  Please feel free to share comments or corrections if I got anything incorrect.  In the next blog I will share what I have learned about creating insert(), remove(), and reverse() methods for Doubly Linked Lists.&lt;/p&gt;

</description>
      <category>career</category>
      <category>ai</category>
      <category>docker</category>
      <category>linux</category>
    </item>
    <item>
      <title>Doubly Linked List Series: Creating shift() and unshift() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Mon, 09 Jan 2023 13:46:16 +0000</pubDate>
      <link>https://dev.to/tartope/doubly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2mmd</link>
      <guid>https://dev.to/tartope/doubly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2mmd</guid>
      <description>&lt;p&gt;Building off of last week's blog on Doubly Linked List classes, push(), and pop() methods - &lt;a href="https://dev.to/tartope/doubly-linked-list-series-node-and-doubly-linked-list-classes-with-push-and-pop-methods-using-javascript-37e"&gt;linked here&lt;/a&gt; - today I will be discussing shift() and unshift() methods.  Starting with shift(), this method does not take a parameter and removes the first node from the beginning of the list.  Here is an illustration of a shift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo0ss0fne1xpvyc6h6utf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo0ss0fne1xpvyc6h6utf.png" alt="Drawing of shift method" width="467" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list, or has only one node.  If neither of those cases applies, then follow the steps above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a shift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41ul2sd166fzmbx7ofz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs41ul2sd166fzmbx7ofz.png" alt="Screen shot of shift method code" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The method unshift() adds a node to the beginning of the list.  Here is an illustration of this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnahdlxfnq6mad4vhecw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnahdlxfnq6mad4vhecw.png" alt="Drawing of unshift method" width="466" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list.  If the list is not empty, then follow the steps mentioned above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for an unshift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2jg7txaghbigr84oeoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2jg7txaghbigr84oeoh.png" alt="Screen shot of unshift method code" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity for shift() and unshift() methods for a Doubly Linked List is O(1) constant time.  The length of the list does not impact the number of steps to remove from the beginning or add to the beginning of the list.&lt;/p&gt;

&lt;p&gt;In the next part of this series, I will share what I have learned about creating get() and set() methods for a Doubly Linked List.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>career</category>
      <category>management</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Doubly Linked List Series: Node and Doubly Linked List Classes with push() and pop() methods using JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 31 Dec 2022 16:21:42 +0000</pubDate>
      <link>https://dev.to/tartope/doubly-linked-list-series-node-and-doubly-linked-list-classes-with-push-and-pop-methods-using-javascript-37e</link>
      <guid>https://dev.to/tartope/doubly-linked-list-series-node-and-doubly-linked-list-classes-with-push-and-pop-methods-using-javascript-37e</guid>
      <description>&lt;p&gt;As I continue to study data structures and algorithms, I am finding that writing things out is helping to improve my understanding of data structures and a few ways to manipulate the data in them.  I will use this series to discuss Doubly Linked Lists, and use illustration, followed by example code, to lay out my understanding of a few methods.&lt;/p&gt;

&lt;p&gt;Doubly Linked Lists are similar to Singly Linked Lists.  If you are looking for an explanation on &lt;a href="https://dev.to/tartope/singly-linked-list-series-node-and-singly-linked-list-classes-54o0"&gt;Singly Linked Lists&lt;/a&gt;, you can take a look at my posts on that.  One key difference with Doubly Linked Lists is that they have a pointer that references the previous node.  Also, they take up more memory however that comes with more flexibility because you are not confined to traversing the list in one direction only.&lt;/p&gt;

&lt;p&gt;Building a Node class for Doubly Linked Lists is similar to building a Node class for Singly Linked Lists and the only difference is adding a previous pointer.  A node is an object with a key-value pair and will look like this: {value: value, next: null, prev: null}.  Here is an illustration of nodes referencing each other:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5j8P1VDH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6usihz2jffivolvxrnu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5j8P1VDH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6usihz2jffivolvxrnu6.png" alt="Drawing of nodes in a doubly linked list" width="880" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of code that builds the node:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HoLMK0Jb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syex7v4hhjao91pvl6vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HoLMK0Jb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syex7v4hhjao91pvl6vg.png" alt="Screenshot of node class code" width="621" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Doubly Linked List class creates the structure for the list.  It includes the head, tail, and length properties.  Here is an example of code that builds the Doubly Linked List:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e8WegBCo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4k556adnrz8sc1vfwl3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e8WegBCo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4k556adnrz8sc1vfwl3m.png" alt="Screenshot of doubly linked list class code" width="588" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These two classes are used to instantiate a list.  Within the Doubly Linked List class, various methods can be written.  I will share two methods: push() and pop().  When you are looking to add a node to the end of a list, you can create a push() method.  This method takes a parameter to create a new node that is added to the end of the list.  Here is an illustration of that method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2i9ieAJ9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wr9a6w8y7nbjy5b0zt50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2i9ieAJ9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wr9a6w8y7nbjy5b0zt50.png" alt="Drawing of push method" width="880" height="684"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list.  If it is not empty, then follow the steps mentioned above.&lt;/p&gt;

&lt;p&gt;Here is an example code for a push() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PgZ1Dt2z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qbjhxkfk7axvjnewqlgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PgZ1Dt2z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qbjhxkfk7axvjnewqlgk.png" alt="Screenshot of push method code" width="732" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A pop() method removes a node from the end of a Doubly Linked List.  A parameter is not needed for this method.  Below is an illustration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Z42g-w2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fse62smdri1t1217ro62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Z42g-w2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fse62smdri1t1217ro62.png" alt="Drawing of pop method" width="880" height="645"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge cases: account for if the list is empty, or has only one node.  If neither of those cases applies, then follow the steps illustrated above.&lt;/p&gt;

&lt;p&gt;Here is an example code for a pop() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yK63xnUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2fhea9xgvl7p28rvo6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yK63xnUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2fhea9xgvl7p28rvo6f.png" alt="Screenshot of pop method code" width="729" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity for push() and pop() methods in a Doubly Linked List will be O(1) constant time because the number of operations does not increase as the length of the list increase.  &lt;/p&gt;

&lt;p&gt;Next week I will share what I have learned about creating shift() and unshift() methods.  As always, the learning process is ongoing, so feel free to share your comments if I got anything incorrect. 😀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Singly Linked List Series: Creating insert(), remove(), and reverse() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 17 Dec 2022 16:29:50 +0000</pubDate>
      <link>https://dev.to/tartope/singly-linked-list-series-creating-insert-remove-and-reverse-methods-with-javascript-3iac</link>
      <guid>https://dev.to/tartope/singly-linked-list-series-creating-insert-remove-and-reverse-methods-with-javascript-3iac</guid>
      <description>&lt;p&gt;I will be wrapping up this Singly Linked List Series by sharing my understanding of creating insert(), remove(), and reverse() methods.  Beginning with insert(), this method receives two parameters: index and value.  This method adds a node at a specified index with the value passed.  It returns true if the node was inserted; otherwise, it returns false.  This method uses &lt;a href="https://dev.to/tartope/singly-linked-list-series-creating-get-and-set-methods-with-javascript-3o51"&gt;get()&lt;/a&gt;, &lt;a href="https://dev.to/tartope/singly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2j37"&gt;unshift() and shift()&lt;/a&gt;, and &lt;a href="https://dev.to/tartope/singly-linked-list-series-creating-push-and-pop-methods-35n4"&gt;push() and pop()&lt;/a&gt; methods to support it.  See the previous Singly Linked List Series blog posts linked above to get an understanding of creating these methods.  Let's start with a visualization for creating this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AGroJEQH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cp5ioqcu78wu7wd6p4d4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AGroJEQH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cp5ioqcu78wu7wd6p4d4.png" alt="Drawing of insert method" width="880" height="758"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case 1: if the index is a negative number or greater than the length of the list, you can return false because that index is not valid.&lt;br&gt;
Edge case 2: if the index is equal to zero, you can use the unshift() method to place a new node at the beginning of the list.&lt;br&gt;
Edge case 3: if the index is equal to the length of the list, you can use the push() method to place a new node at the end of the list.&lt;br&gt;
If none of the above edge cases apply, you can follow the steps above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for an insert() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r78Px9uL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwmht3jhvjxr187yu6de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r78Px9uL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwmht3jhvjxr187yu6de.png" alt="Image of code for an insert method" width="738" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A remove() method will remove a node from a Singly Linked List at a specific index.  This method accepts an index as a parameter.  The visualization looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sS4TdvgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0q9907fcbx13vxnh5zkx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sS4TdvgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0q9907fcbx13vxnh5zkx.png" alt="Drawing of remove method" width="880" height="713"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case 1: if the index is a negative number or greater than or equal to the length, you can return undefined because that index is not valid.&lt;br&gt;
Edge case 2: if the index is equal to zero, you can use the shift() method to remove a node from the beginning of the list.&lt;br&gt;
Edge case 3: if the index is equal to the last index in the list, you can use the pop() method to remove a node from the end of the list.&lt;br&gt;
Same as before, if none of the above edge cases apply, you can follow the steps above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a remove() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rb0NbqoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6nqty20zl7ikr3gwpc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rb0NbqoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6nqty20zl7ikr3gwpc9.png" alt="Image of code for a remove method" width="730" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly, the reverse() method that I will share reverses the list in place.  This method takes no parameters.  See the steps and visualization below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g4zv-Z8L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ay0ea1qy6lzck3h713js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g4zv-Z8L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ay0ea1qy6lzck3h713js.png" alt="Drawing of reverse method" width="880" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pRSnE6DZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f9i1ls0i0f9ot1ifonb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pRSnE6DZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f9i1ls0i0f9ot1ifonb.png" alt="Drawing of reverse method continued" width="880" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of code for a reverse() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Q2AfKVz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qi0utqynjina6f4heoy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Q2AfKVz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qi0utqynjina6f4heoy.png" alt="Image of code for a reverse method" width="741" height="654"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity of these insert(), remove(), and reverse() methods for a Singly Linked List are O(n) linear time because the number of operations increases as the lists' length increases.&lt;/p&gt;

&lt;p&gt;Writing out the steps and drawing the visualizations really helped me better my understanding of creating methods for Singly Linked Lists, and my hope is that this is helpful to someone else, too.  However, there is still so much more for me to learn, so feel free to share your comments or corrections if there is anything written above that is incorrect. 🙂&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Singly Linked List Series: Creating get() and set() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 10 Dec 2022 18:03:13 +0000</pubDate>
      <link>https://dev.to/tartope/singly-linked-list-series-creating-get-and-set-methods-with-javascript-3o51</link>
      <guid>https://dev.to/tartope/singly-linked-list-series-creating-get-and-set-methods-with-javascript-3o51</guid>
      <description>&lt;p&gt;One can create a number of methods to manipulate a Singly Linked List.  Today, I will do my best to share what I understand about creating get() and set() methods.  A get() method receives an index parameter and retrieves a node at that particular index.  Since Singly Linked Lists are not indexed like arrays, one must create a counter to keep track of "indexes."  Let's start with a visualization for creating this method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b2aFyx95--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5do74tuni82enjqrcom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b2aFyx95--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5do74tuni82enjqrcom.png" alt="Drawing that shows how to build a get method" width="880" height="818"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: if the index is a negative number or greater than or equal to the length of the list, you can return undefined because that index does not exist.  Otherwise, follow the steps above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a get() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zdnEtciC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3ou53tc6trlnkpvhhqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zdnEtciC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3ou53tc6trlnkpvhhqt.png" alt="Code that shows how to build a get method" width="697" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A set() method changes the value of a particular node.  This method accepts index and value parameters.  The visualization looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SbfUQ6Bg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v93lqyx2m45rhvuntg29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SbfUQ6Bg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v93lqyx2m45rhvuntg29.png" alt="Drawing that shows how to build a set method" width="880" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of code for a set() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H0tqtiKF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni9du3aw56cy5930yp9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H0tqtiKF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni9du3aw56cy5930yp9w.png" alt="Code that shows how to build a set method" width="745" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity of a get() and set() method for a Singly Linked List is O(n) linear time because the number of operations increases as the lists' length increases.  As I learn more about these topics, the methods become a bit more complex.  Share your comments or corrections if there is anything written above that is incorrect.  Next week, I will share what I have learned about creating insert() and remove() methods.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Singly Linked List Series: Creating shift() and unshift() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 03 Dec 2022 16:55:40 +0000</pubDate>
      <link>https://dev.to/tartope/singly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2j37</link>
      <guid>https://dev.to/tartope/singly-linked-list-series-creating-shift-and-unshift-methods-with-javascript-2j37</guid>
      <description>&lt;p&gt;While continuing to learn data structures and algorithms, I want to continue to share my understanding in case others find it helpful.  Today, I want to share how to create shift() and unshift() methods.  A shift() method removes the first node from the beginning of a Singly Linked List.  Here is my visualization for creating  a shift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--emCvcR72--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z91h3xp2f3r9epz5sbmq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--emCvcR72--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z91h3xp2f3r9epz5sbmq.png" alt="steps to create a shift method" width="880" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list.  If it is not empty, then follow the steps mentioned above.  A second edge case is to redefine the head and tail if the list becomes empty after multiple shift() method applications.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a shift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wOa8bder--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2j3iudqludjyl3fx5y9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wOa8bder--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2j3iudqludjyl3fx5y9.png" alt="image of shift method code" width="716" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An unshift method adds a node to the beginning of a Singly Linked List.  Here is my visualization for creating an unshift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tcbVMjpX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzy48vk11z4be00uzzd2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tcbVMjpX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzy48vk11z4be00uzzd2.png" alt="steps to create an unshift method" width="880" height="666"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6DZIVahM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opccqpj8s7p41h9qc6nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6DZIVahM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opccqpj8s7p41h9qc6nw.png" alt="steps to create an unshift method continued" width="880" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list.  If the list is not empty then follow the steps mentioned above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for an unshift() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8pk12rbG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g06elk77wimm8nh9clxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8pk12rbG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g06elk77wimm8nh9clxg.png" alt="image of unshift method code" width="603" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The time complexity of shift() and unshift() methods for a Singly Linked List is O(1).  No matter the length of the list, it takes the same number of steps to remove from the beginning or add to the beginning of the list.&lt;/p&gt;

&lt;p&gt;In the next part of this series, I will share what I have learned about creating a get() method to grab a chosen node, and a set() method to change the value of a chosen node.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Singly Linked List Series: Creating push() and pop() methods with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 26 Nov 2022 14:46:40 +0000</pubDate>
      <link>https://dev.to/tartope/singly-linked-list-series-creating-push-and-pop-methods-35n4</link>
      <guid>https://dev.to/tartope/singly-linked-list-series-creating-push-and-pop-methods-35n4</guid>
      <description>&lt;p&gt;Adding a node to the end of a Singly Linked List and removing a node from the end of a Singly Linked List is less difficult once you visually map out what needs to happen.  Here is my visualization for creating a push() method that adds a node to the end of a Singly Linked List:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XlvugPDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxagcgedx7g0i8271o44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XlvugPDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxagcgedx7g0i8271o44.png" alt="Image description" width="880" height="770"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h5sykz3i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wh6s4n1zgk5rq7cht8ge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h5sykz3i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wh6s4n1zgk5rq7cht8ge.png" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for an empty list.  If it is not empty then follow the steps mentioned above.&lt;/p&gt;

&lt;p&gt;Here is an example of code for a push() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l-J0lrIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nb9ot1i8geel837v29o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l-J0lrIc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nb9ot1i8geel837v29o.png" alt="Image description" width="604" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is my visualization for creating a pop() method that removes a node from the end of a Singly Linked List:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2JH9JnWT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3kx3difpldv95bo6lyp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2JH9JnWT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3kx3difpldv95bo6lyp.png" alt="Image description" width="880" height="719"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e3wjUXFa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1kcpgu2fr12o3k8fnzp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e3wjUXFa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1kcpgu2fr12o3k8fnzp.png" alt="Image description" width="880" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edge case: you can account for the list becoming empty.  If it becomes empty then follow the steps in the example code below.&lt;br&gt;
Here is an example of code for a pop() method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RdQBV1YC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7u7625egm3fktdm7i5h6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RdQBV1YC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7u7625egm3fktdm7i5h6.png" alt="Image description" width="812" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mapping out these visualizations helped increase my understanding of creating push() and pop() methods for Singly Linked Lists.  Hopefully, others will find this helpful too.  Feel free to share your corrections if I got anything wrong.😀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Singly Linked List Series: Node and Singly Linked List Classes with JavaScript</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 19 Nov 2022 13:45:10 +0000</pubDate>
      <link>https://dev.to/tartope/singly-linked-list-series-node-and-singly-linked-list-classes-54o0</link>
      <guid>https://dev.to/tartope/singly-linked-list-series-node-and-singly-linked-list-classes-54o0</guid>
      <description>&lt;p&gt;While currently studying data structures and algorithms, I thought this would be a good place to "think out loud" and possibly help others along the way.  I have been working on understanding Singly Linked Lists and here is what I have learned when it comes to building a Node class and a Singly Linked List class.  Feel free to share your corrections if I get anything incorrect.&lt;/p&gt;

&lt;p&gt;A Singly Linked List is a linear data structure.  It is composed of nodes; each node points to the next node while the last node points to null.  Unlike arrays, Singly Linked Lists are non-contiguous in memory, so new nodes can be added wherever there is space in memory.  Arrays are contiguous in memory so the elements must be stored right next to each other.  Arrays have a fixed size.  In order to add elements to an array, you must copy all the elements into another place in memory with more space.  Also, Singly Linked Lists are good at insertion and deletion at the beginning (the head), and insertion at the end (the tail).  It takes fewer operations to do this, so the time complexity is O(1) constant time.  However unlike arrays, Singly Linked Lists do not have indices, and random access of a node is not allowed.&lt;/p&gt;

&lt;p&gt;My understanding of the Node class is that it builds the node's structure.  A node is basically an object with a key/value pair: {value: value, next: null}.  Nodes are connected via their next values.  The next value points to the next node.  Here is an example of a node pointing to the next node:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovxo2unaihy9su3dzq1i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovxo2unaihy9su3dzq1i.png" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of code for a Node class that constructs the node:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz921km0bs6pj8lqaob1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz921km0bs6pj8lqaob1.png" alt="Image description" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Singly Linked List class builds the list's structure with the head, tail, and length.  Here is an example of code for a Singly Linked List class that constructs the list:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz8fbf3rmvzd64xmfcs0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz8fbf3rmvzd64xmfcs0.png" alt="Image description" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using these two classes, a Singly Linked List can be instantiated and built with nodes using the Node class.  Within the Singly Linked List, various methods can be written to access and manipulate the list.&lt;/p&gt;

&lt;p&gt;In the next part of this series, I will share what I have learned about adding nodes to the end of a list and removing nodes from the end of a list.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>Rails: A serializer for your serializer?</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Sat, 07 May 2022 21:46:43 +0000</pubDate>
      <link>https://dev.to/tartope/rails-a-serializer-for-your-serializer-p9p</link>
      <guid>https://dev.to/tartope/rails-a-serializer-for-your-serializer-p9p</guid>
      <description>&lt;p&gt;Getting used to serializers was tricky for me when I first learned of them.  Then came custom serializers. 😑  I now think of them as a serializer for your serializer.  Silly, I know.  A custom serializer can be used to streamline the JSON data that is returned.  Example: The models are director--&amp;lt; movies--&amp;lt; reviews.  The return needs to be JSON data for director that includes the streamlined data for all movies of that director.  Create a new serializer (DirectorMovieSerializer) and include only the attributes of movie that you want to be returned.  Don't forget to add the &lt;strong&gt;has_many :movies&lt;/strong&gt; relationship to your DirectorSerializer, and explicitly tell the DirectorSerializer to use the new serializer instead.  See the code below:&lt;/p&gt;

&lt;p&gt;DirectorSerializer:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ygaf2gpq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9jcgr2bm37uvl2vvr4i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ygaf2gpq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9jcgr2bm37uvl2vvr4i.png" alt="Image description" width="828" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add DirectorMovieSerializer:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K2bHoqA7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6zrayx2jrziozbvuf73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K2bHoqA7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6zrayx2jrziozbvuf73.png" alt="Image description" width="826" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JSON data to be returned:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1PApoRJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r899isp9dqhde29ltarx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1PApoRJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r899isp9dqhde29ltarx.png" alt="Image description" width="604" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The JSON data returned should be the director data and the streamlined movie data.  This made more sense to me when I started playing around with the code, so give it a try. 😀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using Serializers in Rails</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Fri, 06 May 2022 23:42:08 +0000</pubDate>
      <link>https://dev.to/tartope/using-serializers-in-rails-2nc1</link>
      <guid>https://dev.to/tartope/using-serializers-in-rails-2nc1</guid>
      <description>&lt;p&gt;Serializers can be used to customize JSON data for a single model.  However, they can also be used to handle associations between multiple models.  The &lt;strong&gt;has_many&lt;/strong&gt; and &lt;strong&gt;belongs_to&lt;/strong&gt; Active Record macros can assist.&lt;/p&gt;

&lt;p&gt;To use a serializer with a one-to-many association, add the belongs_to macro to the corresponding serializer.  Example: there are three models, episode--&amp;lt; appearances &amp;gt;--guests.  When the JSON data for appearances is returned, I want to include the data for episode and guest.  Since the relationships have been established in the model, I can include the same &lt;strong&gt;has_one :episode&lt;/strong&gt; and &lt;strong&gt;has_one :guest&lt;/strong&gt; relationship in the corresponding serializer.  Therefore, when the JSON data for appearance is returned, it will include the data for episode and guest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m2VgLfk4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi0v243bx14powrgyeqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m2VgLfk4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi0v243bx14powrgyeqi.png" alt="Image description" width="860" height="186"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lBpxq-DJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cr1bgopcjc5vw2t7qpot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lBpxq-DJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cr1bgopcjc5vw2t7qpot.png" alt="Image description" width="520" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same can be used with many-to-many associations.  Example: I want the JSON data to include guests along with data for episodes.  Including the &lt;strong&gt;has_many :guests&lt;/strong&gt; relationship in the corresponding episode serializer will return JSON data with the episode, and guests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ytYeSlvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bk0g7tj7g8d6tdwhdm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ytYeSlvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bk0g7tj7g8d6tdwhdm4.png" alt="Image description" width="742" height="220"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m4x6OMU5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvno5boo2supmjum6vo3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m4x6OMU5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvno5boo2supmjum6vo3.png" alt="Image description" width="570" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What helped me understand these concepts the most was seeing them in action.  Practice coding different serializers to see the JSON data that is returned.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ruby and Active Record Associations</title>
      <dc:creator>tartope</dc:creator>
      <pubDate>Thu, 14 Apr 2022 19:09:22 +0000</pubDate>
      <link>https://dev.to/tartope/ruby-and-active-record-associations-i77</link>
      <guid>https://dev.to/tartope/ruby-and-active-record-associations-i77</guid>
      <description>&lt;p&gt;Active Record Associations come in handy when working with multiple models (tables) in your database.  Having a good understanding of Active Record will make working with data across multiple models easier.  Associations you can build are one-to-many and many-to-many associations.  &lt;/p&gt;

&lt;p&gt;When you have two models a one-to-many association can be used.  For example, you have a database with the models: Games and Reviews.  In this case, you can imagine that a game can have many reviews, and a review will belong to one game.  The Review model will read as &lt;strong&gt;"belongs_to :game"&lt;/strong&gt;, and the Games model will read as &lt;strong&gt;"has_many :reviews"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When working with multiple models a many-to-many association is used here.  Now imagine you have a database with the models: Games, Reviews, and Users.  A user can have many reviews and be associated with many games through their reviews.  The Review model will read as &lt;strong&gt;"belongs_to :game"&lt;/strong&gt;, and &lt;strong&gt;"belongs_to :users"&lt;/strong&gt;.  The Games model will read as &lt;strong&gt;"has_many :reviews"&lt;/strong&gt; and include &lt;strong&gt;"has_many :users, through: :reviews"&lt;/strong&gt;.  The Users model will read as &lt;strong&gt;"has_many :reviews"&lt;/strong&gt; and include &lt;strong&gt;"has_many :games, through: :reviews"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Naming is important when using Active Record associations so be careful to use singular vs. plural naming conventions.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
