We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 15: Linked List
Day 15: Linked List
+ 0 comments Python
def insert(self,head,data): nd = Node(data) nth = head if head is None: head = nd else: while nth.next is not None: nth = nth.next nth.next = nd return head
+ 0 comments c++
Node* insert(Node *head,int data) { //Complete this method if(head==NULL){ Node* g=new Node(data); return g; } head->next=insert(head->next,data); return head; }
+ 0 comments c
Node* insert(Node *head,int data) { //Complete this function if(head==NULL){ Node* g=(Node*)malloc(sizeof(Node)); g->data=data; g->next=NULL; return g; } head->next=insert(head->next,data); return head; }
+ 0 comments
+ 0 comments C solution
Node *temp = (Node*)malloc(sizeof(Node)); temp->data = data; temp->next = NULL; if(NULL == head){ head = temp; } else{ Node *ptr = head; while(ptr->next){ ptr = ptr->next; } ptr->next = temp; } return head;
Load more conversations
Sort 681 Discussions, By:
Please Login in order to post a comment