This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.knoldus.javafx; | |
import javafx.application.Application; | |
import javafx.event.ActionEvent; | |
import javafx.event.EventHandler; | |
import javafx.geometry.Insets; | |
import javafx.geometry.Pos; | |
import javafx.scene.Group; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BinarySearch | |
{ | |
public static int binarySearchRecursive(int[] list, int first, int last, int key) | |
{ | |
if(first >= last) | |
{ | |
return -1; | |
} | |
int middle = first + (last - first) / 2; | |
if(list[middle] == key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BinarySearch | |
{ | |
public static int binarySearchIterative(int[] list, int first, int last, int key) | |
{ | |
while(first <= last) | |
{ | |
int middle = first + (last - first) / 2; | |
if(list[middle] == key) | |
{ | |
return middle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BinarySearchAlgorithm | |
{ | |
public static int recursiveBinarySearch(int[] list, int low, int high, int key) | |
{ | |
if( low >= high) | |
{ | |
return -1; | |
} | |
int middle = low + (high - low) / 2; | |
if(list[middle] == key) |