A Writer by quotes, Web Developer by Brain, Indian by Heart,Music Lover by Soul, Inspirer by Words.

Home Top Ad

INSTAGRAM FOLLOW ME OR ASK ME ANY HELP 1. FOLLOW MY PAGE 2.  MY PROFILE 1. DLL - Dup Element In a given DoubleLinkedLis...

Double Linkedlist Learning Module

Image result for coders

INSTAGRAM FOLLOW ME OR ASK ME ANY HELP

1.DLL - Dup Element
In a given DoubleLinkedList (where each node has a character), there is one character which appears twice. Find a function to find the character and return it. Input: NULL<-h>e<=>l<=>l<=>o->NULL Output : 'l' Input: NULL<-a>s<=>d<=>f<=>g<=>h<=>j<=>a->NULL Output: 'a' //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.
#include "common.h" #include char func(struct DchNode * head){ char ch = '\0'; struct DchNode * temp,*temp1,*temp2; temp=head; while(temp!='\0') { temp1=temp; while(temp1->nextNode!='\0') { if(temp->ch==temp1->nextNode->ch) { temp2->ch=temp->ch; } temp1=temp1->nextNode; } temp=temp->nextNode; } return temp2->ch; }
Given a DoubleLinkedList (where each node has a character) insert a given character at the specified location Input: Input : NULL<-h>e<=>l<=>l<=>o->NULL Location: 3 (if the location is beyond LinkedList length, ignore) CharacterToInsert: 'm' Output: NULL<-h>e<=>m<=>l<=>l<=>o->NULL // here is the definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.
#include "common.h" struct DchNode * func(struct DchNode * head, int index, char ch) { struct DchNode *temp; temp=head; int i; struct DchNode *newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=ch; newnode->nextNode=NULL; newnode->prevNode=NULL; if(index==1) { head->prevNode=newnode; newnode->nextNode=head; head=newnode; } for(i=0;temp!='\0';i++) { if(i==index-2) { newnode->nextNode=temp->nextNode; newnode->prevNode=temp; temp->nextNode=newnode; if(newnode->nextNode!=NULL) { newnode->nextNode->prevNode=newnode; } } temp=temp->nextNode; } return head; }

Find the intersection of two given DoubleLinkedList (where each node has a character). Return the DoubleLinkedList which has character which appears in both DoubleLinkedList (same sequence order as DoubleLinkedList1). Input: DoubleLinkedList1: NULL<-h>e<=>l<=>l<=>o->NULL LinkedList2: NULL<-w>o<=>r<=>l<=>d->NULL Output: NULL<-l>o->NULL Input: LinkedList1: NULL<-h>i->NULL LinkedList2: NULL<-b>y<=>e->NULL Output: null // here is the definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" struct DchNode * func(struct DchNode * head1, struct DchNode * head2){ struct DchNode *cur,*newnode,*temp1,*temp2,*start; temp1=head1; temp2=head2; start =NULL; int a[256]={0}; if(temp1==temp2) { return temp1; } while(temp2!='\0') { a[temp2->ch]++; temp2=temp2->nextNode; } while(temp1!=NULL) { if(a[temp1->ch]==1) { a[temp1->ch]=0; newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp1->ch; newnode->prevNode='\0'; newnode->nextNode='\0'; if(start=='\0') { start=newnode; cur=newnode; } else { cur->nextNode=newnode; newnode->prevNode=cur; cur=newnode; } } else if(a[temp1->ch]!=0) { newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp1->ch; newnode->prevNode='\0'; newnode->nextNode='\0'; if(start=='\0') { start=newnode; cur=newnode; } else { cur->nextNode=newnode; newnode->prevNode=cur; cur=newnode; } } temp1=temp1->nextNode; } return start; }
Number is given in a DoubleLinkedList (where each node has one digit), find if it is jumper number, where the absolute difference consecutive digits is 1 Input: NULL<-2>3<=>4<=>5<=>4<=>3<=>4<=>3<=>2<=>1->NULL Output: true Input: NULL<-2>3<=>4<=>5<=>3<=>4->NULL Output: false // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.
#include "common.h" #include #include "ExpCUtils.h" BOOL func(struct DintNode * head){ struct DintNode *temp,*t=NULL; temp=head; int l=0,c=0; while(temp!='\0') { t=temp->nextNode; if(t!=NULL) if(abs((temp->num)-(t->num))!=1) { return false; } temp=temp->nextNode; } return true; }

