Linkedlist Methods: 11 Thing You’re Forgetting to Do

How often do you forget to add something important to your LinkedList? If you answered “all the time” then you might want to read this article. This article covers some common things that you might forget to add to your LinkedList.

A linked list is a data structure where each element has a link pointing to its next element. The elements can be added or removed from the front or back of the list.

Here are 11 things you should remember to do when using LinkedList methods.

Section: add()
Description: Adds an element to the list. Takes the index and item to be added, and adds it to the list.


Section: set()
Description: Replaces the value at a specified index with another specified value. Takes the index and new value, and changes the value at that index to the new one.


Section: get()
Description: Returns a value at a specified index in the list. Takes an index, and returns the object at that location in the list.


Section: contains()
Description: Returns whether or not an item is in the list. Takes an Object and returns a boolean of whether or not it is in the list.


Section: remove()
Description: Removes a value from the list. Takes an index and removes that element from the list, shifting all other elements down by one.

Takeaway:

LinkedList methods differ from ArrayList methods
C++
#include <iostream>
using namespace std;

struct node{
int data;
node *next;
};

class linked_list{
private:node *head,*tail;

public:linked_list(){
head = NULL;
tail = NULL;
}

};

int main(){
linked_list a;
return 0;
}

Leave a Comment

We are offering free coding tuts

X