Personal Brand: Week 1

Photo by Oskar Yildiz on Unsplash

Nodes

As you may know, nodes are a basic data structure that contains data and one or more links to other nodes. Nodes can be used, for example, to represent a tree structure or linked lists. Depending on the data structure it might be possible to traverse from one node to another.

Linked Lists

A linked list is a linear data structure, and its elements are not stored in a contiguous location. In its place, elements are linked through pointers. Linked lists are formed by nodes. Singly-linked lists have nodes with values and a pointer with the address to the next node, doubly linked lists, on the other hand, have values and a pointer to the next and previous nodes.

Photo by Kaleidico on Unsplash

Doubly Linked List

The main difference against singly-linked lists is that we can traverse the list not only from head to tail but also from tail to head. We can add elements to the tail by updating the link of the last tail to point to the new tail.

Linked List Techniques

There are different forms of interacting with linked lists that can be useful to accomplish different tasks. These techniques can come in handy to have in your problem-solving repertoire.

Swapping Nodes in a Linked List

A technique where we search through the entire linked list (using while loops and changing our current node with a method like current_node.get_next_node()) until we find the position of the specified nodes to swap so we can arrange the correctly.

Two-pointer Linked List Techniques

By moving pointers over the nodes of a linked list you can solve different problems, for example, you can move two pointers from the head of a linked list, with one pointer moving at a double rate so that when the faster pointer gets at the end of the list, the slower pointer will be located at the middle.

Photo by Markus Winkler on Unsplash

Searching Arrays

There are different ways of searching through arrays, depending on how the data is received, one algorithm can perform better than the other. Here I present the implementation of 2 important and very useful searching algorithms.

Linear Search

A searching algorithm that consists of going through each element of an array until the value matches the element that we are searching for, in the end, we will return the index of the element.

Binary search

This searching algorithm can only be performed in sorted lists. It consists of the following steps:

  1. Go to the middle element of the list. If that’s the element we are searching for return its index.
  2. If the element we are searching for is greater than the value in the middle, do step 1 with the right half (since the left is less than the value in the middle).
  3. If the element we are searching for is less than the value in the middle, do step 1 with the left half.

Queues

Queues are data structures formed by nodes that, as in a line in a ticket stand, items are removed in the same order that they are added. Can be implemented using linked lists.

Stacks

Stacks are also very interesting data structures. They are made of nodes as well and can be implemented using lists. Literally means arranging objects one over the other, just like a bunch of plates.

Photo by Kelly Sikkema on Unsplash

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eduardo Ahumada

Eduardo Ahumada

8 Followers

Engineer looking to help and contribute. Learning about Software development and Computer Science.