Given DoubleLinkedList where each node has an integer, replace every element with least greatest element on the right Input: NULL<-10>12<=>5<=>40<=>21<=>70<=>1<=>49<=>37->NULL Output: NULL<-12>21<=>21<=>49<=>37<=>70<=>37<=>49<=>37->NULL // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include #include "ExpCUtils.h" struct DintNode * func(struct DintNode * head){ struct DintNode *temp=head,*temp1; int t=0; while(temp!=NULL) { t=temp->num; temp1=temp->nextNode; while(temp1!=NULL) { if(tnum&&t==temp->num) { t=temp1->num; } else if(temp1->num > temp->num && temp1->num < t) { t=temp1->num; } temp1=temp1->nextNode; } temp->num=t; temp=temp->nextNode; } return head; }


Given a Doublelinkedlist, where each node has a character, find the character which appeared the maximum time. If you have multiple character as result, return the first character in that list. Input: NULL<-h>e<=>l<=>l<=>o<=> <=>w<=>o<=>r<=>l<=>d->NULL Output : 'l' Input: NULL<-y>e<=>l<=>h<=>a<=>h<=>a->NULL Output: 'h' // here is the definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.
#include "common.h" #include "ExpCUtils.h" char func(struct DchNode * head){ char ch = '\0'; struct DchNode *temp=head; char a[256]={0}; int max=0; while(temp!='\0') { a[temp->ch]++; temp=temp->nextNode; } temp=head; while(temp!='\0') { if(maxch]) { max=a[temp->ch]; ch=temp->ch; } temp=temp->nextNode; } return ch; }

Given two DoubleLinkedList, where each list denotes an number where each node has one digit, return us a DoubleLinkedList which is the sum of these two numbers. Please DO NOT convert to integers to perform the addition. Input: DoubleLinkedList1: NULL<-1>4<=>5->NULL LinkedList2: NULL<-3>9->NULL Output: NULL<-1>8<=>4->NULL // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DintNode * func(struct DintNode * input1, struct DintNode * input2) { if(input1==NULL && input2==NULL) { return NULL; } else if(input2==NULL && input1!='\0') { return input1; } else if(input1=='\0' && input2!='\0') { return input2; } else if(input1->num==0 && input2->num==0) { return input1; } else{ struct DintNode *first=input1,*second=input2,*cur=NULL; long int x=0,y=0,sum=0,p=0; while(first!='\0') { x=x*10+first->num; first=first->nextNode; } while(second!='\0') { y=y*10+second->num; second=second->nextNode; } sum=x+y; while(sum!='\0') { p=sum%10; struct DintNode *newnode=(struct DintNode*)malloc(sizeof(struct DintNode)); newnode->num=p; sum=sum/10; newnode->prevNode='\0'; newnode->nextNode=cur; cur=newnode; if(cur->nextNode!='\0') { cur->nextNode->prevNode=cur; } } return cur; } }
Count the number of pairs in DoubleLinkedList (where each node has a integer) whose sum equals given sum (all elements are unique) Input: NULL<-0>2<=>5<=>7<=>4<=>6<=>10<=>20<=>-10->NULL Sum: 10 Output : 3 [(0, 10), (4, 6), (20, -10)] // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include #include "ExpCUtils.h" int func(struct DintNode * input, int sum){ // WRITE YOUR CODE HERE; int num = 0; struct DintNode *temp1,*temp2; temp1=input; while(temp1!='\0') { temp2= temp1->nextNode; while(temp2!='\0') { if(temp1->num+temp2->num==sum) { num++; } temp2= temp2->nextNode; } temp1=temp1->nextNode; } return num; }

