Showing posts with label sorted linked list. Show all posts
Showing posts with label sorted linked list. Show all posts

20130330

How to write cpp program to reverse a linked list



//C++ program for reversing single Linked list nodes 
Cpp program for implement reversing Single Linked List
Single linked list program for reversing the nodes
How to reverse linked list 
#include<iostream>
using namespace std;

struct node
{
node *next;
int data;
};
class ll
{
private:
node *start;
public:
ll(){start=NULL;}

void insert(int a)
{
cout<<"Inside Insert."<<endl;
node *newnode=new node;
newnode->data=a;
newnode->next=start;
start=newnode;
//return;
}
void display();
void del();
void reverse();
};

How to write sorted linked list program in cpp with class


How to write sorted linked list program in cpp with class
C++ Program for sorted single linked list with class
//sorted linked list latest
#include<iostream>
using namespace std;
struct node
{
int data;
node *next;
};
node *start=NULL;

void insert(int d)
{
node *newnode=new node;
newnode->data=d;
newnode->next=NULL;
//insert as first elt
if(start==NULL)
{