
Algorithms Homework Help
- 20th May, 2022
- 16:52 PM
int fun(int arrival[ ],int departure[ ],int n) { // suppose n elements in the both array // consider array to be 1 indexed sort(arrival); sort(departure); // Sort both the array using any of the faster sort complexity O(Nlogn) Int i=2; Int j=1; Int ans=1; // final answer we will return Int cur=1; // current status of platform needed while(i<=n && j<=n) { if(arrival[i] <= departure[j] ) { cur++; i++; } Else { cur--; j++; } ans=max(ans,cur); } return ans; } //// Time complexity -: O(NlogN) N -: denotes number of element in the array //// Space complexity -: O(1) we don't used any extra space at all just variables in our function **************************************** Bool fun(Node root,Node par) { if(root==NULL) return false; if(par==NULL) { root->val=0; fun(root->left,root); fun(root->right,root); Return true; } if(par->left==root){ root->val=2*par->val+1; } Else root->val=2*par->val+2; fun(root->left,root); fun(root->right,root); return true; } /// Time complexity just O(N) where N denotes the number of nodes in the tree /// Space complexity O(1) as we are not using any extra space we are just doing everything // in place
Recent Blogs

Apr 09, 2023

Apr 09, 2023

Apr 09, 2023

Apr 09, 2023

Apr 07, 2023

Apr 07, 2023

Apr 07, 2023

Apr 07, 2023

Apr 06, 2023

Apr 06, 2023

Apr 06, 2023

Apr 06, 2023

Apr 06, 2023

Apr 06, 2023

Apr 06, 2023

Apr 05, 2023

Apr 05, 2023

Apr 05, 2023

Apr 04, 2023

Apr 04, 2023

Apr 04, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 03, 2023

Apr 02, 2023

Apr 02, 2023

Apr 02, 2023

Apr 02, 2023

Mar 27, 2023

Mar 27, 2023

Mar 27, 2023

Mar 19, 2023

Mar 13, 2023

Mar 13, 2023

Mar 13, 2023

Jan 26, 2023

Jan 26, 2023

Jan 19, 2023

Jan 19, 2023

Jan 19, 2023

Dec 29, 2022

Dec 22, 2022

Dec 22, 2022

Nov 24, 2022

Nov 24, 2022

Nov 24, 2022

Nov 17, 2022

Nov 17, 2022

Nov 17, 2022

Nov 11, 2022

Nov 11, 2022

Nov 11, 2022

Nov 04, 2022

Nov 04, 2022

Oct 20, 2022

Oct 20, 2022

Oct 20, 2022

Oct 20, 2022

Oct 19, 2022

Aug 18, 2022

Aug 18, 2022

Aug 12, 2022

Aug 12, 2022

Aug 05, 2022

Aug 05, 2022

Jul 29, 2022

Jul 29, 2022

Jul 22, 2022

Jul 22, 2022

Jul 15, 2022

Jul 15, 2022

Jul 08, 2022

Jun 30, 2022

Jun 30, 2022

Jun 17, 2022

Jun 17, 2022

Jun 09, 2022

Jun 09, 2022

Jun 02, 2022

Jun 02, 2022

May 26, 2022

May 26, 2022

May 13, 2022

May 13, 2022

May 05, 2022

May 05, 2022

Apr 29, 2022

Apr 29, 2022

Apr 14, 2022

Apr 14, 2022

Apr 06, 2022

Apr 06, 2022

Mar 31, 2022

Mar 31, 2022

Feb 11, 2022

Feb 04, 2022

Feb 04, 2022

Jan 27, 2022

Jan 27, 2022

Jan 19, 2022

Jan 19, 2022

Jan 07, 2022

Dec 23, 2021

Dec 23, 2021

Nov 10, 2021

Nov 10, 2021

Nov 02, 2021

Nov 02, 2021

Oct 26, 2021

Oct 26, 2021

Oct 19, 2021

Oct 19, 2021

Oct 12, 2021

Oct 08, 2021

Oct 08, 2021

Sep 14, 2021

Sep 07, 2021

Sep 07, 2021

Aug 31, 2021

Aug 31, 2021

Aug 26, 2021

Aug 26, 2021

Sep 04, 2020

Aug 05, 2020

Aug 05, 2020

Jul 28, 2020

Jul 28, 2020

Jul 28, 2020

Mar 20, 2020

Mar 20, 2020

Mar 20, 2020

Feb 13, 2020

Feb 13, 2020

Feb 13, 2020

Feb 13, 2020

Sep 08, 2019

Sep 05, 2019

Jul 05, 2019

Jul 04, 2019

Jun 05, 2019

Jun 05, 2019

Jun 05, 2019

Jun 05, 2019

Jun 05, 2019

Jun 05, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

May 12, 2019

Feb 27, 2019

Feb 27, 2019

Feb 27, 2019
Popular Tags
About Us
The Programming Assignment Help believes in helping students to write clean codes that are simple to read and easy to execute. We provide assignment help, homework help, online tutoring, and project help in programming to customers across the globe.