Count the number of pairs in DoubleLinkedList (where each node has a integer) whose sum equals given sum (all elements are unique) Input: NULL<-0>2<=>5<=>7<=>4<=>6<=>10<=>20<=>-10->NULL Sum: 10 Output : 3 [(0, 10), (4, 6), (20, -10)] // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include #include "ExpCUtils.h" int func(struct DintNode * input, int sum){ // WRITE YOUR CODE HERE; int num = 0; struct DintNode *temp1,*temp2; temp1=input; while(temp1!='\0') { temp2= temp1->nextNode; while(temp2!='\0') { if(temp1->num+temp2->num==sum) { num++; } temp2= temp2->nextNode; } temp1=temp1->nextNode; } return num; }

Given a DoubleLinkedList (where each node has a character) remove duplicates characters and maintain the same order Input: NULL<-h>e<=>l<=>l<=>o<=>w<=>o<=>r<=>l<=>d<=>h<=>i->NULL Output: NULL<-h>e<=>l<=>o<=>w<=>r<=>d<=>h<=>i->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h"
#include "ExpCUtils.h"

struct DchNode * func(struct DchNode * head) {
 struct DchNode *temp,*temp1,*t;
      temp=head;
      while(temp!='\0')
      {
          temp1=temp->nextNode;
          while(temp1!='\0')
          {
           
              if(temp->ch==temp1->ch)
               {
                   
                   t=temp1->prevNode;
                  t->nextNode=temp1->nextNode;
                 temp1=temp1->nextNode;
                 if(temp1!=NULL)
                 temp1->prevNode=t;
                 
               }
               else
               {
              temp1=temp1->nextNode;
               }
          }
          temp=temp->nextNode;
      }

return head;
}
        

Given a DoubleLinkedList (where each node has a character) remove the given character Input: Input String: NULL<-h>e<=>l<=>l<=>o->NULL CharacterToRemove: 'l' Output: NULL<-h>e<=>o->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * head, char ch){ struct DchNode *temp,*newnode,*cur,*start; char c='\0'; temp=head; cur=NULL; while(temp!='\0') { if(temp->ch!=ch) { newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp->ch; newnode->prevNode='\0'; newnode->nextNode=cur; cur=newnode; if(cur->nextNode!='\0') { cur->nextNode->prevNode=cur; } } temp=temp->nextNode; } struct DchNode *t = NULL; struct DchNode *current = cur; while (current != NULL) { t = current->prevNode; current->prevNode = current->nextNode; current->nextNode = t; current = current->prevNode; } if(t!= NULL ) cur = t->prevNode; return cur; }

Given a input string (inputStr1) and reference string (inputStr2) as a DoubleLinkedLink, where each Node has a character, remove all the occurrence of character of reference string in the input string Input LinkedList: NULL<-h>e<=>l<=>l<=>o<=>w<=>o<=>r<=>l<=>d<=>h<=>i->NULL Deletion String: NULL<-l>h<=>e->NULL Output String: NULL<-h>o<=>w<=>o<=>r<=>d<=>i->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include #include "ExpCUtils.h" struct DchNode * func(struct DchNode * head1, struct DchNode * head2){ struct DchNode *temp1,*temp2,*cur,*newnode; temp1=head1; temp2=head2; int a[256]={0}; cur=NULL; while(temp2!='\0') { a[temp2->ch]++; temp2=temp2->nextNode; } while(temp1!='\0') { if(a[temp1->ch]==0) { newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp1->ch; newnode->prevNode='\0'; newnode->nextNode=cur; cur=newnode; if(cur->nextNode!='\0') { cur->nextNode->prevNode=cur; } } temp1=temp1->nextNode; } struct DchNode *t = NULL; struct DchNode *current = cur; while (current != NULL) { t = current->prevNode; current->prevNode = current->nextNode; current->nextNode = t; current = current->prevNode; } if(t!= NULL ) cur= t->prevNode; return cur; }

