title

G-8. Number of Islands | Number of Connected Components in Matrix | C++ | Java

description

GfG Problem Link: https://bit.ly/3oT9Ndg
C++/Java/Codes and Notes Link: https://takeuforward.org/graph/breadth-first-search-bfs-level-order-traversal/
DP Series: https://www.youtube.com/watch?v=FfXoiwwnxFw&list=PLgUwDviBIf0qUlt5H_kiKYaNSqJ81PMMY
SDE Sheet: https://takeuforward.org/interviews/strivers-sde-sheet-top-coding-interview-problems/
Check out our Website for curated resources: https://www.takeuforward.org/
Our Second Channel: https://www.youtube.com/channel/UCvEKHATlVq84hm1jduTYm8g
In case you are thinking to buy courses, please check below:
Code "takeuforward" for 15% off at GFG: https://practice.geeksforgeeks.org/courses
Code "takeuforward" for 20% off on sys-design: https://get.interviewready.io?_aff=takeuforward
Crypto, I use the Wazirx app: https://wazirx.com/invite/xexnpc4u
Take 750 rs free Amazon Stock from me: https://indmoney.onelink.me/RmHC/idjex744
Earn 100 rs by making a Grow Account for investing: https://app.groww.in/v3cO/8hu879t0
Linkedin/Instagram/Telegram: https://linktr.ee/takeUforward
---------------------------------------------------------------------------------------------------------------------------

detail

