Complete C++ Placement Course (Data Structures+Algorithm) : • C++ Full Course | C++... Telegram: t.me/apnikaksh... Instagram: / dhattarwalaman Notes of this Lecture:
Everyone, just try to appreciate the effort that they are putting for us . Be patient , they have to upload c++ , java , web development,.. so it takes time Just be patient and appreciate them Thank you Aman bhaiyya and the whole team 👍
Suppose you have two 3's, Koi v index dede uska value to 3 hi set hoga tree mai right, By the way binary search tree me duplicate values allowed v nahi hai
I think providing notes was a gimmick to attract people toward this playlist because no notes are provided for the later videos which have the main + complex topics...!!!
Aman bhaiyaa ji bahut achha kaam kar rahe ho, But sath sath jhoot bhi bolna sikha rahe ho, Aapne start m bola tha notes, practice ke liye questions , brain teaser milte rahenge but yahan tak aate aate sab gayab ho gaya 😭
this code is not running when the preOrder arr is 1 2 3 4 5 6 7 and its the inOrder arr is 4 2 5 1 6 3 7 formally it is not running for more than 5 values
i am having an issue the class node above the code is not shown properly in this video can you please sent the class node as i have skipped some classes..
Plz help ,i am not getting any output.Whats the mistake here? #include using namespace std; class node{ public: int data; node* left; node* right; node(int val){ data=val; left=NULL; right=NULL; } }; int search(int inorder[],int start,int end,int curr){ for(int i=start;iend){ return NULL; }
int curr=preorder[idx]; idx++; node* root=new node(curr);
static isliye kar rahe hai taaki recurssion use karte samay idx ka value purana wala store rahe.agar static use nahi karenge toh idx =0 ya 1 hi hoga aur error throw karega
@@ROHITKUMAR-pn4gj Declaring static variables inside a class has a different method, you have to declare them outside the class, like this. class sample { public: static int i; }; int sample::i = 0;
Why it is not working i typed the same code as shown in the video? #include using namespace std; struct Node{ int data; struct node* left; struct node* right; Node(int val){ data = val; left = NULL; right = NULL; } }; int search(int inorder[], int start, int end, int curr){ for(int i=start; i end){ return NULL; } int curr = preorder[idx]; idx++; Node* node = new Node(curr); if(start == end){ return node; } int pos = search(inorder, start, end, curr); node->left = buildTree(preorder, inorder, start, pos-1); node->right = buildTree(preorder, inorder, pos+1, end); return node; } void inorderprint(Node* root){ if(root == NULL) return; inorderprint(root -> left); cout
Sir agar aap ko notes nahi provide karne theek hai per program to provide kar do. Vasie kitna bolate ho free content kaha hai free content video ke saath notes bhi free content ke andr hi ate hai.
Bhai time lagta hai banda ek channel nhi chala rha hai... or itne mehnat kr rha hai free mai lectures de rha hai.... jaake purane notes check kroo unme update hua hai unko or detailed kr diya hai.... improvement mai time lagta hai orr notes koi bdee baat nhi hai... khud bhi lecture dekh k bna skte ho.... rough mai likh lo video dekhte waqt fir fair up kroo nhi toh gfg pr dekh loo
//Whats wrong in this code #include using namespace std; struct node{ int data; node* left; node* right; node(int val){ data =val; left=NULL; right=NULL; } }; int position(int inor[],int start, int end, int curr){ for(int i=start;iend){ return NULL; } static int idx=0; int curr =pre[idx]; idx++; node* n1=new node(curr);
Because we are using static variable and this variable once initialised keep on increasing even in recursive call. You call google "static variable" for more clarification.
I m not sure but because of recursion I guess.every time the recursion statement is called, the index will start from 0 and will result in wrong ans . So the keyword static keeps the value of idx static throughout the program
A variable when declared static, its value persists through the function calls. For example in this case idx is initialized with 0 and then incremented. So now before calling the function idx is 1. After the function is called idx value is not initialized to 0 again because it is declared static. Now when idx is incremented its value becomes 2..... If it was not declared static everytime the function was called its value would begin from 0 and would never become more than 1 in this case.
you always miss something in the code and add it at the last , which makes it confusing . for example the return node in the last. try to write the code in one flow please.
include #include using namespace std; struct Node{ int data; struct Node*left; struct Node*right; Node(int val) { data = val; left = NULL; right = NULL; } }; int search(int inorder[], int start, int end, int curr) { for (int i = start; i
@@adityapai5147 abbe oo chilgozee....jaa kr videos dekh whaa 1 feb ko akhri lecture aya thaa////nd hme starting m kya bolla ki april tk compete hojaygaa....agr course adha krwana thaa too jaroorat kya thii///
@@dhruvkumar4326 Tere koi naukar nhi lga h ya paisa nhi dia h tune ki koi tujhe pdhaye woh apne pace se pdhayenge baaki jyada jaldi h toh resources ki kmi nhi h intellipat dekh le utube be 10 ghnte ka lecture h complete python
@@rishitiwari6200 abbbe oo gadhee///imp y nhi h course adha h ya pura//imp y h commitement kbhi puri nhi krte bhaiya.....python k course ka akhri video dekh kbb aya tha....oor phelaa dekh jha bhaiya bolrhe h 1st april tk khtm krwadenge.....oor teri jankari k lie btauu unacademy pr m plus subscriber hu or aman bhaiya s phy padhta hu...woohh 26 jan k baad hmari class lene ayee hi nhii....hamara sylaabus bechh m chordkrr chlegyee oor hzarooo bacho k future ko khrabb krdia
@@rishitiwari6200 abbe oo bhuuto ko smjhagya h bhaiya fraud h///unacademy prr m plus subsrbier huu...mtlb fees bharta hu......wha pr bhaiya hmara pagaal bnagyee//akhri class hmarii 26 jan ko thi phy ki///hmara syllabus bacha hua h///ndd wohh ahi nhi rhe h tbsee....naahi kuch btarhe h////fraud h bhaiyaa
@@dhruvkumar4326 jaa bhai tu logon ko iske fraud hone ka certificate bech bhai itna time waste mat kr aur jitna jaldi ho ske Pdhle aise logon ka committment dekhne baithega toh kuch na kr paega aur kisi ke upr dependent mt hua kr
You really made it much easier than other channels
Everyone, just try to appreciate the effort that they are putting for us .
Be patient , they have to upload c++ , java , web development,.. so it takes time
Just be patient and appreciate them
Thank you Aman bhaiyya and the whole team 👍
I was waiting for this golden comment after all they are providing this for free it takes time to create quality content
thank god these type of ppl exists. It feels so bad how others are humiliating the team in comment section without a pinch of appreciation
commented code for reference
struct node{
int data;
node* left = NULL;
node* right = NULL;
node(int data):data(data){}
};
int searchInOrder(int InOrder[],int start,int end,int curr){
for(int j=start;j
10 times better explanation than what that previous bhaiya would have explained
yes here is the code:
#include
using namespace std;
struct Node
{
int data;
struct Node *left;
struct Node *right;
Node(int value)
{
data = value;
left = NULL;
right = NULL;
}
};
int searchPosition(int inorder[], int start, int end, int curr)
{
for (int i = start; i end)
{
return NULL;
}
int curr = preorder[idx];
idx++;
Node *newroot = new Node(curr);
// if (start == end)
// {
// return newroot;
// }
int pos = searchPosition(inorder, start, end, curr);
newroot->left = buildTree(preorder, inorder, start, pos - 1);
newroot->right = buildTree(preorder, inorder, pos + 1, end);
return newroot;
}
void Inorderprint(Node *root)
{
if (root == NULL)
{
return;
}
Inorderprint(root->left);
cout data right);
}
int main()
{
int preorder[] = {1, 2, 4, 3, 5};
int inorder[] = {4, 2, 1, 5, 3};
Node *root = buildTree(preorder, inorder, 0, 4);
Inorderprint(root);
return 0;
}
Super video🤗🤗.. Concept/logic ekdam तगडे level pe clear ho gaya..♥️🔥🔥
Maja Agaya Mam....Mujhe aj pta chala apko Microsoft kue mila tha....badiya explain kiye hai ap...thanks
Please upload Notes as well !!
What are you going to do with notes lol?
@@scriptkiddie6151 😂😂😂 ye log bi na
But it should be possible when all the node values are unique otherwise the search function gives us random index
Suppose you have two 3's, Koi v index dede uska value to 3 hi set hoga tree mai right, By the way binary search tree me duplicate values allowed v nahi hai
@Overthinker_stuff node->left or node->right will be assigned as null when the base condition will be executed
Explainations have become awesome
ty AC team
best approach on the internet for this question
Thanks so much 😊😊😊😊😊😊😊
you guys have been doing great work...thanks a lot....great explanation
Dedi Shareda Inshallah sbho parrahy gy😊😊 Nice teaching method❤❤
It is really awesome. This is a video with perfect explanation and code😍😍😍
We really need the notes for this
I think providing notes was a gimmick to attract people toward this playlist because no notes are provided for the later videos which have the main + complex topics...!!!
Make yourself
why we need to make a (inorder)tree from inorder and preorder tree, when we already have output same as inorder tree?
Pls Include Time Complexity and space complexity With Videos Too
Full Source Code:
#include
using namespace std;
class Node {
public:
int data;
Node* left;
Node* right;
Node(int val){
data = val;
left = NULL;
right = NULL;
}
};
int search(int inorder[], int start,int end, int curr){
for(int i=start; i end) return NULL;
int curr = preorder[idx];
idx++;
Node* node = new Node(curr);
if(start == end) return node;
int pos = search(inorder, start, end, curr);
node->left = buildTree(preorder, inorder, start, pos-1);
node->right = buildTree(preorder, inorder, pos+1, end);
}
void inorderPrint(Node* root){
// cout
can you suggest me a good place to learn pointers like the one used
If we use HashMap (Java)for searching position it may become O(n)
really nice explanations.. thanks mam
I am waiting......
Thankyou shraddha mam😊
Mam aap agar shource code provide kr paye it can be more better
Superb explanation dhidhi
very helpful. thanks for uploading.
Thanku soo much sirji & Didi ji 🙏
That was an amazing explanation...
Thank u didi🔥🔥
condition : if(start==end) return node; is not necessary, right??? [ as base condition ,ie, if(start>end) return NULL; is enough]
yes base condition handles all the edges cases
Base cond'n is sufficient.
Thank you aman bhaiyya🙏🙌
Beautifully explained. Well done.
will ever base case come( s>e) ??
thanks
I wasted a whole hour trying to learn this. You guys made it so simple. Thankyou for all of it
+1
Notes please
Optimisation Needed
very similar to quick sort.
🙂
zaero...nice
why we take idx static type in buildtree method
my inorderPrint( ) function is printing preorder
what could be the error in my coding ?
You guys are really awesome.
Also thanks for adding that algorithm slide,it helped while revising.
yes adding algorithm helps a lot
what is time complexity?
n*n
Aman bhaiyaa ji bahut achha kaam kar rahe ho,
But sath sath jhoot bhi bolna sikha rahe ho,
Aapne start m bola tha notes, practice ke liye questions , brain teaser milte rahenge but yahan tak aate aate sab gayab ho gaya 😭
but this is not an optimised solution..the time complexity of this program is O(n^2)..which not an efficient one..
plz python walla course complete krdooo
What will search function return if there is one of the data in left of root is equal to root->data?? I think it will not return correct root pos
sleep saver 🤝
What is the complexity here?
In average case it should be nlog(n)
O(n2)
Please apload notes all lecture please sir
this code is not running when the preOrder arr is 1 2 3 4 5 6 7 and its the inOrder arr is 4 2 5 1 6 3 7
formally it is not running for more than 5 values
You might have not changed the value in the main function in build tree part
In passing the value in build tree
where could I find the notes for dsa c++
oye agr buildtree k last main return node na likho tab v root pointer acquire value of root node y???????
So, she take preorder as a input and print the same preorder --\(*_*)/--
yaar ye stub kya hai?
wah didi apne tho moj kar di
Please upload notes of the lecture
how buildtree function is returning address of root node to pointer root in main can somebody explain
getting error in printing inorder traversal
i am having an issue the class node above the code is not shown properly in this video can you please sent the class node as i have skipped some classes..
First watch those videos
can someone plz explain me the base condition of buildtree as i am not able to get that
Plzz upload web Dev course also
9:38 what is the difference between Node and node there??????
LHS signifies the new node that is being created and RHS signifies the value that is being stored in the new node
Plz help ,i am not getting any output.Whats the mistake here?
#include
using namespace std;
class node{
public:
int data;
node* left;
node* right;
node(int val){
data=val;
left=NULL;
right=NULL;
}
};
int search(int inorder[],int start,int end,int curr){
for(int i=start;iend){
return NULL;
}
int curr=preorder[idx];
idx++;
node* root=new node(curr);
if(start==end){
return root;}
int pos=search(inorder,start,end,curr);
root->left=formtree(preorder,inorder,start,pos-1);
root->right=formtree(preorder,inorder,pos+1,end);
return root;
}
void inorderprint(node* k){
if(k==NULL){
return;
}
inorderprint(k->left);
cout
bro same issue can u help pls?
They are deleting negative comments (majority) . that is why you can see the views and comments ratio. What a joke guys. the explanation is very bad.
9:10 what is the logic behind -writing the static in front of int index
static isliye kar rahe hai taaki recurssion use karte samay idx ka value purana wala store rahe.agar static use nahi karenge toh idx =0 ya 1 hi hoga aur error throw karega
Tum global bhi declare skte static ki jagah
@@palashagrawal2343 but in the gfg i submitted its giving runtime error for the static int 🤔
@@ROHITKUMAR-pn4gj Declaring static variables inside a class has a different method, you have to declare them outside the class, like this.
class sample
{
public:
static int i;
};
int sample::i = 0;
@@palashagrawal2343 ty bro.
Why it is not working i typed the same code as shown in the video?
#include
using namespace std;
struct Node{
int data;
struct node* left;
struct node* right;
Node(int val){
data = val;
left = NULL;
right = NULL;
}
};
int search(int inorder[], int start, int end, int curr){
for(int i=start; i end){
return NULL;
}
int curr = preorder[idx];
idx++;
Node* node = new Node(curr);
if(start == end){
return node;
}
int pos = search(inorder, start, end, curr); node->left = buildTree(preorder, inorder, start, pos-1);
node->right = buildTree(preorder, inorder, pos+1, end);
return node;
}
void inorderprint(Node* root){
if(root == NULL)
return;
inorderprint(root -> left);
cout
#include
using namespace std;
class Node{
public:
int data;
Node* left;
Node* right;
Node(int val){
data = val;
left = NULL;
right = NULL;
}
};
int search(int inorder[], int start, int end, int curr){
for(int i = start; i end){
return NULL;
}
int curr = preorder[idx];
idx++;
Node* node = new Node(curr);
/*if(start == end){
return node;
}*/
int pos = search(inorder, start, end, curr);
node->left = buildtree(preorder, inorder, start, pos-1);
node->right = buildtree(preorder, inorder, pos+1, end);
return node;
}
void inorderprint(Node* root){
if(root == NULL){
return;
}
inorderprint(root->left);
cout
because at starting you passed struct node*left and right (you have to pass in capital means struct Node*) because you initialize node with capitals .
Can we make binary trees for alphabets (char) instead of numbers😅😅
Yes, definately
pls add the notes
Sir agar aap ko notes nahi provide karne theek hai per program to provide kar do. Vasie kitna bolate ho free content kaha hai free content video ke saath notes bhi free content ke andr hi ate hai.
Bhai time lagta hai banda ek channel nhi chala rha hai... or itne mehnat kr rha hai free mai lectures de rha hai.... jaake purane notes check kroo unme update hua hai unko or detailed kr diya hai.... improvement mai time lagta hai orr notes koi bdee baat nhi hai... khud bhi lecture dekh k bna skte ho.... rough mai likh lo video dekhte waqt fir fair up kroo nhi toh gfg pr dekh loo
didi iska code toh de doo aap notes bahut hii jaruri hai iska
this course made me fall in love with coding
what if there are duplicate values in array , this will not work , any solutions ?
impossible for duplicate elements
Lol have u ever seen duplicates in a tree😂😂
*NOTES*
//Whats wrong in this code
#include
using namespace std;
struct node{
int data;
node* left;
node* right;
node(int val){
data =val;
left=NULL;
right=NULL;
}
};
int position(int inor[],int start, int end, int curr){
for(int i=start;iend){
return NULL;
}
static int idx=0;
int curr =pre[idx];
idx++;
node* n1=new node(curr);
if(start==end){
return n1;
}
int pos =position(inor,start,end,curr);
n1->left=build_tree(pre, inor, start, pos-1);
n1->right=build_tree(pre, inor, pos+1, end);
return n1;
}
void inorder(node* root){
if(root==NULL){
return;
}
inorder(root->left);
cout
nathing just input you taken is different so your output is diff
if you take the same value 12435 then the answer will be same
@@ashutoshsharma4420 use these values in preorder
plz send code
I m getting segmentation error can someone help me
there might be a fault in segment i.e not writing == or stufs like that
define the static indx outside the class as a global variable
@@sparshtaneja but what's the reason behind this
why static int is giving segmentation error
@@ROHITKUMAR-pn4gj I am not getting this error, can you share your code, if you are having this error.
Can anyone please explain me how idx value is increasing as it is redeclare every time
Because we are using static variable and this variable once initialised keep on increasing even in recursive call.
You call google "static variable" for more clarification.
@@isheoran ok got it tysm
@@isheoran gr8 thnx
Hello I want to know is there any update regarding Java Placement Course ...
code link
I am getting a segmentation fault. Anyone knows how to fix it??
it is because of declaring i=0 in buildtree function
instead pass it in function
Yes it works 🙏🏻
Not intuitive, frankly.
Please provide notes earlier
What is the beat at the start ?🥺
this is tough
why without static right output do not come
I m not sure but because of recursion I guess.every time the recursion statement is called, the index will start from 0 and will result in wrong ans . So the keyword static keeps the value of idx static throughout the program
A variable when declared static, its value persists through the function calls. For example in this case idx is initialized with 0 and then incremented. So now before calling the function idx is 1. After the function is called idx value is not initialized to 0 again because it is declared static. Now when idx is incremented its value becomes 2.....
If it was not declared static everytime the function was called its value would begin from 0 and would never become more than 1 in this case.
@@sajankumarkar8237 why we are not using call by reference instead of static
@@ritik51 Do you mean calling idx by reference, if yes then you can do this, you can even use call by value.
but when using call by reference , i am getting an extra 4 (for the example in the video) in the end , any idea why ?
you always miss something in the code and add it at the last , which makes it confusing . for example the return node in the last. try to write the code in one flow please.
Do you even write codes in flow or you takes 3 days to write a code?
lecture is really good but why notes are not there
plz
include
#include
using namespace std;
struct Node{
int data;
struct Node*left;
struct Node*right;
Node(int val) {
data = val;
left = NULL;
right = NULL;
}
};
int search(int inorder[], int start, int end, int curr) {
for (int i = start; i
preorder ki sequence galat likhi hai apany
apne paagal bnadia hmaraa...pyhton ka adha course upload kia h
@@adityapai5147 abbe oo chilgozee....jaa kr videos dekh whaa 1 feb ko akhri lecture aya thaa////nd hme starting m kya bolla ki april tk compete hojaygaa....agr course adha krwana thaa too jaroorat kya thii///
@@dhruvkumar4326 Tere koi naukar nhi lga h ya paisa nhi dia h tune ki koi tujhe pdhaye woh apne pace se pdhayenge baaki jyada jaldi h toh resources ki kmi nhi h intellipat dekh le utube be 10 ghnte ka lecture h complete python
@@rishitiwari6200 abbbe oo gadhee///imp y nhi h course adha h ya pura//imp y h commitement kbhi puri nhi krte bhaiya.....python k course ka akhri video dekh kbb aya tha....oor phelaa dekh jha bhaiya bolrhe h 1st april tk khtm krwadenge.....oor teri jankari k lie btauu unacademy pr m plus subscriber hu or aman bhaiya s phy padhta hu...woohh 26 jan k baad hmari class lene ayee hi nhii....hamara sylaabus bechh m chordkrr chlegyee oor hzarooo bacho k future ko khrabb krdia
@@rishitiwari6200 abbe oo bhuuto ko smjhagya h bhaiya fraud h///unacademy prr m plus subsrbier huu...mtlb fees bharta hu......wha pr bhaiya hmara pagaal bnagyee//akhri class hmarii 26 jan ko thi phy ki///hmara syllabus bacha hua h///ndd wohh ahi nhi rhe h tbsee....naahi kuch btarhe h////fraud h bhaiyaa
@@dhruvkumar4326 jaa bhai tu logon ko iske fraud hone ka certificate bech bhai itna time waste mat kr aur jitna jaldi ho ske Pdhle aise logon ka committment dekhne baithega toh kuch na kr paega aur kisi ke upr dependent mt hua kr
#include
using namespace std;
class Node
{
public:
int data;
Node* left;
Node* right;
Node(int val)
{
data = val;
left = NULL;
right = NULL;
}
};
int search(int inorder[], int start, int end, int curr)
{
for(int i = start; i end)
{
return NULL;
}
int curr = preorder[idx];
idx++;
Node* node = new Node(curr);
if(start == end)
{
return node;
}
int pos = search(inorder, start, end, curr);
node->left = buildTree(preorder,inorder,start,pos-1);
node->right = buildTree(preorder,inorder,pos+1,end);
return node;
}
void inorderprint(Node* root)
{
Node* temp = root;
if(temp == NULL)
{
return;
}
inorderprint(temp->left);
coutn;
int preorder[] = {1,2,4,3,5};
// for(int i=0; i>preorder[i];
// }
int inorder[] = {4,2,1,5,3};
// for(int i=0; i>inorder[i];
// }
Node* root = buildTree(preorder,inorder,0,4);
inorderprint(root);
}
output : 2 4 3 1 5 0
it's showing wrong. In which line, I am doing wrong
In Search function loop continues till end i.e for(int i=start;i
notes plz