Algorithm for implementation of doubly linked list
Algorithm:
Step1: Start Step2: Read the case in ch and data Step3: Switch ch Case1, perform insertfront function Case2, perform insertend function Case3,perform insertany function Case4,perform deletefront function Case5, perform deleteend function Case6, perform deleteany function Case7, exit insertfront function 1.if insertfnode=null ,then print memory underflow 2.else read the element in data ptr=header data[insertfnode]=data llink[insertfnode]=null rlink[insertfnode]=ptr header=insertfnode llink[ptr]=insertfnode insertend function 1.if insertenode=null ,then print memory underflow 2.else read the data in m ptr=header find the last node and set m in last node and set llink[insertenode]=ptr rlink[insertenode]=null insertany function 1.if insertenodeany=null, then print memory underflow 2.else find the given location of the element set the data to the location set llink and rlink of the data deletefront function 1.if ptr=null,then print the list is empty 2.else ptr1=rlink[ptr] llink[ptr1]=null header=ptr1 deleteend function 1.if ptr=null,then print list is empty 2.else find the last node and asign it to ptr free(ptr) deleteany function 1.if ptr=null,then print list is empty 2.else Read the data to be deleted find the location of the data if ptr=null ,then print key not found else,free(ptr) Step4: stop
Comments
Post a Comment