see my code why showing run time error
// Made by Kunal Saini
// Date - 10-11-19
// Topic - Linkedlist
// insertion
// deletion
// searching
#include
using namespace std;
class node{
public:
int data;
node* next;
//constructor
node(int n)
{
data=n;
next=NULL;
}
};
void insertathead(node &head,int data)
{
noden = new node(data);
n->next=head;
head=n;
}
void print(node *head)
{
while(head!=NULL)
{
cout<data<<"–>";
head=head->next;
}
cout<<endl;
}
node* midpoint(node*head)
{
if(head==NULL || head->next==NULL)
return head;
node *fast=head->next;
node *slow=head;
while(fast!=NULL || fast->next!=NULL)
{
fast=fast->next->next;
slow=slow->next;
}
return slow;
}
int main()
{
node* head=NULL;
//node* head2=NULL;
insertathead(head,1);
insertathead(head,2);
insertathead(head,3);
insertathead(head,4);
print(head);
node*m=midpoint(head);
cout<data;
//head= reverserec(head);
// cout<<head<<endl;//<<head2;
return 0;
}