[wpdm_package id=’1373′] Algorithm: Use the level order traversal or Breadth First Traversal. Insert the element where we find the left/right node as NULL. [sourcecode lang=”cpp”]…
[wpdm_package id=’1375′] Algorithm: Create a Stack. Till the half of the string length, push the characters of the string into the stack. If it is…
[wpdm_package id=’1377′] Algorithm – Keep two pointer c and m. Always move c pointer at twice the speed of m pointer. If the linked list…
[wpdm_package id=’1379′] Algorithm: visit the root. While traversing level l, keep all the elements at level l+1 in queue. Go to the next level and…
[wpdm_package id=’1386′] [wpdm_package id=’1390′] Algorithm Move the pointer 2 nodes at a time. If it points to a null node means Linked list is of…
[wpdm_package id=’1388′] [wpdm_package id=’1390′] [sourcecode lang=”cpp”] int Print_Reverse_LinkedList(intnode *c){ if(c==NULL) return 0; Print_Reverse_LinkedList(c->next); cout<<c->data<<"\t"; return 1; } [/sourcecode]
[wpdm_package id=’1410′] Inserting element at end: [sourcecode lang=”cpp”] void insertAtEnd(int d) { node *current=head; node *temp=new node(d); if(head==NULL) { head=temp; temp->next=temp; } else { for(;current->next!=head;current=current->next);…
On September 21, 2013 Some of us attended placement process for SAP Labs India. First round was an on-line test conducted on a website. Online…
[wpdm_package id=’1398′] Algorithm: [sourcecode lang=”cpp”] node *MergeList(node *a,node *b) { node *result=NULL; if(a==NULL) return b; if(b==NULL) return a; if(a->data<=b->data) { result=a; result->next=MergeList(a->next,b); } else {…
[wpdm_package id=’1343′] [wpdm_package id=’1345′] Algorithm: Use 2 pointers ptr and newptr. Initially both points to head node of the list. Move ptr ‘n’ times. After…