Notes ●QUEUE:-A type of a data structure in which the elements are inserted and deleted according to the FIFO (First In First Out) principle. ●Working:- A Queue can be implemented using an ARRAY in which > every new element which is inserted in the END: Enqueue > If any element has to be removed, it is removed from the starting point: Dequeu ------------------------------------------------------------------- ●STACK :- A type of a data structure in which the elements are inserted and deleted according to the LIFO (Last In First Out) principle. ● Working:-A STACK can be implemented using an array in which > every new element which is inserted, is inserted at theTOP (PUSH) > If any element has to be removed, it is removed from the TOP (POP)
For Example Mujhe lgta hai yeh "B" pr wapis hi nahi jayega,yeh "D"->"E"->"C"->"G" jayega. ------------------------------------------------------------------- Algorithm of DFS:- 1. START WITH EMPTY STACK 2. INSERT THE ROOT NODE (INITIAL STATE) IN THE STACK 3. CHECK IF THE ROOT NODE IS THE GOAL NODE IF THE ROOT NODE IS THE GOAL NODE, SEARCH IS SUCCESSFUL ELSE REMOVE ROOT 4. PUSH: INSERT CHILD (SUCCESSOR) NODES OF THE NODE REMOVED FROM THE QUEUE 5. POP: Remove the topmost node from the STACK 6. CHECK IF THE POPPED NODE IS THE GOAL NODE 7. IF THE POPPED NODE IS THE GOAL NODE, PRINT (SEARCH SUCCESSFUL) AND EXIT ELSE, REPEAT STEPS 4 TO 7 UNTIL THE SEARCH IS SUCCESSFUL OR ALL THE NODES OF THE TREE HAVE BEEN TRAVERSED AND THE STACK IS EMPTY IF THE GOAL STATE IS NOT FOUND , PRINT (SEARCH UNSUCCESSFUL) AND EXIT _______________________________________ Step1: Insert (PUSH) the initial state (root node) S on TOP of STACK Step 2: POP S and PUSH it’s child nodes H and A Step 3: POP A and PUSH it’s child nodes C and B Step 4: POP B and PUSH it’s child nodes E and D Step 5: POP D but D has no child ! Move to the next node E Step 6: POP E but E has no child ! Move to the next node C To reach node C, we will have to backtrack from level 3 to level 2 Step 7: POP C and PUSH it’s child node G Step 8: POP G. G is the GOAL STATE !! SUCCESS !!
When a weighted graph is given, what is the order we should select the adjacent edge in DFS, should we select the least cost edge first ? please answer this
What, how many values does DFS holds on its stack at once? (unlike BFS that holds B^L) Thanks again and again ,this is a topic of 3 semesters just in between 10-20
My thinking....once it backtracks it deletes the appropriate node as it is already visited.Hemce B,C,A are not present in tree while backtracking and hence visits G directly
6:04 from E node it should backtrack to B and again it should backtrack to A and then it reaches c node
ya bro
it does but since you dont take the value twice, this is even a better representation
Exactly
Yes
@Bloody Kheeng teacher not explain properly. this is wrong way to explain this algorithm you can watch gate smashers UA-cam channel for this algorithm
Hi to all the cse students!
Hi to all bca students
Hi bro.. Im EEE student 😀
Hlw guys
Dai poi padida
Hi to all AI students
Not only the contents but the "Hi, Students" motivates me to watch all the videos related to my study ❤️🙌 Thank you so much mam ❤️🙏
Notes
●QUEUE:-A type of a data structure in which the elements are inserted and
deleted according to the FIFO (First In First Out) principle.
●Working:-
A Queue can be implemented using an ARRAY in which
> every new element which is inserted in the END: Enqueue
> If any element has to be removed, it is removed from the
starting point: Dequeu
-------------------------------------------------------------------
●STACK :- A type of a data structure in which the elements are inserted and
deleted according to the LIFO (Last In First Out) principle.
● Working:-A STACK can be implemented using an array in which
> every new element which is inserted, is inserted at theTOP (PUSH)
> If any element has to be removed, it is removed from the TOP (POP)
For Example
Mujhe lgta hai yeh "B" pr wapis hi nahi jayega,yeh "D"->"E"->"C"->"G" jayega.
-------------------------------------------------------------------
Algorithm of DFS:-
1. START WITH EMPTY STACK
2. INSERT THE ROOT NODE (INITIAL STATE) IN THE STACK
3. CHECK IF THE ROOT NODE IS THE GOAL NODE
IF THE ROOT NODE IS THE GOAL NODE, SEARCH IS SUCCESSFUL ELSE REMOVE ROOT
4. PUSH: INSERT CHILD (SUCCESSOR) NODES OF THE NODE REMOVED FROM THE QUEUE
5. POP: Remove the topmost node from the STACK
6. CHECK IF THE POPPED NODE IS THE GOAL NODE
7. IF THE POPPED NODE IS THE GOAL NODE, PRINT (SEARCH SUCCESSFUL) AND EXIT
ELSE, REPEAT STEPS 4 TO 7 UNTIL THE SEARCH IS SUCCESSFUL OR ALL THE NODES OF THE TREE
HAVE BEEN TRAVERSED AND THE STACK IS EMPTY
IF THE GOAL STATE IS NOT FOUND , PRINT (SEARCH UNSUCCESSFUL) AND EXIT
_______________________________________
Step1: Insert (PUSH) the initial state (root node) S on TOP of
STACK
Step 2: POP S and PUSH it’s child nodes H and A
Step 3: POP A and PUSH it’s child nodes C and B
Step 4: POP B and PUSH it’s child nodes E and D
Step 5: POP D but D has no child ! Move to the next node E
Step 6: POP E but E has no child ! Move to the next node C
To reach node C, we will have to backtrack from level 3 to level 2
Step 7: POP C and PUSH it’s child node G
Step 8: POP G.
G is the GOAL STATE !! SUCCESS !!
Mm
Aiml students assemble
Thanks mam you made this topic easier... 🙏
Thank u mam...best wishes
Nice one Bhanu Priya Ma'am
When a weighted graph is given, what is the order we should select the adjacent edge in DFS, should we select the least cost edge first ? please answer this
What, how many values does DFS holds on its stack at once?
(unlike BFS that holds B^L)
Thanks again and again ,this is a topic of 3 semesters just in between 10-20
A relatively simple real-world processes made so complex and ambigious in computer programing
For the backtracking how did E connect straight with C? No connection exist between them, it should go back to B, A, C and then G. Am I right?
you are right dude
while back track it already visited b and a so only
My thinking....once it backtracks it deletes the appropriate node as it is already visited.Hemce B,C,A are not present in tree while backtracking and hence visits G directly
E node should be back toh A nd then it traversed to C nd G
Tqq sis for this useful session 👌👌
you're awesome thank you sm for these videos
good teaching..
thank u..
BFS is optimal assuming uniform cost across edges otherwise it is not optimal
Nice presentation mem
What "n" in time complexity ?
Thank you mam
At 9:16 some aunty in telugu speaking " Ha em anavu" 😂😂
TQ Mam ❤
Tq so much mam love ❤️ u mam
BFS implemented by FIFO Principle.
Similarly, DFS implemented by what??
Last in first out (stack)
Thank you for allowing me to survive University.
🙏👍you and me man....
Thank you 🤗
Where is f
backtracking node E to C How?
Not possible ryt ? I too had same doubt. !!
everything is from javatpoint
maam please provide notes
Make your own 🤣
I'm the .8K liker
What is n?
Node
Hii to all the ponjeslians 😂😎
Mam can i see you face mam😊
hi to all CSE (ksr students)
Please mam show your face I have a great wish to see our teachers at least once
not really helping.
You don't know what you say