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

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

End-to-End Speech Emotion Recognition Project using ANN
Speech Emotion Recognition using RAVDESS Audio Dataset - Build an Artificial Neural Network Model to Classify Audio Data into various Emotions like Sad, Happy, Angry, and Neutral

Learn to Build an End-to-End Machine Learning Pipeline - Part 2
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, incorporating Hopsworks' feature store and Weights and Biases for model experimentation.

Credit Card Default Prediction using Machine learning techniques
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Build Piecewise and Spline Regression Models in Python
In this Regression Project, you will learn how to build a piecewise and spline regression model from scratch in Python to predict the points scored by a sports team.

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.

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

Build CI/CD Pipeline for Machine Learning Projects using Jenkins
In this project, you will learn how to create a CI/CD pipeline for a search engine application using Jenkins.

AWS MLOps Project for Gaussian Process Time Series Modeling
MLOps Project to Build and Deploy a Gaussian Process Time Series Model in Python on AWS

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Time Series Project to Build a Multiple Linear Regression Model
Learn to build a Multiple linear regression model in Python on Time Series Data

OSZAR »