How to create a linked list in R?

How to create a linked list in R?

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]]
#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]]

Relevant Projects

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

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.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.