Given a string as DoubleLinkedList (where each node has a character), reverse the LinkedList Input: Input String: NULL<-m>i<=>k<=>e->NULL Output: NULL<-e>k<=>i<=>M->NULL Input String: NULL<-b>r<=>e<=>a<=>k->NULL Output: NULL<-k>a<=>e<=>r<=>b->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * head){ struct DchNode *t = NULL; struct DchNode *current = head; while (current != NULL) { t = current->prevNode; current->prevNode = current->nextNode; current->nextNode = t; current = current->prevNode; } if(t!= NULL ) head= t->prevNode; return head; }

Reverse a string (given a Doublelinkedlist, where each node has a character) in a group of given size. Every group of string of given size should be reversed. <-h><-l><-t><-h>//here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

Reverse a string (given a Doublelinkedlist, where each node has a character) in a group of given size. Every group of string of given size should be reversed. Input: MULL<-h>e<=>l<=>l<=>o<=> <=>m<=>a<=>s<=>t<=>e<=>r<=>4<=>5->NULL Size: 3 Output: NULL<-l>e<=>h<=> <=>o<=>l<=>s<=>a<=>m<=>r<=>e<=>t<=>5<=>4->NULL Input: NULL<-t>h<=>a<=>n<=>k<=> <=>y<=>o<=>u<=> <=>b<=>y<=>e->NULL Size: 2 Output: NULL<-h>t<=>n<=>a<=> <=>k<=>o<=>y<=> <=>u<=>y<=>b<=>e->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * str, int size) { if(str==NULL || size==0) { return str; } int l=1; struct DchNode *last=str; while(last->nextNode!=NULL) { l++; last=last->nextNode; } if(size>=l) { struct DchNode *first=str; int i=0,j=l; while(first!=last && ich; first->ch=last->ch; last->ch=temp; first=first->nextNode; last=last->prevNode; i++;j--; } return str; } else if(sizenextNode!=NULL) { struct DchNode *next=first; int count=1,i,j; while(countnextNode!=NULL) { next=next->nextNode; count++; } else break; } struct DchNode *t=next->nextNode; int rev=count/2,count1=0; while(count1ch; first->ch=next->ch; next->ch=temp; first=first->nextNode; next=next->prevNode; count1++; } first=t; } return str; } }