{'title': 'G-8. Number of Islands | Number of Connected Components in Matrix | C++ | Java', 'heatmap': [{'end': 1283.268, 'start': 1240.038, 'weight': 0.812}, {'end': 1443.865, 'start': 1428.409, 'weight': 0.883}], 'summary': 'Tutorial covers topics including finding the number of islands in a grid of size n x m using bfs or dfs traversal, optimizing graph traversal, identifying neighbors in all eight directions, and implementing bfs algorithm in a matrix with a space complexity of n square and a time complexity of roughly n square.', 'chapters': [{'end': 126.921, 'segs': [{'end': 66.641, 'src': 'embed', 'start': 3.416, 'weight': 0, 'content': [{'end': 9.72, 'text': 'so we have learnt about the BFS traversal and the DFS traversal, but where will it be applied?', 'start': 3.416, 'duration': 6.304}, {'end': 16.485, 'text': "so you're gonna do a bunch of problems, and this video is going to be about the first problem number of connected components.", 'start': 9.72, 'duration': 6.765}, {'end': 17.866, 'text': 'so let me explain you the problem.', 'start': 16.485, 'duration': 1.381}, {'end': 19.587, 'text': 'so what does the problem state?', 'start': 17.866, 'duration': 1.721}, {'end': 28.314, 'text': "the problem states you'll be given a grid of size n, cross m, where n is the number of rows and m is the number of columns in the grid,", 'start': 19.587, 'duration': 8.727}, {'end': 32.857, 'text': 'and zeros are meaning water and one is meaning the land.', 'start': 28.314, 'duration': 4.543}, {'end': 40.759, 'text': 'okay, so your task is to find the number of islands, and an island is surrounded by water and is formed by connecting adjacent lands,', 'start': 32.857, 'duration': 7.902}, {'end': 45.9, 'text': 'horizontally or vertically, or direct, diagonally, in all eight directions.', 'start': 40.759, 'duration': 5.141}, {'end': 51.241, 'text': "so basically, what they are stating is they'll be giving you a grid of size n, cross m.", 'start': 45.9, 'duration': 5.341}, {'end': 56.603, 'text': 'okay, over here, zero means water, one means land.', 'start': 51.241, 'duration': 5.362}, {'end': 59.213, 'text': 'now you have to find the islands.', 'start': 56.603, 'duration': 2.61}, {'end': 60.354, 'text': 'so this is a land.', 'start': 59.213, 'duration': 1.141}, {'end': 61.395, 'text': 'this is a land.', 'start': 60.354, 'duration': 1.041}, {'end': 62.236, 'text': 'this is a land.', 'start': 61.395, 'duration': 0.841}, {'end': 62.997, 'text': 'this is a land.', 'start': 62.236, 'duration': 0.761}, {'end': 64.279, 'text': 'this is a land.', 'start': 62.997, 'duration': 1.282}, {'end': 66.641, 'text': 'so i can say these all lands are connected.', 'start': 64.279, 'duration': 2.362}], 'summary': 'Given a grid, find the number of connected islands with 1s and 0s.', 'duration': 63.225, 'max_score': 3.416, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH03416.jpg'}], 'start': 3.416, 'title': 'Finding islands', 'summary': 'Explains how to find the number of islands in a grid of size n x m, where 0 represents water and 1 represents land, using bfs or dfs traversal.', 'chapters': [{'end': 126.921, 'start': 3.416, 'title': 'Number of connected components', 'summary': 'Explains the problem of finding the number of islands in a grid of size n x m, where 0 represents water and 1 represents land, with the task being to find the connected islands using bfs or dfs traversal.', 'duration': 123.505, 'highlights': ['The problem involves finding the number of islands in a grid of size n x m, where 0 represents water and 1 represents land. The grid of size n x m contains 0 for water and 1 for land, and the task is to identify the connected islands.', 'The islands are formed by connecting adjacent lands horizontally, vertically, or diagonally in all eight directions. The definition of islands includes the connectivity of adjacent lands in all eight directions, forming islands surrounded by water.', 'The chapter emphasizes that the grid problem is essentially a graph problem, to be approached with graph traversal techniques like BFS or DFS. The problem is presented as a graph problem, requiring the application of graph traversal techniques such as BFS or DFS to find the connected islands.']}], 'duration': 123.505, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH03416.jpg', 'highlights': ['The problem involves finding the number of islands in a grid of size n x m, where 0 represents water and 1 represents land.', 'The islands are formed by connecting adjacent lands horizontally, vertically, or diagonally in all eight directions.', 'The chapter emphasizes that the grid problem is essentially a graph problem, to be approached with graph traversal techniques like BFS or DFS.']}, {'end': 404.679, 'segs': [{'end': 187.296, 'src': 'embed', 'start': 155.832, 'weight': 0, 'content': [{'end': 158.514, 'text': "it can be any traversal BFS, DFS doesn't matter.", 'start': 155.832, 'duration': 2.682}, {'end': 165.5, 'text': 'If I start a traversal from one, this will make sure it traverses the nearest one.', 'start': 159.235, 'duration': 6.265}, {'end': 169.623, 'text': 'This will make sure it traverses the nearest one.', 'start': 167.462, 'duration': 2.161}, {'end': 172.566, 'text': 'This will make sure it traverses the nearest one.', 'start': 170.424, 'duration': 2.142}, {'end': 175.048, 'text': 'This will make sure it traverses the nearest one.', 'start': 173.166, 'duration': 1.882}, {'end': 187.296, 'text': 'So if I start from a particular one and I do a certain level of traversal, assuming, assuming that the connections are in all the eight directions,', 'start': 175.608, 'duration': 11.688}], 'summary': 'Traversing algorithm ensures nearest node traversal in all 8 directions.', 'duration': 31.464, 'max_score': 155.832, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0155832.jpg'}, {'end': 296.984, 'src': 'embed', 'start': 248.621, 'weight': 1, 'content': [{'end': 254.244, 'text': 'again among these two, i can pick up anyone as the starting node and it will make sure it will touch these two.', 'start': 248.621, 'duration': 5.623}, {'end': 258.346, 'text': 'and from here i can pick up anyone and this will make sure it only touches it.', 'start': 254.244, 'duration': 4.102}, {'end': 269.712, 'text': 'so can i say if i take three starting nodes, yes, if i take three starting nodes i will be able to touch all the pieces of plant.', 'start': 258.346, 'duration': 11.366}, {'end': 279.525, 'text': 'thereby can i say there are three islands because one starting node will make sure it touches all the connected lands.', 'start': 269.712, 'duration': 9.813}, {'end': 282.407, 'text': 'so one starting node will represent one island.', 'start': 279.525, 'duration': 2.882}, {'end': 284.249, 'text': 'so this is the intuition.', 'start': 282.407, 'duration': 1.842}, {'end': 286.672, 'text': 'so we have understood kind of the intuition.', 'start': 284.249, 'duration': 2.423}, {'end': 288.353, 'text': 'but how do we apply?', 'start': 286.672, 'duration': 1.681}, {'end': 294.342, 'text': 'and traversal technique that we have learned in the previous videos.', 'start': 288.353, 'duration': 5.989}, {'end': 296.984, 'text': 'so we know couple of traversal techniques.', 'start': 294.342, 'duration': 2.642}], 'summary': 'By using three starting nodes, all pieces of plant can be touched, representing three islands. traversal techniques are applied.', 'duration': 48.363, 'max_score': 248.621, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0248621.jpg'}], 'start': 128.222, 'title': 'Graph traversal and optimization', 'summary': 'Covers node traversal in graphs using bfs or dfs, optimizing traversal for visiting all nodes with three starting nodes, and island counting in a grid using bfs traversal technique.', 'chapters': [{'end': 221.217, 'start': 128.222, 'title': 'Node traversal in graphs', 'summary': 'Discusses the concept of node traversal in a graph, emphasizing the process of traversing connected nodes using bfs or dfs, ensuring each node is reached in a specified number of steps.', 'duration': 92.995, 'highlights': ['Starting a traversal from a specific node ensures each connected node is reached in the nearest steps, effectively utilizing BFS or DFS.', 'The traversal process ensures that each node is reached within a certain level, especially if connections are available in all eight directions.', 'The concept of traversal in a graph involves reaching all connected nodes within a specified range, as demonstrated by the process of reaching all connected nodes starting from a specific node.']}, {'end': 269.712, 'start': 221.217, 'title': 'Optimizing traversal for visiting all nodes', 'summary': "Discusses the strategy of using three starting nodes to ensure visiting all nodes in a plant, offering an efficient traversal approach for comprehensive coverage of the plant's components.", 'duration': 48.495, 'highlights': ['By using three starting nodes for traversal, it guarantees the coverage of all plant components, ensuring comprehensive visitation.', 'The discussion highlights the selection of starting nodes for traversal, emphasizing the flexibility in choosing any of the nodes to achieve complete coverage.', 'The strategy outlines the efficiency of visiting all nodes in a plant by employing a specific number of starting nodes for traversal.']}, {'end': 404.679, 'start': 269.712, 'title': 'Island counting with bfs', 'summary': 'Discusses how to count the number of islands in a grid using bfs traversal technique, representing the starting node as a pair of row and column number, and marking visited nodes in a 2d array.', 'duration': 134.967, 'highlights': ['Counting islands using BFS traversal technique The chapter explains the process of counting islands in a grid using the BFS traversal technique.', 'Representing starting node as a pair of row and column number The starting node is represented as a pair of row and column number instead of a vertex number.', 'Marking visited nodes in a 2D array A 2D array is created to mark visited nodes, with the initial configuration marking the starting node as visited.']}], 'duration': 276.457, 'thumbnail': '', 'highlights': ['Starting a traversal from a specific node ensures each connected node is reached in the nearest steps, effectively utilizing BFS or DFS.', 'By using three starting nodes for traversal, it guarantees the coverage of all plant components, ensuring comprehensive visitation.', 'Counting islands using BFS traversal technique The chapter explains the process of counting islands in a grid using the BFS traversal technique.']}, {'end': 703.121, 'segs': [{'end': 445.758, 'src': 'embed', 'start': 405.159, 'weight': 0, 'content': [{'end': 406.4, 'text': 'I pick up the element from the queue.', 'start': 405.159, 'duration': 1.241}, {'end': 410.942, 'text': 'Perfect And then it said travel to all its neighbors.', 'start': 406.64, 'duration': 4.302}, {'end': 417.786, 'text': 'And in the graph, we stored all the neighbors in something which was known as adjacency list.', 'start': 411.803, 'duration': 5.983}, {'end': 425.083, 'text': "remember. but over here, what we will do is we don't have an adjacency list, but we know who are the neighbors.", 'start': 418.638, 'duration': 6.445}, {'end': 433.429, 'text': "if i'm standing at a node, the neighbors can be someone at the top, someone on this diagonal, someone on this diagonal, someone in this one,", 'start': 425.083, 'duration': 8.346}, {'end': 436.791, 'text': 'someone here, someone here, someone here, someone here.', 'start': 433.429, 'duration': 3.362}, {'end': 438.252, 'text': 'there are eight directions.', 'start': 436.791, 'duration': 1.461}, {'end': 439.333, 'text': 'who can be neighbors?', 'start': 438.252, 'duration': 1.081}, {'end': 440.994, 'text': 'we know the eight directions.', 'start': 439.333, 'duration': 1.661}, {'end': 443.116, 'text': 'we know that there can be eight directions.', 'start': 440.994, 'duration': 2.122}, {'end': 445.758, 'text': 'so what we will do is we will go to all directions.', 'start': 443.116, 'duration': 2.642}], 'summary': 'Algorithm computes neighbors in a graph using eight directions.', 'duration': 40.599, 'max_score': 405.159, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0405159.jpg'}, {'end': 614.155, 'src': 'embed', 'start': 586.736, 'weight': 2, 'content': [{'end': 590.758, 'text': 'so you saw how, in one traversal, you could have done dfs as well,', 'start': 586.736, 'duration': 4.022}, {'end': 597.3, 'text': 'how in one traversal we were able to touch everyone the lands that were connected to it.', 'start': 591.278, 'duration': 6.022}, {'end': 603.423, 'text': 'done next we we have to start from this guy, which is the starting point will change.', 'start': 597.3, 'duration': 6.123}, {'end': 612.093, 'text': "this time the starting point will become four comma zero and again we'll follow the same process, and if we follow the same process again,", 'start': 604.947, 'duration': 7.146}, {'end': 614.155, 'text': 'it will be marked right.', 'start': 612.093, 'duration': 2.062}], 'summary': 'Demonstrated dfs traversal touching all connected lands in one pass.', 'duration': 27.419, 'max_score': 586.736, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0586736.jpg'}], 'start': 405.159, 'title': 'Graph and bfs traversal', 'summary': 'Discusses graph traversal and neighbors, emphasizing adjacency list and identifying neighbors in all eight directions. it also covers bfs traversal of a matrix, using three starting points to visit all connected lands in one traversal, demonstrating the process of selecting starting points and reaching all connected lands.', 'chapters': [{'end': 445.758, 'start': 405.159, 'title': 'Graph traversal and neighbors', 'summary': 'Discusses graph traversal and neighbors, emphasizing the concept of adjacency list and the method for identifying neighbors in all eight directions.', 'duration': 40.599, 'highlights': ['The chapter explains the concept of adjacency list and its relevance in storing graph neighbors.', 'It emphasizes the method for identifying neighbors in all eight directions during graph traversal.']}, {'end': 703.121, 'start': 446.477, 'title': 'Bfs traversal of matrix', 'summary': 'Discusses the bfs traversal of a matrix, where three starting points were used to visit all the connected lands in one traversal, demonstrating the process of selecting starting points and reaching all connected lands.', 'duration': 256.644, 'highlights': ['The chapter demonstrates how to select starting points for BFS traversal in a matrix, using the example of a 4x4 grid, and successfully visiting all connected lands in one traversal, using three different starting points.', 'The process of BFS traversal is detailed, illustrating the steps of marking visited points and selecting starting points to ensure all connected lands are visited in one traversal, with a clear explanation of the decision-making process.', 'The importance of selecting starting points for BFS traversal is emphasized, highlighting the efficiency of the process in reaching all connected lands in one traversal and avoiding unnecessary revisits to already visited points.']}], 'duration': 297.962, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0405159.jpg', 'highlights': ['The chapter emphasizes the method for identifying neighbors in all eight directions during graph traversal.', 'The chapter explains the concept of adjacency list and its relevance in storing graph neighbors.', 'The process of BFS traversal is detailed, illustrating the steps of marking visited points and selecting starting points to ensure all connected lands are visited in one traversal, with a clear explanation of the decision-making process.', 'The chapter demonstrates how to select starting points for BFS traversal in a matrix, using the example of a 4x4 grid, and successfully visiting all connected lands in one traversal, using three different starting points.', 'The importance of selecting starting points for BFS traversal is emphasized, highlighting the efficiency of the process in reaching all connected lands in one traversal and avoiding unnecessary revisits to already visited points.']}, {'end': 1155.754, 'segs': [{'end': 766.602, 'src': 'embed', 'start': 735.092, 'weight': 0, 'content': [{'end': 736.253, 'text': 'With those row and column.', 'start': 735.092, 'duration': 1.161}, {'end': 741.687, 'text': 'at the same time you say these are the number of starting points that i called for.', 'start': 737.523, 'duration': 4.164}, {'end': 745.11, 'text': 'so apparently this portion will count.', 'start': 741.687, 'duration': 3.423}, {'end': 752.737, 'text': 'every time you call us row column to be the starting point, you count it and bfs will stay kind of similar.', 'start': 745.11, 'duration': 7.627}, {'end': 757.121, 'text': 'only you just make sure how to traverse in the adjacency list.', 'start': 752.737, 'duration': 4.384}, {'end': 759.443, 'text': 'so we kind of wrote the pseudo code.', 'start': 757.121, 'duration': 2.322}, {'end': 766.602, 'text': "so i'll now get back to the editor and i will tell you how to write the code like step by step again.", 'start': 759.443, 'duration': 7.159}], 'summary': 'Discussing implementing bfs with starting points and adjacency list.', 'duration': 31.51, 'max_score': 735.092, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0735092.jpg'}, {'end': 816.348, 'src': 'embed', 'start': 782.37, 'weight': 1, 'content': [{'end': 783.911, 'text': "so what's the first thing?", 'start': 782.37, 'duration': 1.541}, {'end': 785.812, 'text': 'i told you we need to create?', 'start': 783.911, 'duration': 1.901}, {'end': 787.413, 'text': 'uh, like we need to get the n.', 'start': 785.812, 'duration': 1.601}, {'end': 788.614, 'text': 'so n will be very simple.', 'start': 787.413, 'duration': 1.201}, {'end': 789.955, 'text': 'you can just say grid dot size.', 'start': 788.614, 'duration': 1.341}, {'end': 792.457, 'text': 'that will give you the n, and i need to get the m as well.', 'start': 789.955, 'duration': 2.502}, {'end': 795.979, 'text': 'so you can say grid of zero dot size.', 'start': 792.457, 'duration': 3.522}, {'end': 798.941, 'text': "right, that's something which you can say.", 'start': 795.979, 'duration': 2.962}, {'end': 801.183, 'text': 'what is the next thing that you will do?', 'start': 798.941, 'duration': 2.242}, {'end': 803.104, 'text': 'you need to create a visited array.', 'start': 801.183, 'duration': 1.921}, {'end': 810.289, 'text': "so since we need to pass everything by reference, it's better we create something like this okay, now we need to create visited.", 'start': 803.104, 'duration': 7.185}, {'end': 816.348, 'text': 'so vector of int and m, comma zero, so everything is marked as zero.', 'start': 810.289, 'duration': 6.059}], 'summary': 'Creating n and m using grid dot size and grid of zero dot size, followed by creating a visited array.', 'duration': 33.978, 'max_score': 782.37, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0782370.jpg'}, {'end': 880.127, 'src': 'embed', 'start': 851.935, 'weight': 2, 'content': [{'end': 855.018, 'text': 'and over here you can just initialize count equal to zero.', 'start': 851.935, 'duration': 3.083}, {'end': 858.521, 'text': 'now your turn, your time now to write the bfs code.', 'start': 855.018, 'duration': 3.503}, {'end': 859.802, 'text': "so let's quickly try out the bfs.", 'start': 858.521, 'duration': 1.281}, {'end': 863.557, 'text': "so what i'll do is you can write the dfs as well.", 'start': 860.996, 'duration': 2.561}, {'end': 864.958, 'text': 'that is completely your choice.', 'start': 863.557, 'duration': 1.401}, {'end': 866.159, 'text': "i'll leave it to you.", 'start': 864.958, 'duration': 1.201}, {'end': 868.78, 'text': "so i'm writing the bfs.", 'start': 866.159, 'duration': 2.621}, {'end': 870.261, 'text': 'you can write dfs as well.', 'start': 868.78, 'duration': 1.481}, {'end': 874.304, 'text': "i'll show that to you as well, so int row.", 'start': 870.261, 'duration': 4.043}, {'end': 876.105, 'text': 'okay, int column.', 'start': 874.304, 'duration': 1.801}, {'end': 877.505, 'text': "that's the starting point.", 'start': 876.105, 'duration': 1.4}, {'end': 880.127, 'text': "now the next thing that you'll do you'll take the visited guy.", 'start': 877.505, 'duration': 2.622}], 'summary': 'Initiate bfs and dfs code, for example: initialize count to zero.', 'duration': 28.192, 'max_score': 851.935, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0851935.jpg'}, {'end': 965.298, 'src': 'embed', 'start': 939.871, 'weight': 3, 'content': [{'end': 948.987, 'text': "right now we need to traverse in the neighbors, traverse in the neighbors and mark them if it's a line.", 'start': 939.871, 'duration': 9.116}, {'end': 950.508, 'text': 'this is what we need to do.', 'start': 948.987, 'duration': 1.521}, {'end': 954.771, 'text': 'now the question comes up you need to traverse in its neighbors.', 'start': 950.508, 'duration': 4.263}, {'end': 956.472, 'text': 'so which are its neighbors?', 'start': 954.771, 'duration': 1.701}, {'end': 958.653, 'text': "so i'm going to teach you a shortcut for this.", 'start': 956.472, 'duration': 2.181}, {'end': 965.298, 'text': "so apparently, if you are standing at a row column, let's let's come back to the ipad.", 'start': 958.653, 'duration': 6.645}], 'summary': 'Traverse neighbors to mark lines, discuss shortcut for finding neighbors.', 'duration': 25.427, 'max_score': 939.871, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/muncqlKJrH0/pics/muncqlKJrH0939871.jpg'}], 'start': 703.121, 'title': 'Bfs traversal and code writing', 'summary': 'Discusses pseudo code for bfs traversal, including iterating through rows and columns, marking visited points, and counting starting points. it also involves step-by-step writing of java and c++ code, creating a character grid, initializing arrays, using bfs and dfs algorithms, and determining neighbors.', 'chapters': [{'end': 759.443, 'start': 703.121, 'title': 'Pseudo code for bfs traversal', 'summary': 'Discusses the pseudo code for bfs traversal, iterating through rows and columns, marking visited points, and counting the number of starting points for bfs calls.', 'duration': 56.322, 'highlights': ['The pseudo code for BFS traversal involves iterating through rows and columns, marking visited points, and counting the number of starting points for BFS calls.', 'The pseudo code also ensures that BFS traversal stays similar, with a focus on how to traverse the adjacency list.']}, {'end': 1155.754, 'start': 759.443, 'title': 'Writing java and c++ code', 'summary': 'Involves writing java and c++ code step by step, creating a character grid, initializing arrays, using bfs and dfs algorithms, and determining the neighbors using a specific technique.', 'duration': 396.311, 'highlights': ["Creating a character grid and initializing arrays The chapter involves creating a character grid and initializing a visited array with values marked as zero, using the size of the grid for 'n' and 'm'.", 'Implementing BFS and DFS algorithms The chapter discusses writing the BFS algorithm, with details on initializing and traversing through the grid using BFS, and the option to write the DFS algorithm.', 'Determining neighbors using a specific technique The chapter explains a shortcut technique for determining neighbors, involving varying row and column values from -1 to +1 and utilizing loops to obtain neighbor rows and columns.']}], 'duration': 452.633, 'thumbnail': '', 'highlights': ['The pseudo code for BFS traversal involves iterating through rows and columns, marking visited points, and counting the number of starting points for BFS calls.', "The chapter involves creating a character grid and initializing a visited array with values marked as zero, using the size of the grid for 'n' and 'm'.", 'Implementing BFS and DFS algorithms The chapter discusses writing the BFS algorithm, with details on initializing and traversing through the grid using BFS, and the option to write the DFS algorithm.', 'Determining neighbors using a specific technique The chapter explains a shortcut technique for determining neighbors, involving varying row and column values from -1 to +1 and utilizing loops to obtain neighbor rows and columns.', 'The pseudo code also ensures that BFS traversal stays similar, with a focus on how to traverse the adjacency list.']}, {'end': 1493.19, 'segs': [{'end': 1200.783, 'src': 'embed', 'start': 1156.154, 'weight': 2, 'content': [{'end': 1163.756, 'text': 'Now, these guys have to be valid because if you remember, they might nothing be on the top or they might be crossing boundaries.', 'start': 1156.154, 'duration': 7.602}, {'end': 1167.82, 'text': 'So make sure the neighbor row is valid.', 'start': 1164.216, 'duration': 3.604}, {'end': 1172.744, 'text': 'which is this again, which is you need to make sure?', 'start': 1167.82, 'duration': 4.924}, {'end': 1178.989, 'text': 'uh, you need n and m, so you can again just recompute them or you can carry them from them.', 'start': 1172.744, 'duration': 6.245}, {'end': 1184.993, 'text': 'so grid dot size and you can say grid zero dot size will be your column size perfect.', 'start': 1178.989, 'duration': 6.004}, {'end': 1187.555, 'text': 'so you can say this has to be valid thereby,', 'start': 1184.993, 'duration': 2.562}, {'end': 1195.821, 'text': 'this has to be this and and obviously n column has to be greater than zero and an n column has to be less than m.', 'start': 1187.555, 'duration': 8.266}, {'end': 1197.282, 'text': 'this is for valid.', 'start': 1195.821, 'duration': 1.461}, {'end': 1200.783, 'text': 'once they are valid, they have to be very, very important.', 'start': 1197.282, 'duration': 3.501}], 'summary': 'Validating n and m for column size, ensuring n<0 and n