Category : data-structures

The function deleteLast() is not working. struct node { int data; struct node* next; }; struct node *head=NULL, *newNode, *temp; void insertFirst(int data) { newNode= new node; newNode->data=data; newNode->next=head; head=newNode; } void deleteFirst() { newNode=head; head=head->next; free(newNode); } void deleteLast() { newNode=head; while(newNode->next!=NULL) { newNode=newNode->next; temp=newNode->next; } newNode->next=NULL; free(temp); } void print() { newNode=head; while(newNode!=NULL) ..

Read more

I want to write following project: Books in library are described as following: author; title; label1, label2, label3… Book may have few labels. Sample data in txt file: Herbert; Dune; sci-fi; desert; Shakespeare; Hamlet; tragedy, baroque; I want to display books by labels. For example: desert: Herbert; Dune; sci-fi: Herbert; Dune; tragedy: Shakespeare; Hamlet; baroque: ..

Read more

I wrote this piece of code for merging two sorted arrays:- class Solution { public: void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) { int p1=m-1, p2=n-1, i=m+n-1; while(p2>=0){ if(p1>=0 && nums1[p1]<nums2[p2]){ nums1[i]=nums2[p2]; p2–; }//if else{ nums1[i]=nums1[p1]; p1–; } i–; } }//fn }; This is throwing up a runtime error. Can someone help me ..

Read more

Problem Statement React Developer Community is a community of React developers. It allows developers to reach out to others and discuss various topics around JS programming. This community has been modeled as a directed social network graph. The Nagging React newbie A Nagging React newbieB is constantly troubling React expert A. React Expert A needs ..

Read more