{"id":6110,"date":"2023-11-13T13:36:32","date_gmt":"2023-11-13T20:36:32","guid":{"rendered":"https:\/\/ioflood.com\/blog\/?p=6110"},"modified":"2024-02-19T20:28:18","modified_gmt":"2024-02-20T03:28:18","slug":"binary-search-java","status":"publish","type":"post","link":"https:\/\/ioflood.com\/blog\/binary-search-java\/","title":{"rendered":"binarySearch() Java: Locating Elements in Sorted Arrays"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/ioflood.com\/blog\/wp-content\/uploads\/2023\/11\/clean_binary_search_tree_structure_for_java_programming-300x300.jpg\" alt=\"clean_binary_search_tree_structure_for_java_programming\" width=\"300\" height=\"300\" title=\"\"><\/figure>\n<\/div>\n<p>Are you finding it challenging to implement binary search in Java? You&#8217;re not alone. Many developers find themselves in a maze when it comes to binary search in Java, but we&#8217;re here to help.<\/p>\n<p>Think of binary search as a detective, helping you find the &#8216;suspect&#8217; (element) in a sorted &#8216;lineup&#8217; (array) in the most efficient way. It&#8217;s a powerful tool that can significantly speed up your search process in sorted arrays.<\/p>\n<p><strong>In this guide, we&#8217;ll walk you through the process of implementing and using binary search in Java<\/strong>, from basic use to advanced techniques. We&#8217;ll cover everything from the logic behind binary search, how to write the code, to more complex uses and common issues you may encounter.<\/p>\n<p>So, let&#8217;s dive in and start mastering binary search in Java!<\/p>\n<h2>TL;DR: How Do I Implement Binary Search in Java?<\/h2>\n<blockquote><p>\n  The simplest way to perform a binary search in Java is by using the <code>Arrays.binarySearch()<\/code> method from the Java standard library, with the syntax <code>int result = Arrays.binarySearch(arrayToSearch, keyToSearch);<\/code>.\n<\/p><\/blockquote>\n<p>Here&#8217;s a basic example:<\/p>\n<pre><code class=\"language-java line-numbers\">int[] arr = {10, 20, 30, 40, 50};\nint key = 30;\nint result = Arrays.binarySearch(arr, key);\n\n\/\/ Output:\n\/\/ 2\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created an array <code>arr<\/code> and a key <code>key<\/code> that we want to find in the array. We then use the <code>Arrays.binarySearch()<\/code> method to find the index of the key in the array. The method returns the index of the key, which is 2 in this case.<\/p>\n<blockquote><p>\n  This is a basic way to use binary search in Java, but there&#8217;s much more to learn about implementing and using binary search in Java. Continue reading for more detailed information and advanced usage scenarios.\n<\/p><\/blockquote>\n<h2>Implementing Binary Search in Java: The Basics<\/h2>\n<p>Binary search is a divide-and-conquer algorithm that reduces the search space by half at each step. It starts by comparing the middle element of a sorted array with the target value. If the target value matches the middle element, its position in the array is returned. If the target value is less or more than the middle element, the search continues on the lower or upper half of the array, respectively.<\/p>\n<p>Now, let&#8217;s dive into how to implement this algorithm in Java.<\/p>\n<h3>Step-by-Step Guide to Writing Binary Search Code<\/h3>\n<p>Here&#8217;s a simple code example of how to implement binary search in Java:<\/p>\n<pre><code class=\"language-java line-numbers\">public class BinarySearch {\n    int binarySearch(int arr[], int x) {\n        int l = 0, r = arr.length - 1;\n        while (l &lt;= r) {\n            int m = l + (r - l) \/ 2;\n\n            \/\/ Check if x is present at mid\n            if (arr[m] == x)\n                return m;\n\n            \/\/ If x greater, ignore left half\n            if (arr[m] &lt; x)\n                l = m + 1;\n\n            \/\/ If x is smaller, ignore right half\n            else\n                r = m - 1;\n        }\n\n        \/\/ if we reach here, then element was not present\n        return -1;\n    }\n}\n\n\/\/ Driver method to test above\npublic static void main(String args[]) {\n    BinarySearch bs = new BinarySearch();\n    int arr[] = {2, 3, 4, 10, 40};\n    int n = arr.length;\n    int x = 10;\n    int result = bs.binarySearch(arr, x);\n    if(result == -1)\n        System.out.println(\"Element not present in array\");\n    else\n        System.out.println(\"Element found at index \" + result);\n}\n\n\/\/ Output:\n\/\/ Element found at index 3\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a <code>BinarySearch<\/code> class with a <code>binarySearch<\/code> method. This method takes an array <code>arr[]<\/code> and a target value <code>x<\/code> as parameters. It starts by defining the lower (<code>l<\/code>) and upper (<code>r<\/code>) bounds of the search space. Then, it enters a while loop where it calculates the middle index <code>m<\/code> and compares the middle element <code>arr[m]<\/code> with the target value <code>x<\/code>. Depending on the comparison, it either returns the middle index or adjusts the search space. If the target value is not found, it returns -1.<\/p>\n<h2>Binary Search in Java: Advanced Techniques<\/h2>\n<p>As you become more comfortable with the basics of binary search in Java, you can start to explore more complex uses. Two such uses include searching in a 2D array and using binary search with custom objects.<\/p>\n<h3>Binary Search in 2D Arrays<\/h3>\n<p>Implementing binary search on a 2D array is a bit more complex than a 1D array, but it&#8217;s still feasible. The idea is to apply binary search on both dimensions of the 2D array.<\/p>\n<p>Here&#8217;s an example of how you can implement binary search in a 2D array:<\/p>\n<pre><code class=\"language-java line-numbers\">public class BinarySearch2D {\n    int[] binarySearch(int matrix[][], int target) {\n        int row = matrix.length;\n        int col = matrix[0].length;\n\n        int low = 0;\n        int high = row*col - 1;\n\n        while(low &lt;= high) {\n            int mid = low + (high - low) \/ 2;\n            int mid_element = matrix[mid\/col][mid%col];\n\n            if(target == mid_element)\n                return new int[]{mid\/col, mid%col};\n\n            else if(target &lt; mid_element)\n                high = mid - 1;\n\n            else\n                low = mid + 1;\n        }\n\n        return new int[]{-1, -1};\n    }\n}\n\n\/\/ Driver method to test above\npublic static void main(String args[]) {\n    BinarySearch2D bs2d = new BinarySearch2D();\n    int matrix[][] = {{1, 3, 5}, {7, 9, 11}, {13, 15, 17}};\n    int target = 15;\n    int result[] = bs2d.binarySearch(matrix, target);\n    if(result[0] == -1)\n        System.out.println(\"Element not present in matrix\");\n    else\n        System.out.println(\"Element found at index \" + Arrays.toString(result));\n}\n\n\/\/ Output:\n\/\/ Element found at index [2, 1]\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a <code>BinarySearch2D<\/code> class with a <code>binarySearch<\/code> method. This method takes a 2D array <code>matrix[][]<\/code> and a target value <code>target<\/code> as parameters. It starts by defining the lower (<code>low<\/code>) and upper (<code>high<\/code>) bounds of the search space, which is the total number of elements in the matrix. Then, it enters a while loop where it calculates the middle index <code>mid<\/code> and the middle element <code>mid_element<\/code>. Depending on the comparison between <code>mid_element<\/code> and <code>target<\/code>, it either returns the indices of <code>mid_element<\/code> or adjusts the search space. If the target value is not found, it returns [-1, -1].<\/p>\n<h3>Binary Search with Custom Objects<\/h3>\n<p>In Java, you can also use binary search with custom objects. The key is to provide a way for the <code>Collections.binarySearch()<\/code> method to compare the custom objects. You can do this by making your custom class implement the <code>Comparable<\/code> interface or by providing a custom <code>Comparator<\/code>.<\/p>\n<p>Here&#8217;s how you can implement binary search with custom objects:<\/p>\n<pre><code class=\"language-java line-numbers\">import java.util.Arrays;\nimport java.util.Comparator;\n\n\/\/ Custom class\nclass Point {\n    int x, y;\n\n    \/\/ Constructor\n    public Point(int x, int y) {\n        this.x = x;\n        this.y = y;\n    }\n}\n\n\/\/ Custom comparator\nclass MyComparator implements Comparator&lt;Point&gt; {\n    public int compare(Point p1, Point p2) {\n        return p1.x - p2.x;\n    }\n}\n\n\/\/ Driver method to test above\npublic static void main(String args[]) {\n    Point arr[] = {new Point(10, 20), new Point(30, 40), new Point(50, 60)};\n    Point key = new Point(30, 40);\n    int result = Arrays.binarySearch(arr, key, new MyComparator());\n    if(result &lt; 0)\n        System.out.println(\"Element not present in array\");\n    else\n        System.out.println(\"Element found at index \" + result);\n}\n\n\/\/ Output:\n\/\/ Element found at index 1\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a custom <code>Point<\/code> class and a custom <code>MyComparator<\/code> class. The <code>Point<\/code> class represents points in a 2D space, and the <code>MyComparator<\/code> class defines how to compare two <code>Point<\/code> objects. We then create an array of <code>Point<\/code> objects and use the <code>Arrays.binarySearch()<\/code> method with the custom comparator to find the index of a target <code>Point<\/code> object in the array.<\/p>\n<h2>Exploring Alternative Approaches to Binary Search in Java<\/h2>\n<p>In Java, there are several alternative methods you can use to perform a binary search. Two of these methods include using the <code>Collections.binarySearch()<\/code> method for lists and implementing an iterative binary search. Let&#8217;s delve into these methods.<\/p>\n<h3>Binary Search on Lists Using <code>Collections.binarySearch()<\/code><\/h3>\n<p>The <code>Collections.binarySearch()<\/code> method is a powerful tool for performing binary search on lists. This method assumes that the list is already sorted in ascending order.<\/p>\n<p>Here&#8217;s an example of how you can use <code>Collections.binarySearch()<\/code>:<\/p>\n<pre><code class=\"language-java line-numbers\">import java.util.Arrays;\nimport java.util.List;\nimport java.util.Collections;\n\npublic class BinarySearchList {\n    public static void main(String[] args) {\n        List&lt;Integer&gt; list = Arrays.asList(2, 4, 6, 8, 10, 12, 14, 16);\n        int key = 10;\n        int result = Collections.binarySearch(list, key);\n        System.out.println(\"Element found at index \" + result);\n    }\n}\n\n\/\/ Output:\n\/\/ Element found at index 4\n<\/code><\/pre>\n<p>In this example, we&#8217;ve created a list of integers and used the <code>Collections.binarySearch()<\/code> method to find the index of a target integer in the list. The method returns the index of the target integer, which is 4 in this case.<\/p>\n<h3>Implementing Iterative Binary Search<\/h3>\n<p>An iterative binary search is another alternative approach to recursive binary search. This method uses a while loop instead of recursion to find the target element.<\/p>\n<p>Here&#8217;s an example of how you can implement an iterative binary search in Java:<\/p>\n<pre><code class=\"language-java line-numbers\">public class IterativeBinarySearch {\n    int binarySearch(int arr[], int x) {\n        int l = 0, r = arr.length - 1;\n        while (l &lt;= r) {\n            int m = l + (r - l) \/ 2;\n\n            if (arr[m] == x)\n                return m;\n\n            if (arr[m] &lt; x)\n                l = m + 1;\n\n            else\n                r = m - 1;\n        }\n\n        return -1;\n    }\n}\n\n\/\/ Driver method to test above\npublic static void main(String args[]) {\n    IterativeBinarySearch ibs = new IterativeBinarySearch();\n    int arr[] = {2, 3, 4, 10, 40};\n    int x = 10;\n    int result = ibs.binarySearch(arr, x);\n    if(result == -1)\n        System.out.println(\"Element not present in array\");\n    else\n        System.out.println(\"Element found at index \" + result);\n}\n\n\/\/ Output:\n\/\/ Element found at index 3\n<\/code><\/pre>\n<p>In this example, the <code>binarySearch<\/code> method implements an iterative binary search. It takes an array <code>arr[]<\/code> and a target value <code>x<\/code> as parameters. It uses a while loop to find the index of the target value in the array. If the target value is not found, it returns -1.<\/p>\n<p>As you can see, each of these methods has its own benefits and use cases. The <code>Collections.binarySearch()<\/code> method is great for searching in lists, while the iterative binary search can sometimes be easier to understand and debug than a recursive binary search. The best method to use depends on your specific needs and circumstances.<\/p>\n<h2>Troubleshooting Binary Search in Java<\/h2>\n<p>Even with the best understanding and implementation of binary search in Java, you may still encounter some common issues. Let&#8217;s discuss these potential pitfalls and provide solutions to overcome them.<\/p>\n<h3>Off-By-One Errors<\/h3>\n<p>One of the most common issues you might face when implementing binary search in Java is the infamous off-by-one error. This error typically occurs when you miscalculate the middle index or incorrectly define the boundaries of your search space.<\/p>\n<p>To avoid off-by-one errors, always ensure that your middle index calculation (<code>int m = l + (r - l) \/ 2;<\/code>) is correct, and that your search space boundaries (<code>l<\/code> and <code>r<\/code>) are appropriately defined and updated.<\/p>\n<h3>Unsorted Arrays<\/h3>\n<p>Binary search in Java requires the array to be sorted before the search. If your array is not sorted, the binary search algorithm will not work correctly.<\/p>\n<p>Always ensure that your array is sorted in ascending order before performing a binary search. You can use Java&#8217;s built-in methods such as <code>Arrays.sort(arr)<\/code> to sort an array.<\/p>\n<h3>Handling Duplicate Elements<\/h3>\n<p>If your array contains duplicate elements, the binary search algorithm may not return the index of the first occurrence of the target element. Instead, it might return the index of any occurrence.<\/p>\n<p>If you need to find the first or last occurrence of a target element in an array with duplicate elements, you may need to modify your binary search algorithm or use a different search algorithm.<\/p>\n<h3>Array Index Out of Bounds<\/h3>\n<p>Another common issue is the ArrayIndexOutOfBoundsException, which occurs when you try to access an array element using an invalid index. This can happen if your search space boundaries (<code>l<\/code> and <code>r<\/code>) are incorrectly defined or updated.<\/p>\n<p>Always ensure that your search space boundaries are within the valid range of indices for your array.<\/p>\n<p>Implementing binary search in Java can be tricky, but with these troubleshooting tips and best practices, you can avoid common issues and ensure that your binary search algorithm works correctly.<\/p>\n<h2>Understanding Binary Search: The Basics<\/h2>\n<p>Before we delve deeper into the implementation of binary search in Java, it&#8217;s crucial to understand the fundamentals of the binary search algorithm itself and its time complexity.<\/p>\n<h3>The Binary Search Algorithm<\/h3>\n<p>Binary search is a fast search algorithm that finds the position of a target value within a sorted array. It works by repeatedly dividing the search interval in half and comparing the target value with the middle element of the current search interval.<\/p>\n<p>If the target value matches the middle element, its position in the array is returned. If the target value is less or more than the middle element, the search continues on the lower or upper half of the array, respectively.<\/p>\n<p>Here&#8217;s a simple illustration of how the binary search algorithm works:<\/p>\n<pre><code class=\"language-java line-numbers\">\/\/ Initial array (sorted)\nint[] arr = {2, 3, 4, 10, 40, 55, 78, 99};\n\n\/\/ Target value\nint key = 40;\n\n\/\/ Binary search process\n\/\/ Step 1: Compare key with middle element (10). Key is larger, so consider right half.\n\/\/ Step 2: In the right half, compare key with middle element (55). Key is smaller, so consider left half.\n\/\/ Step 3: In the new left half, compare key with middle element (40). Key matches, so return index.\n<\/code><\/pre>\n<p>In this example, the binary search algorithm successfully finds the target value (40) in the sorted array after three steps.<\/p>\n<h3>Time Complexity of Binary Search<\/h3>\n<p>The time complexity of binary search is O(log n), where n is the number of elements in the array. This is because with each step, the binary search algorithm halves the search space. This division process can be repeated approximately log n times until the search space is reduced to just one element.<\/p>\n<p>The logarithmic time complexity of binary search makes it very efficient for large arrays. For example, for an array with a million elements, binary search can find the target value in just 20 steps in the worst case scenario.<\/p>\n<h3>The Importance of Sorting in Binary Search<\/h3>\n<p>Binary search relies on the array being sorted in ascending order. This is because the algorithm works by comparing the target value with the middle element and then deciding whether to continue the search on the left or right half of the array. If the array is not sorted, this decision process will not work correctly, and the algorithm may not find the target value even if it&#8217;s present in the array.<\/p>\n<p>In conclusion, binary search is a powerful and efficient search algorithm that can significantly speed up the search process in sorted arrays. Understanding the basics of this algorithm and its time complexity is crucial for implementing it correctly and effectively in Java.<\/p>\n<h2>Broader Applications of Binary Search in Java<\/h2>\n<p>Binary search in Java is not limited to finding elements in arrays. The algorithm&#8217;s efficiency and speed make it suitable for a variety of applications, including data analysis and machine learning.<\/p>\n<h3>Binary Search in Data Analysis<\/h3>\n<p>In data analysis, binary search can be used to quickly find specific data points in large datasets. For instance, if you have a sorted dataset of user activity on a website, you could use binary search to quickly find the activities of a specific user or within a specific time frame.<\/p>\n<pre><code class=\"language-java line-numbers\">\/\/ Simplified example - finding user activity\nUserActivity[] activities = ...; \/\/ Sorted array of user activities\nUserActivity key = ...; \/\/ The target user activity\n\nint index = Arrays.binarySearch(activities, key, new UserActivityComparator());\n\n\/\/ Output:\n\/\/ Index of the target user activity or -1 if not found\n<\/code><\/pre>\n<p>In this example, <code>UserActivity<\/code> is a custom class that represents user activities, and <code>UserActivityComparator<\/code> is a custom comparator that defines how to compare two <code>UserActivity<\/code> objects. The <code>Arrays.binarySearch()<\/code> method is then used to find the index of a target <code>UserActivity<\/code> object in the array.<\/p>\n<h3>Binary Search in Machine Learning<\/h3>\n<p>In machine learning, binary search can be used in decision trees, which are a type of model used for classification and regression. Each node in the decision tree represents a binary decision, effectively forming a binary search algorithm.<\/p>\n<pre><code class=\"language-java line-numbers\">\/\/ Simplified example - decision tree node\npublic class DecisionTreeNode {\n    DecisionTreeNode leftChild, rightChild;\n    Decision decision;\n\n    public DecisionTreeNode(DecisionTreeNode leftChild, DecisionTreeNode rightChild, Decision decision) {\n        this.leftChild = leftChild;\n        this.rightChild = rightChild;\n        this.decision = decision;\n    }\n}\n\n\/\/ Output:\n\/\/ A node in a decision tree, representing a binary decision\n<\/code><\/pre>\n<p>In this example, <code>DecisionTreeNode<\/code> is a class that represents a node in a decision tree, and <code>Decision<\/code> is a class that represents a binary decision. Each <code>DecisionTreeNode<\/code> has a left child, a right child, and a decision, forming a binary search tree structure.<\/p>\n<h3>Further Resources for Binary Search in Java<\/h3>\n<p>If you&#8217;re interested in learning more about binary search in Java and related topics, here are some resources you might find beneficial:<\/p>\n<ul>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/java-stream\/\">Java Stream: Enhancing Data Manipulation<\/a> &#8211; Dive into advanced topics like parallelism and concurrency in Java stream processing.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/java-stream-filter\/\">Exploring Java Stream Filter<\/a> &#8211; Master Java stream filter operations for efficient data manipulation and extraction.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/merge-sort-java\/\">Java Merge Sort Algorithm<\/a> &#8211; Learn Java merge sort techniques for efficient sorting of large datasets.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/algs4.cs.princeton.edu\/11model\/\" target=\"_blank\" rel=\"noopener\">Java Algorithms and Clients<\/a> &#8211; A comprehensive resource that covers various algorithms in Java, including binary search.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/\" target=\"_blank\" rel=\"noopener\">Oracle&#8217;s Java Tutorials<\/a> covers a wide range of topics, including collections, generics, and more.<\/p>\n<\/li>\n<li>\n<p>GeeksforGeeks&#8217; <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.geeksforgeeks.org\/binary-search\/\" target=\"_blank\" rel=\"noopener\">Binary Search Guide<\/a> provides a detailed explanation of binary search, its implementation, and its variations.<\/p>\n<\/li>\n<\/ul>\n<h2>Wrapping Up: Binary Search in Java<\/h2>\n<p>In this comprehensive guide, we&#8217;ve delved into the process of implementing and using binary search in Java, an efficient algorithm for finding elements in sorted arrays.<\/p>\n<p>We started with the basics, learning how to implement binary search using the <code>Arrays.binarySearch()<\/code> method from the Java standard library. We then moved onto more advanced techniques, such as performing binary search on 2D arrays and using binary search with custom objects. Along the way, we tackled common issues you might encounter when implementing binary search, such as off-by-one errors and problems with unsorted arrays, providing solutions and best practices for each issue.<\/p>\n<p>We also explored alternative methods for performing binary search in Java, such as using the <code>Collections.binarySearch()<\/code> method for lists and implementing an iterative binary search. Here&#8217;s a quick comparison of these methods:<\/p>\n<table>\n<thead>\n<tr>\n<th>Method<\/th>\n<th>Use Case<\/th>\n<th>Complexity<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Arrays.binarySearch()<\/code><\/td>\n<td>Arrays<\/td>\n<td>O(log n)<\/td>\n<\/tr>\n<tr>\n<td><code>Collections.binarySearch()<\/code><\/td>\n<td>Lists<\/td>\n<td>O(log n)<\/td>\n<\/tr>\n<tr>\n<td>Iterative Binary Search<\/td>\n<td>Custom Implementation<\/td>\n<td>O(log n)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Whether you&#8217;re just starting out with binary search in Java or you&#8217;re looking to refine your skills, we hope this guide has helped you understand the intricacies of binary search and its implementation in Java.<\/p>\n<p>Armed with this knowledge, you&#8217;re now ready to implement binary search in your Java programs and solve complex problems more efficiently. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you finding it challenging to implement binary search in Java? You&#8217;re not alone. Many developers find themselves in a maze when it comes to binary search in Java, but we&#8217;re here to help. Think of binary search as a detective, helping you find the &#8216;suspect&#8217; (element) in a sorted &#8216;lineup&#8217; (array) in the most [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9912,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[154,121],"tags":[],"class_list":["post-6110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-programming-coding","cat-154-id","cat-121-id","has_thumb"],"_links":{"self":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/comments?post=6110"}],"version-history":[{"count":10,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6110\/revisions"}],"predecessor-version":[{"id":17539,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/6110\/revisions\/17539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media\/9912"}],"wp:attachment":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media?parent=6110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/categories?post=6110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/tags?post=6110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}