Multiple Parenthesis Matching Using Stack with C Code

  Рет қаралды 112,325

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 237
@CodeWithHarry
@CodeWithHarry 4 жыл бұрын
Ek galti ho gai choti si code me jo ki baad me theek bhi kar di! Maaf kar dena🙏🙏🙏
@eklavyakumar1204
@eklavyakumar1204 4 жыл бұрын
Bhya ap free m pra rhe ho wahii bohot h tnks bhai 🙏 🙏
@georgianabhishek3561
@georgianabhishek3561 4 жыл бұрын
Please flutter ka tutorial leao bhai plz 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
@mastiwithaishvi337
@mastiwithaishvi337 4 жыл бұрын
Koi ni harry bhai aap bhi insaan hi to ho baaki maine aapka pura python course follow kara hai aur a ye bahut maze aate hai aap free me hamara itna bhala katre ho god bless you and your family🙏🙏🙏🙏❤❤
@ShivamKumar-yp4vv
@ShivamKumar-yp4vv 4 жыл бұрын
Sir really you are making future of INDIA
@harshitrathi3077
@harshitrathi3077 4 жыл бұрын
aree bhaiya you are doing this much for us and telling like this.....you are god for us ....just keep on uploading Videos on Programming and Coding Till I Get Any Job ( CURRENTLY IN BTECH CSE 2ND YEAR) 😅😅
@nextnotification9857
@nextnotification9857 Жыл бұрын
I have written code myself after understanding the logic but it took me 1 hr to write it
@aryanshrivastava2344
@aryanshrivastava2344 2 жыл бұрын
To understand this problem : Just remember As we traverse the string ( expression ) from left to right for ( int i = 0; i < len; i++) { 1. if (we encounter a opening parentheses push it on to the stack) 2. Else if ( we encounter a closing parentheses ) if ( stack is empty || top element don't pair with closing parentheses ) return false; else{ pop() } } After the loop just check at last if ( stack is empty ) // means all opening parentheses found their closing counterparts return true; else // some opening parentheses not found their closing counterparts so they are not popped return false; For expression to be balanced every closure should be for the last unclosed [ ( ) ] ( -> last unclosed ) -> closure we encounter first // it will be for the last unclosed which is ) ( -> will be popped Updated list : [ ] [ -> last unclosed ] -> closure we encounter next Hope you understand !!
@smartattributeslearning1559
@smartattributeslearning1559 Жыл бұрын
Kya Bat karte hain sir jaan de denge jaan😍😍😍 like to bahut dur ki bat hain(But majak se hatke really amazing sir u r great sir . sir kabhi kabhi mujhe lagta hai ki engineering student ke liye hire mathmetics ke liye Dr. Gajandra Prohit or programming ke liye Harry Boss ager na hote to hamara kya hota) aap dono ko egineering students ke traf se bahut der sare Thank you and love you both sir. jo engineering students sahmat hain like kare
@coderzadda
@coderzadda 4 жыл бұрын
Thanks, Harry sir dil se......You create bright future for India.
@PythonGuruji
@PythonGuruji 4 жыл бұрын
harry bhai coding me gltiya n ho to programmer kaise banpayega koi..huge respect
@VoiceWithAdarsh
@VoiceWithAdarsh 4 жыл бұрын
Haary ❤️
@shubhangiagrawal336
@shubhangiagrawal336 4 жыл бұрын
You are a one in million...Thankyou for helping out in DSA
@Aman-du2rl
@Aman-du2rl 4 жыл бұрын
Bhai me apke video series dekh raha hu python vali bohot mza a raha h literally apne bohot mehnath se padhya i liked that. After i complete it i will definitely do the next programming language what you tough on the KZbin.... Thank you very much Aman
@engineerbhai7642
@engineerbhai7642 4 жыл бұрын
You deserve millions subscribers. Excellent coder in you tube.
@dariofairhall2695
@dariofairhall2695 2 жыл бұрын
We can use stacktop() If we check open and close parenthesis match befor poping element from stack. At that case, we need top element from stack which is need to be checked and then If matched, then pop and continue checking Else expression not balanced
@parallax8916
@parallax8916 2 жыл бұрын
exactly!! i was also thinking about the same logic. we do not need to pop directly, instead we check first , match it with stackTop, if it matches, then only we pop, else we return 0.
@Shorts-iv2zk
@Shorts-iv2zk Жыл бұрын
int mulParenMatch(char* exp){ struct Stack*s; s->top=-1; s->size=50; s->arr=(char*)malloc(s->size*sizeof(char)); for(int i=0;exp[i]!='\0';i++){ if(exp[i]=='(' || exp[i]=='{' || exp[i]=='['){ push(s,exp[i]); } else if(exp[i]==')' && s->arr[s->top]=='('){ if(isEmpty(s)){ return 0; } else{ pop(s); } } else if(exp[i]=='}' && s->arr[s->top]=='{'){ if(isEmpty(s)){ return 0; } else{ pop(s); } } else if(exp[i]==']' && s->arr[s->top]=='['){ if(isEmpty(s)){ return 0; } else{ pop(s); } } } return isEmpty(s); } then what's wrong in this code??
@mdmatiurrahman7373
@mdmatiurrahman7373 4 жыл бұрын
Someone....plz..Give a Noble Prize to Harry sir....Watching your C tutorial... And I am now at 9:09:35 ....Understood everything clearly...And love from Bangladesh...
@udaywahi
@udaywahi 2 жыл бұрын
তুই হিন্দি বুঝতে পারি
@pushkarnath1904
@pushkarnath1904 3 жыл бұрын
Yes I have done the programs in my code blocks already 😍😍
@pickypotato6617
@pickypotato6617 4 жыл бұрын
you are my inspiration to start my channel
@georgianabhishek3561
@georgianabhishek3561 4 жыл бұрын
Bahit tagdi video hai bhai Love you keep doing awesome work like this🖐👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
@harshulagarwal1755
@harshulagarwal1755 4 жыл бұрын
Harry bhai aap pls competitive programming ke bhee questions karwa diya karo from Codechef
@uditpanjiyar3203
@uditpanjiyar3203 Жыл бұрын
iss level kaa question solve ker kai maja aa gaya ❤👌💯💯💯
@abdullahmubarak2360
@abdullahmubarak2360 4 жыл бұрын
sir ap ki c tutorial par video awesome ha .thanks alot❤❤
@Iamarealdiamond3
@Iamarealdiamond3 4 жыл бұрын
Harry is God of Coding. 🙏
@aninditasarkar2470
@aninditasarkar2470 4 жыл бұрын
Sir, could you please make a video on character input and output, file copying , and character counting in c?
@anjalibajaj8824
@anjalibajaj8824 4 жыл бұрын
Badiya Harry bhai very helpful
@IG_Hunter
@IG_Hunter 4 жыл бұрын
To great explanation Love u bro You are great
@shatviksmit3388
@shatviksmit3388 3 жыл бұрын
0:41 Sir I suppose that in our previous code while traversing the list our condition should be if it is '(' , '[' '{' then push in the stack and if it is ')', ']' or '}' then pop from the stack Like if correct
@Lila12386
@Lila12386 4 жыл бұрын
Nice Explanation Harry Bhai👍👍👍👍
@shyamsoni5153
@shyamsoni5153 2 жыл бұрын
Harry bhai app to ds ke sath advance c bhi sikha rhe ho 👍🏻
@pooja581
@pooja581 3 жыл бұрын
Thank you Bhaiya such amazing videos ❤❤
@agyeytripathi8582
@agyeytripathi8582 3 жыл бұрын
you are best teacher
@siddharthasarmah9266
@siddharthasarmah9266 4 жыл бұрын
Thanks for saving my life
@pavanpandya9080
@pavanpandya9080 4 жыл бұрын
Excellent explanation ❤️
@HasanAli-vp6ci
@HasanAli-vp6ci 4 жыл бұрын
Excellent explanation 👌
@shreshthakamal158
@shreshthakamal158 4 жыл бұрын
Thank you Harry Bhai
@ELECTRODYNAMICS_07
@ELECTRODYNAMICS_07 4 жыл бұрын
You are doing a great job 😘
@KitsuneLucy05
@KitsuneLucy05 4 жыл бұрын
He protecc.... He attacc..... But most importantly...... He the best coder who know the tec 🔥🔥🔥 Following your C 15 hour tutorial bro keep up the awesome work👍👍👍
@kamaldakshkrishnan9990
@kamaldakshkrishnan9990 2 жыл бұрын
superb bro
@samuelfrank9947
@samuelfrank9947 3 жыл бұрын
Thanks a lot bhaiya, Enjoyed this video
@joyrajlongjam7121
@joyrajlongjam7121 3 жыл бұрын
If code is not running then allocate memory dynamically for the stack in the parenthesisMatch function i.e struct stack*sp = (struct stack *)malloc(sizeof(struct stack));
@kushal6065
@kushal6065 3 жыл бұрын
but it works on mine without allocating memory, how?
@rohanprasad7601
@rohanprasad7601 2 жыл бұрын
thanks..
@AbhishekGupta-qh8xh
@AbhishekGupta-qh8xh 2 жыл бұрын
thanks bro..but can you explain why was it was not working without dynamic memory allocation
@satyamkarn3277
@satyamkarn3277 2 жыл бұрын
Yes
@tanshadow9165
@tanshadow9165 4 жыл бұрын
Setup tour plzzz!! 👇
@silentmahi3030
@silentmahi3030 2 жыл бұрын
Excellent
@parthkukkar7770
@parthkukkar7770 3 жыл бұрын
thanks a lot sir this playlist is very helpful
@arunbaranpal838
@arunbaranpal838 4 жыл бұрын
Awesome video 👍👍👍👍
@dalvinder_kaur
@dalvinder_kaur 2 жыл бұрын
Thankyou 🙏
@rounakagarwal3286
@rounakagarwal3286 4 жыл бұрын
Bhai JavaScript Framework ke upar Ek combine video bnao jismein aap angular, react aur vue ka tips and tricks do ki Ham kisko choose Kare or fir uske upar aap course banoo, Main aapka web development ka JavaScript tutorials in Hindi ka course complete kar liya hai aur Mujhe front end web developer banna hai to front end web developer ke liye JavaScript and CSS frameworks bhi Aane chahie aur mujhe bahut jyada confusion ho rahi hai ki main JavaScript Framework kaunsa Sikho to please bhai kam karo.AUR EK VIDEO BANAO. My humble request to you. You are such a good teacher to teach programming languages that's why i am asking to you.
@manavdeepsingh1297
@manavdeepsingh1297 4 жыл бұрын
Very good video 👍😀😀 keep it up 👌
@myhomegaming5
@myhomegaming5 Жыл бұрын
Thank you sir🤩
@georgianabhishek3561
@georgianabhishek3561 4 жыл бұрын
Please flutter ka tutorial le ao bhai please Btw love your video's 👍👍👍👍👍
@DipsOfficial802
@DipsOfficial802 2 жыл бұрын
Thank you harry bhai for such awesome course 🙏🙏🙏
@antu_saha
@antu_saha 2 жыл бұрын
Thanks harry bhi
@adarshkumargupta.
@adarshkumargupta. 2 жыл бұрын
< ................Gjjb ka explanation !!!!!!!!!!!!! mast hai.........>
@ShaksD-vf3go
@ShaksD-vf3go 4 ай бұрын
Goat=harry bhai❤❤
@mohinishendye1040
@mohinishendye1040 3 жыл бұрын
Great 👍👍
@ashutoshsoni9412
@ashutoshsoni9412 4 жыл бұрын
Harry bhai waise "I'll see you next time" ki jagah "U'll see me next time" hona chahiye na 😂😂
@sailendrachettri8521
@sailendrachettri8521 3 жыл бұрын
Funny!
@ayushmourya812
@ayushmourya812 4 жыл бұрын
Thanku Harry Bhai
@_HarshitChaurasia
@_HarshitChaurasia 2 жыл бұрын
Nice sirr
@TravelingSane
@TravelingSane 3 жыл бұрын
thankew
@_HarshitChaurasia
@_HarshitChaurasia 2 жыл бұрын
Appki puri video dekh rha hu
@arpanchaudhuri8486
@arpanchaudhuri8486 4 жыл бұрын
Best as usual❤️❤️❤️❤️
@JAYYY.J
@JAYYY.J Жыл бұрын
Harry sir did it before 1:20
@Avneet_09
@Avneet_09 4 жыл бұрын
Already accessed
@Sans_K5
@Sans_K5 2 жыл бұрын
thanks_Sir💜
@balramjadon3556
@balramjadon3556 4 жыл бұрын
Best Bhai ❤️👌💯
@shivanshutyagi83
@shivanshutyagi83 3 жыл бұрын
Harry bhai👏👏
@ridham7120
@ridham7120 4 жыл бұрын
Harry bhai aap online classes chalu kar do
@princesukhala7106
@princesukhala7106 2 жыл бұрын
Done done
@sdgamers7311
@sdgamers7311 4 жыл бұрын
Sir no udemy...🖒🖒 Only Code with Harry...🖒🖒
@memeTHUGofficial
@memeTHUGofficial 4 жыл бұрын
Mast video
@codewithharryfanchannel559
@codewithharryfanchannel559 4 жыл бұрын
Thank you sir.
@YASHSINGH-se7qu
@YASHSINGH-se7qu 3 жыл бұрын
sir ek doubt hai , apne kahi pr stack ko heap me memory k liye request nhi kiya .....struct stack *sp=(struct stact*)malloc(sizeof(struct stack)) ....?
@arya7577
@arya7577 4 жыл бұрын
Sir Your Python For Absolute Beginners's Source code is not coming when i am clicking on the link ....sir please sort it out ...do not forget to reply me as well as correct me if i am wrong ...please do reply sir....Myself Arya
@sahibisht6051
@sahibisht6051 4 жыл бұрын
Harry bahi issue hai (how to minimize main-thread work in blogger) please batiya Harry bhaiya
@Mustafa-ji3cp
@Mustafa-ji3cp 4 жыл бұрын
Love you 😊😊❤ legend
@utkarshsingh245
@utkarshsingh245 2 жыл бұрын
#include using namespace std; struct stack{ int size; int top; char* arr; }; void push(struct stack* p, char element){ if(p->top == p->size-1){ coutarr = new char(p->size); for(int i = 0; itop == -1){ return 0; } else{ if(p->arr[p->top] == '(' && s[i] == ')'){ pop(p); } else if(p->arr[p->top] == '[' && s[i] == ']'){ pop(p); } else if(p->arr[p->top] == '{' && s[i] == '}'){ pop(p); } else{ return 0; } } } } if(p->top == -1){ return 1; } else{ return 0; } } int main() { string s = "([7-9}-7)"; if(parathesischeck(s)){ cout
@bulukivine8238
@bulukivine8238 3 жыл бұрын
Please upload vedios on Graph data structure harry bhai
@abdullahmubarak2360
@abdullahmubarak2360 4 жыл бұрын
sir ap ki typing speed kitni hai ? or kitni typing speed programing kar lae achi hai?
@ashispanda8808
@ashispanda8808 2 жыл бұрын
Please make data structures and algorithms using python with notes in 1 video
@Sunny-nt3vg
@Sunny-nt3vg 4 жыл бұрын
React JS 😍😍
@webcreationstudio7088
@webcreationstudio7088 3 жыл бұрын
*sir aap Multiple Parenthesis Matching ko as an homework bhi de sakhte thay*
@sahilsingh1155
@sahilsingh1155 4 жыл бұрын
Mere DS ke karta dharta aap hi ho🙏😁
@elonmusk893
@elonmusk893 4 жыл бұрын
Aaj to java wala episode aane wala tha na sir ???
@RohanDasRD
@RohanDasRD 4 жыл бұрын
10k to go
@sailendrachettri8521
@sailendrachettri8521 3 жыл бұрын
1m Near.
@pupjetofficial
@pupjetofficial 4 жыл бұрын
bhai why don't we just increase value of top when we find opening parentheses and decrease it when we find closing one.....and using if else we can solve this.... we don't need to make an array....or stack for this
@ansarikashif4514
@ansarikashif4514 4 ай бұрын
18:52
@adarshraj3208
@adarshraj3208 3 жыл бұрын
We can also this problem by creating three structure pointers for three different brackets as it is shown below int parenthesis(char *equation) { struct stack *s; s = (struct stack *)malloc(sizeof(struct stack)); s->size = strlen(equation); s->arr = (char *)malloc(s->size * sizeof(char)); s->top = -1; struct stack *t; t = (struct stack *)malloc(sizeof(struct stack)); t->size = strlen(equation); t->arr = (char *)malloc(s->size * sizeof(char)); t->top = -1; struct stack *u; u = (struct stack *)malloc(sizeof(struct stack)); u->size = strlen(equation); u->arr = (char *)malloc(s->size * sizeof(char)); u->top = -1; for (int i = 0; i < s->size; i++) { if (equation[i] == '(') { push(s, '('); } else if (equation[i] == ')') { if (isempty(s)) { return 0; break; } else { pop(s); } } else if (equation[i] == '{') { push(t, '{'); } else if (equation[i] == '}') { if (isempty(t)) { return 0; break; } else { pop(t); } } else if (equation[i] == '[') { push(u, '['); } else if (equation[i] == ']') { if (isempty(u)) { return 0; break; } else { pop(u); } } } if (isempty(s)==isempty(t)==isempty(u)==1) { return 1; } else { return 0; } }
@Pranauv
@Pranauv 2 жыл бұрын
bro i dont think this will work for wrong brackets expression like -- [(34*21])
@himanshudash-c4c
@himanshudash-c4c Жыл бұрын
no problem
@rayangamedev1912
@rayangamedev1912 4 жыл бұрын
bhai c# ka course kab laho ge
@elon_chacha
@elon_chacha 4 жыл бұрын
Harry sir, ye data structures ka course kitne moth ka h? Plz ek bar bta dijiye bdi kripa hogi....🙏
@rohitshah8904
@rohitshah8904 4 жыл бұрын
👍
@mohitgoel2975
@mohitgoel2975 4 жыл бұрын
👍👍👍
@SachinKumar-xt8ny
@SachinKumar-xt8ny 4 жыл бұрын
Bss ek dil chahiye Bhai.... 7th comment
@abhhishekabs
@abhhishekabs 3 жыл бұрын
Why do we need a different match function ? Can't we match the popped character and the exp[I] directly ? Will it give errors ?
@manjitsharma889
@manjitsharma889 3 жыл бұрын
First of all, the popped character will always be one of these three ' ( ' or ' { ' or ' [ ' , now according to you, popped_char == exp[i] will be ' ( ' == ' ) ' which is false. ' ( ' is a different character than ' ) '. Matching the popped character and exp[i] will be matching ' ( ' with ' ) ' or ' ( ' with ' ] ' both of these are always false. suppose you've this expression " [ ( a + b ] ) " then first we'll push the character '[', then '(' will be pushed, when ']' is encountered, the top element in the stack is popped, that is '(' is popped, now we use the match function to match the following set '(' with ' ) ' and ' [ ' with ']'. here above, the popped element is ' ( ', but the current character is ' ] ', hence the match function will return false, since the following pair - ' ( ' , ' ] ' didn't match.
@amalasebastian9968
@amalasebastian9968 3 жыл бұрын
@@manjitsharma889 thank you so much for the explanation
@yashwanthpasaladi2714
@yashwanthpasaladi2714 2 жыл бұрын
same doubt
@MEAmitKourav
@MEAmitKourav 4 жыл бұрын
Sir, Whenever you add new part to program Please tell b/w which to part you pasted it.
@lakhveer0362
@lakhveer0362 4 жыл бұрын
😍😘🙏🙏🙏✌✌✌legend 😍
@noi375
@noi375 3 жыл бұрын
Sir I am using online compiler and your code was giving same error as in the previous video i.e. segmentation fault please reply my question 🥺🥺🥺🥺
@RohitSharma-rk6xd
@RohitSharma-rk6xd 3 жыл бұрын
run those code in code blocks!! bro! i am also try to run those code in online compiler and it throws TLE error!
@NitinKumar-xm7hu
@NitinKumar-xm7hu 3 жыл бұрын
You've to use "struct Parenthesis * p= (struct Parenthesis *)malloc(sizeof(struct Parenthesis))" instead of "struct Parenthesis * p" only .
@ShivamKumar-yp4vv
@ShivamKumar-yp4vv 4 жыл бұрын
Sir big fan heart plz
@naqeebkhan4414
@naqeebkhan4414 4 жыл бұрын
Please bahi apple kay lia appstore may app publish karnay kay liay video banaw or hum 1 app ko kitnay jaga publish karsaktay hai
@arindamdutta7369
@arindamdutta7369 4 жыл бұрын
Sir ji DS ALGO ka kitna % Padhaye AAP??..AUR kitna baaki hai???....I am excited to know
@shazwatching5697
@shazwatching5697 2 жыл бұрын
7:40
@jinaykothari4511
@jinaykothari4511 4 жыл бұрын
Harry bhai please reply fast .... I am not able to use jupyter notebook
@anmol_pandey14
@anmol_pandey14 4 жыл бұрын
We want dsa videos fast!
@sb_infi
@sb_infi 2 жыл бұрын
8:30
@GovtExamsPrep1
@GovtExamsPrep1 11 ай бұрын
Alternative code: #include #include #include #define max 100 char stack[max],expr[max]; int top =-1; int match(char); void check(); int isEmpty(); void push(char); char pop(); void push(char x){ if(top == max-1){ printf("Stack_overflow "); return; } else{ top = top + 1; stack[top] = x; } } char pop(){ if(top == -1){ printf("Stack_underflow "); printf(" Unbalanced expression !! "); exit(0); } else{ char c = stack[top]; top = top - 1; return c; } } int isEmpty(){ if(top == -1) return 1; else return 0; } int match(char x){ switch(x){ case '(': case ')': return 3; case '{': case '}': return 2; case '[': case ']': return 1; } } void check(){ int i = 0; char element,x; while(i
Infix, Prefix and Postfix Expressions
26:54
CodeWithHarry
Рет қаралды 601 М.
Parenthesis Checking Using Stack in C Language
20:29
CodeWithHarry
Рет қаралды 159 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 23 МЛН
How I would learn to code (If I could start over)
13:14
CodeWithHarry
Рет қаралды 197 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 98 МЛН
MergeSort Sorting Algorithm in Hindi
35:34
CodeWithHarry
Рет қаралды 332 М.
Introduction to Circular Queue in Data Structures
24:25
CodeWithHarry
Рет қаралды 335 М.
Peek Operation in Stack Using Arrays (With C Code & Explanation)
21:22
3.8 Infix to Prefix using Stack | Data Structures Tutorials
24:05
Jenny's Lectures CS IT
Рет қаралды 987 М.
Winning Google Kickstart Round C 2020
30:57
William Lin (tmwilliamlin168)
Рет қаралды 4 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59