Algorithm for inserting data to singly 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, exit Step4: insertfront function 1.read element in data 2.set link[insertfnode]=header 3.data[insertfnode]=data 4.header=insertfnode insertend function 1.read the data in m 2.set ptr=header 3.find the last node and set the data to the last node insertany function 1.if insertnodeany!=null,then printbmemory underflow 2.else, read the data and location set data to the location if location not found,then print key not found Step5: stop
Comments
Post a Comment