Thursday, 18 August 2016

Doubly LinkedList Operations in C++

/*
Title: C++ program to demonstrate doubly linked list.
Author: Pavan Jaiswal
Operations: 
 1. Add nodes to linkedlist at the begining and at the end.
 2. Display the linkedlist.
 All rest operations can be made as per your choice.
 
*/

#include "iostream"
#include "stdlib.h"
using namespace std;

/* structure to hold list */
struct list{
 string name;
 int rollno;
 struct list *next, *prev;
}*first=NULL, *last=NULL, *node=NULL, *start=NULL;

/* class to perform operations */
class LinkedList{
 public:
 /* member function declaration */
  void insertAtBegining(); 
  void insertAtEnd();
  void displayList();
};

Singly LinkedList Operations in C++

/*
Title: Singly linkedlist demonstration in C++
Author: Pavan Jaiswal
Operations: 1. Add node to list
  2. Display list
  Rest operations can added as per your choice. 
*/

#include "iostream"
#include "stdlib.h"

using namespace std;

struct list{
 string name;
 struct list *next;
}*head=NULL, *tail=NULL, *node=NULL;

class SinlgyLinkedList{
 public:
  void addNodeToList();
  void displayList();
};