Lec 3 | Circular Linked List | Insertion | Data Structures

‪@VimalKaushik-g3t‬ Please Like, Share, and Subscribe. If any doubts or feedback, please comment below. In this video, we discussed about 1. Introduction to Circular Linked List 2. Insertion of a new node in a circular linked list. The logic is as follows, void insertion() { if(last == NULL) { printf("Empty List.\n"); return; } crl: printf("Enter position to insert:\n"); scanf("%d",&pos); if(pos(less than symbol)1 || pos(greater than symbol)n+1) { printf("Invalid position to insert.\n"); goto crl; } printf("Enter element to insert:\n"); temp = (crllst*)malloc(sizeof(crllst)); scanf("%d",&temp-(greater than symbol)data); temp-(greater than symbol)link == NULL; if(pos == 1) { temp-(greater than symbol)link = last-(greater than symbol)link; last-(greater than symbol)link = temp; } else if(pos == n+1) { temp-(greater than symbol)link = last-(greater than symbol)link; last-(greater than symbol)link = temp; last = temp; } else { crllst *ins = last-(greater than symbol)link; for(int i=1 ; i(less than symbol)pos-1 ; i++) { ins = ins-(greater than symbol)link; } temp-(greater than symbol)link = ins-(greater than symbol)link; ins-(greater than symbol)link = temp; } n++; printf("%d inserted at %d successfully.\n", temp-(greater than symbol)data, pos); }