Check if a Binary Tree is Binary Search Tree or not

Introduction This tutorial will check if a Binary Tree is Binary Search Tree or not. We know that a binary search tree (BST) is a node based binary tree data structure which satisfies the following properties: The left sub-tree of a node contains only nodes with keys less than the root node’s key. The right sub-tree of a node contains only nodes with keys greater than the root node’s key. Both the left and right sub-trees must also be again binary search trees. We will implement the algorithm using Java program…

Continue

Finding Start and End Index of an element in a sorted Array using Kotlin

Finding start and end index of an element in a sorted array using Kotlin programming language will be shown here. The array may contain duplicate elements and we will see how to find a start and end index for an element in this array elements. We may design the algorithm for finding start and end index of an element in a sorted array in various ways but we need to consider also for the optimized solution. We can simply iterate through array elements and find the start and end index…

Continue

Spring Boot MVC AutoComplete using jQuery

Introduction Autocomplete allows you to easily create autocomplete and auto-suggest boxes for text input fields. When you start a search on Google, you can find the information you are looking for using search predictions. Search predictions are possible search terms you can use that are related to the terms you are typing and what other people are searching for. Spring Boot MVC autocomplete example will show you exactly the same thing here. Autocomplete is a feature in which an application predicts the rest of a word a user is typing.…

Continue

Binary Search using C

This example shows how Binary Search Algorithm works and I am going to implement it using C programming language. Binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. Binary search algorithm is better when an array is sorted because it makes comparison between the search key “k” and middle element of the array. Since the array is sorted,…

Continue

Sequential Search using C

This example shows how Sequential Search algorithm works. Simple way to search for a key value k in an array a is to compare the values of the elements in a with k. The process starts with the first element of the array and k and comparison continues as long as either the comparison does not result in a success or the list of elements in the array are exhausted. This method of searching is known as sequential search or linear search. The following code example will return the index…

Continue