How to create a linked list in R?

This recipe helps you create a linked list in R

Recipe Objective

Linked list is a data structure which contains sequence of linked data elements called nodes. These nodes points to the next node using a pointer. ​

After array, linked list is the most used data structure . There are three important concepts that needs to the stated for us to understand Linked List better.

  1. Link: Every link has the capability to store data which is also known as data element.
  2. First: A linked list always posseses a connection to the starting link called First
  3. Next: Every link in the linked list also contain a link to the next link which is called Next.

Linked list is not only reduces access time due to it's dynamic capabilities but also carries out intertion and deletion operation easily. One of the disadvantages includes that reverse traversing becomes way too diificult in this data structure. ​

There are three types of linked list: ​

  1. Simple Linked list
  2. Double linked list
  3. Circular linked list

They are mainly used to create trees and can be represented as a list. In R, there is no need to reference the following and previous items as R uses indexing for the same purpose. ​

This recipe demonstrates how to create a tree using linked list. ​

Example: Creation of a Tree

A tree is just a list which contains other lists

Tree = list(list(2, 4), list(3, list(6, 12)))

The creation of this tree uses the concept of linked list discussed above.

#accessing the left child: list(2,4) Tree[[1]]

2
4

#accessing the right child: list(3, list(6,12)) Tree[[2]]

1. 3
2. A. 6
   B. 12

#accessing the right child of right chils: list(6,12) Tree[[2]][[2]]

6
12

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

Classification Projects on Machine Learning for Beginners - 1
Classification ML Project for Beginners - A Hands-On Approach to Implementing Different Types of Classification Algorithms in Machine Learning for Predictive Modelling

MLOps using Azure Devops to Deploy a Classification Model
In this MLOps Azure project, you will learn how to deploy a classification machine learning model to predict the customer's license status on Azure through scalable CI/CD ML pipelines.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

ML Model Deployment on AWS for Customer Churn Prediction
MLOps Project-Deploy Machine Learning Model to Production Python on AWS for Customer Churn Prediction

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Build a Logistic Regression Model in Python from Scratch
Regression project to implement logistic regression in python from scratch on streaming app data.

Build Classification Algorithms for Digital Transformation[Banking]
Implement a machine learning approach using various classification techniques in Python to examine the digitalisation process of bank customers.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.