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 !!
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
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
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 TH-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
Thanks mam you made this topic easier... 🙏
Thank u mam...best wishes
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
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
Thank you very much i m highly appreciated I'm going to write my exam tomorrow on this topic❤❤❤
Nice one Bhanu Priya Ma'am
good teaching..
thank u..
What "n" in time complexity ?
Tqq sis for this useful session 👌👌
you're awesome thank you sm for these videos
E node should be back toh A nd then it traversed to C nd G
BFS is optimal assuming uniform cost across edges otherwise it is not optimal
Nice presentation mem
TQ Mam ❤
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
BFS implemented by FIFO Principle.
Similarly, DFS implemented by what??
Last in first out (stack)
Tq so much mam love ❤️ u mam
Thank you 🤗
At 9:16 some aunty in telugu speaking " Ha em anavu" 😂😂
Thank you for allowing me to survive University.
🙏👍you and me man....
backtracking node E to C How?
Not possible ryt ? I too had same doubt. !!
everything is from javatpoint
Aiml students assemble
maam please provide notes
Make your own 🤣
What is n?
Node
I'm the .8K liker
Mam can i see you face mam😊
Please mam show your face I have a great wish to see our teachers at least once
hi to all CSE (ksr students)
You don't know what you say
not really helping.