Given a DoubleLinkedList, where each node has character, rotate the LinkedList by given number 'n' Input: NULL<-a>b<=>c<=>d<=>e<=>f<=>g<=>h->NULL n: 4 Output: NULL<-e>f<=>g<=>h<=>a<=>b<=>c<=>d->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * str, int l) { if(l==0) return str; if(str==NULL) return NULL; struct DchNode *cur; cur=str; int n=0; while(cur!='\0') { n++; cur=cur->nextNode; } // printf("%d",l); if(lprevNode=NULL; int count=0;cur=str; while(countnextNode; } newnode=cur->nextNode; cur->nextNode->prevNode=NULL; cur->nextNode=NULL; cur=newnode; while(cur->nextNode!='\0') { cur=cur->nextNode; } cur->nextNode=str; str->prevNode=cur; cur->nextNode=str; return newnode; }

For a given DoubleLinkedList, which has character and the number of times the character appeared, decode to the full string. During decoding if the character appear only once, then no number will be next to that character. Input: NULL<-a>5<=>b<=>r<=>3->NULL Output: NULL<-a>a<=>a<=>a<=>a<=>b<=>r<=>r<=>r->NULL Input: NULL<-a>1<=>0<=>b<=>r<=>3<=>a<=>3->NULL Output: NULL<-a>a<=>a<=>a<=>a<=>a<=>a<=>a<=>a<=>a<=>b<=>r<=>r<=>r<=>a<=>a<=>a->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h"
#include "ExpCUtils.h"

struct DchNode * func(struct DchNode * str)
{
    struct DchNode *temp=str,*newnode,*cur=NULL,*start=NULL;
    int c=0;
    char ch='\0';
    while(temp!=NULL)
    {
        if(temp->ch>=97&&temp->ch<=122)
        {
            c=0;
            ch=temp->ch;
            newnode=(struct DchNode *)malloc(sizeof(struct DchNode));
            newnode->ch=temp->ch;
            newnode->prevNode='\0';
            newnode->nextNode='\0';
            if(start==NULL)
            {
                start=newnode;
                cur=newnode;
            }
            else{
            cur->nextNode=newnode;
            newnode->prevNode=cur;
            cur=newnode;
            }
        }
        else if(temp->ch>=48&&temp->ch<=57)
        {
            c=c*10+temp->ch-'0';
        }
        int j=0;
        while(j
        {
            newnode=(struct DchNode *)malloc(sizeof(struct DchNode));
            newnode->ch=ch;
            newnode->prevNode='\0';
            newnode->nextNode='\0';
             if(start==NULL)
            {
                start=newnode;
                cur=newnode;
            }
            else{
            cur->nextNode=newnode;
            newnode->prevNode=cur;
            cur=newnode;}
            j++;
        }
        temp=temp->nextNode;
    }
      return start;
}


For a given input DoubleLinkedList (where each node is character), count the contiguous characters and represent them in integers. If the contiguous count is 1, you need not add the integer. Input: NULL<-a>a<=>a<=>a<=>a<=>b<=>r<=>r<=>r->NULL Output: NULL<-a>5<=>b<=>r<=>3->NULL Input: NULL<-a>a<=>a<=>a<=>a<=>a<=>a<=>a<=>a<=>a<=>b<=>r<=>r<=>r<=>a<=>a<=>a->NULL Output: NULL<-a>1<=>0<=>b<=>r<=>3<=>a<=>3->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * str) { struct DchNode *temp=str,*head=NULL,*next,*temp1; int a=0; while(temp!=NULL) { struct DchNode *c=(struct DchNode *)malloc(sizeof(struct DchNode)); c->ch=temp->ch; c->nextNode=NULL; if(head==NULL) { head=c; c->prevNode=NULL;temp1=head; } else { temp1->nextNode=c;c->prevNode=temp1; temp1=c; } next=temp->nextNode;a=1; while(next!=NULL&&temp->ch==next->ch) { a++; next=next->nextNode; } temp=next; if(a<10 a="" amp="" dchnode="" malloc="" newnode-="" newnode="(struct" sizeof="" struct="">ch=(char(a+'0')); newnode->nextNode=NULL; newnode->prevNode=temp1; temp1->nextNode=newnode;temp1=newnode; } else if(a>=10) { { struct DchNode *newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=char((a/10)+'0'); newnode->nextNode=NULL; newnode->prevNode=temp1; temp1->nextNode=newnode;temp1=newnode; } { struct DchNode *newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=(char((a%10)+'0')); newnode->nextNode=NULL; newnode->prevNode=temp1; temp1->nextNode=newnode;temp1=newnode; } } } return head; }

Given an DoubleLinkedList (where each node has integer) find the second largest element (where array has only distinct elements) Input: NULL<-2>10<=>11<=>20<=>-5<=>40<=>60<=>90<=>1<=>100->NULL Output: 90 // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" #include int func(struct DintNode * input){ struct DintNode *temp=input; int f,s; f=temp->num; s=0; while(temp->nextNode!=NULL) { if(fnextNode->num ) { s=f; f=temp->nextNode->num; } else if(snextNode->num) { s=temp->nextNode->num; } else if(s==f) { s=temp->nextNode->num; } temp=temp->nextNode; } return s; }
Given a input two DoubleLinkedList (inputlist1) and (inputlist2), merge these two DoubleLinkedList by combining elements of same index Input String: NULL<-h>e<=>l<=>l<=>o->NULL Deletion String: NULL<-1>2<=>3->NULL Output String: NULL<-h>1<=>e<=>2<=>l<=>3<=>l<=>o->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; };
NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h"
#include "ExpCUtils.h"
struct DchNode *  func(struct DchNode *  head1, struct DchNode *  head2) {
        struct DchNode *prev1,*prev2,*cur1,*cur2;
cur1=head1;
cur2=head2;
if(cur1==NULL && cur2!=NULL)
    {
        return cur2;
    }
while(cur1!=NULL&&cur2!=NULL)
{
    prev1=cur1;
    prev2=cur2;
    cur1=cur1->nextNode;
    cur2=cur2->nextNode;
   
    if(prev1->nextNode==NULL)
    {
        prev1->nextNode=prev2;
        prev2->prevNode=prev1;
    }
    else if(prev2->nextNode==NULL)
    {
        prev1->nextNode=prev2;
        prev2->prevNode=prev1;
        prev2->nextNode=cur1;
        cur1->prevNode=prev2;
    }
    else 
    {
        prev1->nextNode=prev2;
        prev2->prevNode=prev1;
        prev2->nextNode=cur1;
         cur1->prevNode=prev2;
    }
}
return head1;
}

      
Given a DoubleLinkedList (each node is a character), split the LinkedList to half and reverse each half Input: Input String: NULL<-m>i<=>k<=>e->NULL Output: NULL<-i>M<=>e<=>k->NULL Input String: NULL<-b>r<=>e<=>a<=>k->NULL Output: NULL<-r>b<=>e<=>k<=>a->NULL //here is the class definition of DchNode public class DchNode { public char ch; public DchNode nextNode; public DchNode prevNode; public DchNode(char ch){ this.ch = ch; } } //Here is the Definition of DchNode for C Language struct DchNode { char ch; struct DchNode * nextNode; struct DchNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.
#include "common.h" #include "ExpCUtils.h" struct DchNode * func(struct DchNode * str) { if(str==NULL) return NULL; struct DchNode *temp,*newnode,*head1=NULL,*head2=NULL,*cur; int i=0,k=0,m=0,l=0; temp=str; while(temp!='\0') { l++; temp=temp->nextNode; } if(l==1) return str; temp=str; m=l/2; k=l%2; while(ich=temp->ch; newnode->prevNode=NULL; newnode->nextNode=head1; if(head1==NULL) cur=newnode; head1=newnode; if(head1->nextNode!='\0') { head1->nextNode->prevNode=newnode; } i++; temp=temp->nextNode; } if(k==1) { newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp->ch; newnode->nextNode='\0'; newnode->prevNode='\0'; cur->nextNode=newnode; newnode->prevNode=cur; cur=newnode; temp=temp->nextNode; } while(temp!=NULL) { newnode=(struct DchNode *)malloc(sizeof(struct DchNode)); newnode->ch=temp->ch; newnode->prevNode='\0'; newnode->nextNode=head2; head2=newnode; if(head2->nextNode!=NULL) head2->nextNode->prevNode=newnode; temp=temp->nextNode; } cur->nextNode=head2; head2->prevNode=cur; return head1; }

