{"id":11202,"date":"2025-11-24T11:03:41","date_gmt":"2025-11-24T05:33:41","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=11202"},"modified":"2025-11-24T17:12:21","modified_gmt":"2025-11-24T11:42:21","slug":"breadth-first-search-bfs","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/breadth-first-search-bfs\/","title":{"rendered":"Breadth First Search (BFS)"},"content":{"rendered":"\n<!-- PrismJS for Syntax Highlighting -->\n<link href=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/themes\/prism-tomorrow.min.css\" rel=\"stylesheet\">\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/prism.min.js\"><\/script>\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/prismjs@1.29.0\/plugins\/autoloader\/prism-autoloader.min.js\"><\/script>\n\n<style>\n.wp_blog_theme {\n  --primary: #E58C32;\n  --secondary: #030302;\n  --light-bg: #fef9f4;\n  --text-dark: #2d2d2d;\n  --tab-radius: 12px;\n  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);\n  --code-bg: #001f3f;\n  --code-text: #d4f1ff;\n}\n\n.wp_blog_container {\n  font-family: 'Segoe UI', sans-serif;\n  background: var(--light-bg);\n  margin: 0;\n  padding: 0;\n  color: var(--text-dark);\n}\n\n\/* Heading *\/\n.wp_blog_main-heading {\n  text-align: center;\n  font-size: 2.4rem;\n  color: var(--primary);\n  margin-top: 2.5rem;\n  font-weight: bold;\n}\n\n\/* Explanation Card *\/\n.wp_blog_explanation,\n.wp_blog_code-tabs-container {\n  max-width: 940px;\n  margin: 2rem auto;\n  padding: 2rem;\n  background: white;\n  border-radius: var(--tab-radius);\n  box-shadow: var(--shadow);\n}\n\n\/* Text and Visuals *\/\n.wp_blog_explanation h2 {\n  font-size: 1.4rem;\n  color: var(--primary);\n  margin-bottom: 0.5rem;\n}\n\n.wp_blog_explanation p,\n.wp_blog_explanation li {\n  font-size: 1.05rem;\n  line-height: 1.7;\n  margin: 0.5rem 0;\n}\n\n.wp_blog_explanation code {\n  background: #fef9f4;   \/* light bg instead of dark blue *\/\n  color: #E58C32;        \/* brand orange *\/\n  padding: 3px 6px;\n  border-radius: 4px;\n  font-family: 'Courier New', monospace;\n  font-weight: 600;      \/* optional, makes it pop *\/\n}\n\n.wp_blog_explanation img {\n  max-width: 100%;\n  border-radius: var(--tab-radius);\n  margin-top: 1rem;\n  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);\n}\n\n\/* Tab Buttons *\/\n.wp_blog_code-tabs-header {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 0.5rem;\n  margin-bottom: 1rem;\n}\n\n.wp_blog_code-tab-button {\n  padding: 0.6rem 1.2rem;\n  border: 1px solid var(--primary);\n  background: white;\n  color: var(--primary);\n  border-radius: 50px;\n  font-weight: 600;\n  cursor: pointer;\n  transition: all 0.3s ease;\n}\n\n.wp_blog_code-tab-button:hover {\n  background: var(--secondary);\n}\n\n.wp_blog_code-tab-button.active {\n  background: var(--primary);\n  color: white;\n}\n\n\/* Code Content *\/\n.wp_blog_code-tab-content {\n  display: none;\n  background: var(--code-bg);\n  border-radius: var(--tab-radius);\n}\n\n.wp_blog_code-tab-content.active {\n  display: block;\n}\n\n.wp_blog_code-tab-content pre {\n  margin: 0;\n  padding: 1.5rem;\n  font-size: 1rem;\n  overflow-x: auto;\n  background: var(--code-bg);\n  border-radius: var(--tab-radius);\n  color: var(--code-text);\n}\n\n\/* Dark mode variables *\/\n.wp_blog_theme.dark-mode {\n  --light-bg: #121212;\n  --text-dark: #f5f5f5;\n  --shadow: 0 4px 12px rgba(255, 255, 255, 0.08);\n  --code-bg: #1e1e1e;\n  --code-text: #c5f0ff;\n}\n\n.wp_blog_theme.dark-mode .wp_blog_explanation {\n  background: #1e1e1e;\n}\n\n\/* Dark mode code highlight *\/\n.wp_blog_theme.dark-mode .wp_blog_explanation code {\n  background: #333;\n  color: #ffd27f;\n}\n\n.wp_blog_theme {\n  position: relative; \/* makes it the reference for absolute children *\/\n}\n\n.wp_blog_toggle-btn {\n  position: absolute;\n  top: 1rem;\n  right: 1rem;\n  z-index: 9999;\n  padding: 0.5rem 0.8rem;\n  border-radius: 10%;\n  background: var(--primary);\n  color: white;\n  font-weight: bold;\n  cursor: pointer;\n  border: none;\n  box-shadow: var(--shadow);\n  transition: background 0.3s, transform 0.2s;\n}\n\n.wp_blog_toggle-btn:hover {\n  background: #cc772e;\n}\n\n.wp_blog_theme.dark-mode .wp_blog_code-tabs-container {\n  background: #1e1e1e;\n}\n<\/style>\n\n<div class=\"wp_blog_container wp_blog_theme\">\n  <button id=\"blogNotesThemeToggle\" class=\"wp_blog_toggle-btn\">\ud83c\udf19<\/button>\n  <h1 class=\"wp_blog_main-heading\"><\/h1>\n\n  <div class=\"wp_blog_explanation\">\n    <h2>Breadth First Search (BFS)<\/h2>\n    <h2>Example: 1<\/h2>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/1.png\" alt=\"\">\n    <p><strong>BFS: <\/strong><code>[0, 1, 2, 3, 4]<\/code><\/p>\n\n    <h2>Example: 2<\/h2>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/2.png\" alt=\"\">\n    <p><strong>BFS: <\/strong><code>[1, 2, 4, 3, 5, 9, 8, 6, 7]<\/code><\/p>\n    \n    <h2>Real-World Example<\/h2>\n    <!-- Chandigarh -->\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/3.png\" alt=\"\">\n    <p><strong>BFS: <\/strong><code>[Mussoorie, Dehradun, Chandigarh, , Delhi, Agra, Jaipur]<\/code><\/p>\n\n    <p><strong><code>This solution is also considered valid.<\/code><\/strong><\/p>\n    <p><strong>BFS: <\/strong><code>[Mussoorie, Dehradun, Chandigarh, , Delhi, Jaipur, Agra]<\/code><\/p>\n\n    <p><strong>We implement Breadth-First Search (BFS) using a queue data structure<\/strong><\/p>\n   \n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/1.png\" alt=\"\">\n    <ul>\n        <li><code>Start by choosing a source node<\/code> (the node from where you want to begin the traversal).<\/li>\n        <li><code>Create a <strong>visited<\/strong> array or set<\/code> to keep track of nodes you have already visited.<\/li>\n        <li><code>Add the starting node to the queue<\/code> and mark it as visited.<\/li>\n        <li>While the queue is not empty:\n            <ul>\n                <li>Remove (poll) one node from the front of the queue.<\/li>\n                <li>Check all adjacent (neighbouring) nodes of this node.<\/li>\n                <li>For each adjacent node:\n                    <ul>\n                        <li>If it is <strong>not visited<\/strong>, then:\n                            <ul>\n                                <li>Mark it as visited.<\/li>\n                                <li>Add it to the queue.<\/li>\n                            <\/ul>\n                        <\/li>\n                    <\/ul>\n                <\/li>\n            <\/ul>\n        <\/li>\n        <li><strong>Repeat this process<\/strong> until the queue becomes empty.<\/li>\n    <\/ul>\n\n    <h2>Problem Statement:<\/h2>\n    <p>\n       Given a reference of a node in a connected undirected graph.\n    <\/p>\n    <p>\n        Return a deep copy (clone) of the graph.\n    <\/p>\n    <p>\n        Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors.\n    <\/p>\n    <pre>\n        class Node {\n            public int val;\n            public List<Node> neighbors;\n        }\n    <\/pre>\n\n    <p><strong>Test case format:<\/strong><\/p>\n    <p>\n        For simplicity, each node&#8217;s value is the same as the node&#8217;s index (1-indexed). For example, the first node with <code>val == 1<\/code>, the second node with val == 2, and so on. The graph is represented in the test case using an adjacency list.\n    <\/p>\n\n    <p>\n        <strong>An adjacency list<\/strong> is a collection of unordered <strong>lists<\/strong> used to represent a finite graph. Each list describes the set of neighbors of a node in the graph.\n    <\/p>\n\n    <p>\n        The given node will always be the first node with <code>val = 1<\/code>. You must return the <strong>copy of the given node<\/strong> as a reference to the cloned graph.\n    <\/p>\n\n    <h3>Example 1:<\/h3>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/img_1.png\" alt=\"\">\n    <p><strong>Input: <\/strong>adjList = [[2,4],[1,3],[2,4],[1,3]]<\/p>\n    <p><strong>Output: <\/strong>[[2,4],[1,3],[2,4],[1,3]]<\/p>\n    <p><strong>Explanation: <\/strong>There are 4 nodes in the graph.\n        1st node (val = 1)&#8217;s neighbors are 2nd node (val = 2) and 4th node (val = 4).\n        2nd node (val = 2)&#8217;s neighbors are 1st node (val = 1) and 3rd node (val = 3).\n        3rd node (val = 3)&#8217;s neighbors are 2nd node (val = 2) and 4th node (val = 4).\n        4th node (val = 4)&#8217;s neighbors are 1st node (val = 1) and 3rd node (val = 3).<\/p>\n\n    <h3>Example 2:<\/h3>\n    <img decoding=\"async\" src=\"https:\/\/namastedev.com\/blog\/wp-content\/uploads\/2025\/11\/img_2.png\" alt=\"\">\n    <p><strong>Input: <\/strong>adjList = [[]]<\/p>\n    <p><strong>Output: <\/strong>[[]]<\/p>\n    <p><strong>Explanation: <\/strong>Note that the input contains one empty list. The graph consists of only one node with val = 1 and it does not have any neighbors.<\/p>\n\n\n    <h3>Example 3:<\/h3>\n    <p><strong>Input: <\/strong>adjList = []<\/p>\n    <p><strong>Output: <\/strong>[]<\/p>\n    <p><strong>Explanation: <\/strong>This an empty graph, it does not have any nodes.<\/p>\n\n    <h3>Constraints<\/h3>\n    <ul>\n        <li>The number of nodes in the graph is in the range [0, 100].<\/li>\n        <li><code>1 <= Node.val <= 100<\/code><\/li>\n        <li><code>Node.val<\/code> is unique for each node.<\/li>\n        <li>There are no repeated edges and no self-loops in the graph.<\/li>\n        <li>The Graph is connected and all nodes can be visited starting from the given node.<\/li>\n    <\/ul>\n    \n    <h2>Approach<\/h2>\n    <ul>\n        <li>If the input node is NULL \u2192 return NULL.<\/li>\n        <li>Create the clone of the starting node and insert it into the map.<\/li>\n        <li>Use a queue (BFS):\n            <ul>\n                <li>Push the original root node.<\/li>\n            <\/ul>\n        <\/li>\n        <li>While the queue is not empty:\n            <ul>\n                <li>Pop one node curr.<\/li>\n                <li>For each neighbor n of curr:\n                    <ul>\n                        <li>If n is not cloned yet:\n                            <ul>\n                                <li>Create a clone of n.<\/li>\n                                <li>Add it to the map.<\/li>\n                                <li>Push n into the queue.<\/li>\n                            <\/ul>\n                        <\/li>\n                        <li>Add the cloned neighbor to the neighbor list of the current cloned node.<\/li>\n                    <\/ul>\n                <\/li>\n            <\/ul>\n        <\/li>\n        <li>Return the cloned root from the map.<\/li>\n    <\/ul>\n\n<\/div> \n\n    <div class=\"wp_blog_code-tabs-container\">\n        <div class=\"wp_blog_code-tabs-header\">\n            <button class=\"wp_blog_code-tab-button active\" data-lang=\"js\">JavaScript<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"py\">Python<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"java\">Java<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"cpp\">C++<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"c\">C<\/button>\n            <button class=\"wp_blog_code-tab-button\" data-lang=\"cs\">C#<\/button>\n        <\/div>\n\n        <!-- JavaScript -->\n        <div class=\"wp_blog_code-tab-content active\" data-lang=\"js\">\n            <pre><code class=\"language-javascript\">\n var cloneGraph = function(root) {\n    if (!root) return null;\n\n    const q = [root];\n    const visited = new Map();\n    const cloneRoot = new Node(root.val);\n    visited.set(root, cloneRoot);\n\n    while (q.length) {\n        const curr = q.shift();\n        const cloneCurr = visited.get(curr);\n\n        for (const n of curr.neighbors) {\n            if (!visited.has(n)) {\n                visited.set(n, new Node(n.val));\n                q.push(n);\n            }\n            cloneCurr.neighbors.push(visited.get(n));\n        }\n    }\n    return cloneRoot;\n};       <\/code><\/pre>\n        <\/div>\n\n        <!-- Python -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"py\">\n            <pre><code class=\"language-python\">\nfrom collections import deque\n\nclass Node:\n    def __init__(self, val = 0, neighbors = None):\n        self.val = val\n        self.neighbors = neighbors if neighbors is not None else []\n\ndef cloneGraph(node: 'Node') -> 'Node':\n    if not node:\n        return None\n\n    visited = {}\n    q = deque([node])\n\n    cloneRoot = Node(node.val)\n    visited[node] = cloneRoot\n\n    while q:\n        curr = q.popleft()\n        cloneCurr = visited[curr]\n\n        for n in curr.neighbors:\n            if n not in visited:\n                visited[n] = Node(n.val)\n                q.append(n)\n            cloneCurr.neighbors.append(visited[n])\n\n    return cloneRoot\n\n            <\/code><\/pre>\n        <\/div>\n\n        <!-- Java -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"java\">\n            <pre><code class=\"language-java\">\nimport java.util.*;\n\nclass Node {\n    public int val;\n    public List<Node> neighbors;\n    public Node() { val = 0; neighbors = new ArrayList<Node>(); }\n    public Node(int _val) { val = _val; neighbors = new ArrayList<Node>(); }\n    public Node(int _val, ArrayList<Node> _neighbors) { val = _val; neighbors = _neighbors; }\n}\n\npublic class Solution {\n    public Node cloneGraph(Node node) {\n        if (node == null) return null;\n\n        Map<Node, Node> visited = new HashMap<>();\n        Queue<Node> q = new LinkedList<>();\n\n        Node cloneRoot = new Node(node.val);\n        visited.put(node, cloneRoot);\n        q.add(node);\n\n        while (!q.isEmpty()) {\n            Node curr = q.poll();\n            Node cloneCurr = visited.get(curr);\n\n            for (Node n : curr.neighbors) {\n                if (!visited.containsKey(n)) {\n                    visited.put(n, new Node(n.val));\n                    q.add(n);\n                }\n                cloneCurr.neighbors.add(visited.get(n));\n            }\n        }\n        return cloneRoot;\n    }\n}\n     <\/code><\/pre>\n        <\/div>\n\n        <!-- C++ -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"cpp\">\n            <pre><code class=\"language-cpp\">\n#include &lt;vector&gt;\n#include &lt;queue&gt;\n#include &lt;nordered_map&gt;\nusing namespace std;\n\nclass Node {\npublic:\n    int val;\n    vector<Node*> neighbors;\n    Node() : val(0) {}\n    Node(int _val) : val(_val) {}\n    Node(int _val, vector<Node*> _neighbors) : val(_val), neighbors(_neighbors) {}\n};\n\nNode* cloneGraph(Node* node) {\n    if (!node) return nullptr;\n\n    unordered_map<Node*, Node*> visited;\n    queue<Node*> q;\n\n    Node* cloneRoot = new Node(node->val);\n    visited[node] = cloneRoot;\n    q.push(node);\n\n    while (!q.empty()) {\n        Node* curr = q.front(); q.pop();\n        Node* cloneCurr = visited[curr];\n\n        for (Node* n : curr->neighbors) {\n            if (visited.find(n) == visited.end()) {\n                visited[n] = new Node(n->val);\n                q.push(n);\n            }\n            cloneCurr->neighbors.push_back(visited[n]);\n        }\n    }\n    return cloneRoot;\n}\n  <\/code><\/pre>\n        <\/div>\n\n        <!-- C -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"c\">\n            <pre><code class=\"language-c\">\n#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\ntypedef struct Node {\n    int val;\n    struct Node** neighbors;\n    int neighborsCount;\n} Node;\n\n\/********** Create a new node **********\/\nNode* createNode(int val) {\n    Node* n = (Node*)malloc(sizeof(Node));\n    n->val = val;\n    n->neighbors = NULL;\n    n->neighborsCount = 0;\n    return n;\n}\n\nvoid addNeighbor(Node* node, Node* neigh) {\n    node->neighbors = realloc(node->neighbors,\n                              sizeof(Node*) * (node->neighborsCount + 1));\n    node->neighbors[node->neighborsCount++] = neigh;\n}\nNode* findClone(Node** origs, Node** clones, int size, Node* key) {\n    for (int i = 0; i < size; i++) {\n        if (origs[i] == key) {\n            return clones[i];\n        }\n    }\n    return NULL;\n}\n\nvoid addMapping(Node*** origs, Node*** clones, int* size,\n                Node* orig, Node* clone) {\n\n    int newSize = *size + 1;\n\n    *origs  = realloc(*origs,  newSize * sizeof(Node*));\n    *clones = realloc(*clones, newSize * sizeof(Node*));\n\n    (*origs)[*size] = orig;\n    (*clones)[*size] = clone;\n\n    *size = newSize;\n}\nNode* cloneGraph(Node* node) {\n    if (!node) return NULL;\n\n    \/\/ visited map arrays\n    Node** origs = NULL;\n    Node** clones = NULL;\n    int mapSize = 0;\n\n    \/\/ BFS queue\n    int capacity = 64;\n    Node** queue = malloc(sizeof(Node*) * capacity);\n    int head = 0, tail = 0;\n\n    \/\/ clone the root\n    Node* cloneRoot = createNode(node->val);\n    addMapping(&origs, &clones, &mapSize, node, cloneRoot);\n\n    queue[tail++] = node;\n\n    while (head < tail) {\n        Node* curr = queue[head++];\n        Node* cloneCurr = findClone(origs, clones, mapSize, curr);\n\n        for (int i = 0; i < curr->neighborsCount; i++) {\n            Node* neigh = curr->neighbors[i];\n            Node* cloneNeigh = findClone(origs, clones, mapSize, neigh);\n\n            \/\/ if not cloned yet, clone it + enqueue\n            if (!cloneNeigh) {\n                cloneNeigh = createNode(neigh->val);\n                addMapping(&origs, &clones, &mapSize, neigh, cloneNeigh);\n\n                if (tail == capacity) {\n                    capacity *= 2;\n                    queue = realloc(queue, sizeof(Node*) * capacity);\n                }\n                queue[tail++] = neigh;\n            }\n\n            \/\/ link clone\n            addNeighbor(cloneCurr, cloneNeigh);\n        }\n    }\n\n    free(queue);\n    free(origs);\n    free(clones);\n    return cloneRoot;\n}     <\/code><\/pre>\n        <\/div>\n\n        <!-- C# -->\n        <div class=\"wp_blog_code-tab-content\" data-lang=\"cs\">\n            <pre><code class=\"language-csharp\">\nusing System.Collections.Generic;\n\npublic class Node {\n    public int val;\n    public IList<Node> neighbors;\n    public Node() { val = 0; neighbors = new List<Node>(); }\n    public Node(int _val) { val = _val; neighbors = new List<Node>(); }\n    public Node(int _val, IList<Node> _neighbors) { val = _val; neighbors = _neighbors; }\n}\n\npublic class Solution {\n    public Node CloneGraph(Node node) {\n        if (node == null) return null;\n\n        var visited = new Dictionary<Node, Node>();\n        var q = new Queue<Node>();\n\n        Node cloneRoot = new Node(node.val);\n        visited[node] = cloneRoot;\n        q.Enqueue(node);\n\n        while (q.Count > 0) {\n            var curr = q.Dequeue();\n            var cloneCurr = visited[curr];\n\n            foreach (var n in curr.neighbors) {\n                if (!visited.ContainsKey(n)) {\n                    visited[n] = new Node(n.val);\n                    q.Enqueue(n);\n                }\n                cloneCurr.neighbors.Add(visited[n]);\n            }\n        }\n\n        return cloneRoot;\n    }\n}\n            <\/code><\/pre>\n        <\/div>\n    <\/div>\n\n<\/div>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n  const buttons = document.querySelectorAll(\".wp_blog_code-tab-button\");\n  const contents = document.querySelectorAll(\".wp_blog_code-tab-content\");\n\n  buttons.forEach((button) => {\n    button.addEventListener(\"click\", () => {\n      const lang = button.getAttribute(\"data-lang\");\n\n      buttons.forEach((btn) => btn.classList.remove(\"active\"));\n      contents.forEach((content) => content.classList.remove(\"active\"));\n\n      button.classList.add(\"active\");\n      document\n        .querySelector(`.wp_blog_code-tab-content[data-lang=\"${lang}\"]`)\n        .classList.add(\"active\");\n    });\n  });\n\n  const themeToggle = document.getElementById(\"blogNotesThemeToggle\");\n  const themeContainer = document.querySelector(\".wp_blog_theme\");\n\n  themeToggle.addEventListener(\"click\", () => {\n    themeContainer.classList.toggle(\"dark-mode\");\n    themeToggle.textContent =\n      themeContainer.classList.contains(\"dark-mode\") ? \"\u2600\ufe0f\" : \"\ud83c\udf19\";\n  });\n});\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udf19 Breadth First Search (BFS) Example: 1 BFS: [0, 1, 2, 3, 4] Example: 2 BFS: [1, 2, 4, 3, 5, 9, 8, 6, 7] Real-World Example BFS: [Mussoorie, Dehradun, Chandigarh, , Delhi, Agra, Jaipur] This solution is also considered valid. BFS: [Mussoorie, Dehradun, Chandigarh, , Delhi, Jaipur, Agra] We implement Breadth-First Search (BFS) using<\/p>\n","protected":false},"author":108,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[210,322,260,176,175,211,810,174,172,177,173],"tags":[],"class_list":["post-11202","post","type-post","status-publish","format-standard","category-algorithms","category-algorithms-and-data-structures","category-c-c-plus-plus","category-csharp","category-cplusplus","category-data-structures","category-dsa","category-java","category-javascript","category-php","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/108"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=11202"}],"version-history":[{"count":2,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11202\/revisions"}],"predecessor-version":[{"id":11208,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/11202\/revisions\/11208"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=11202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=11202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=11202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}