Given DoubleLinkedList (where each node is integer), replace each element with the count of number of elements which are greater towards its right Input: NULL<-10>12<=>5<=>40<=>21<=>70<=>1<=>49<=>37->NULL Output: NULL<-6>5<=>5<=>3<=>3<=>0<=>2<=>0<=>0->NULL // here is the definition of DintNode public class DintNode { public int num; public DintNode nextNode; public DintNode prevNode; public DintNode(int num){ this.num = num; } } //Here is the Definition of DintNode for C Language struct DintNode { int num; struct DintNode * nextNode; struct DintNode * prevNode; }; NOTE: Do not use any printf or scanf statements while writing answers in C Language.

#include "common.h" #include "ExpCUtils.h" struct DintNode * func(struct DintNode * input) { struct DintNode *temp=input,*newnode,*cur,*temp1; int count=0; cur=NULL; while(temp!=NULL) { temp1=temp->nextNode; count=0; while(temp1!=NULL) { if(temp1->num>temp->num) { count++; } temp1=temp1->nextNode; } { newnode=(struct DintNode *)malloc(sizeof( struct DintNode)); newnode->num=count; newnode->prevNode=NULL; newnode->nextNode=cur; cur=newnode; if(cur->nextNode!=NULL) { cur->nextNode->prevNode=newnode; } } temp=temp->nextNode; } struct DintNode *t = NULL; struct DintNode *current = cur; while (current != NULL) { t = current->prevNode; current->prevNode = current->nextNode; current->nextNode = t; current = current->prevNode; } if(t!= NULL ) cur= t->prevNode; return cur; }