From c148ce4c1c307c967ab746797504b8bb6f49cb4b Mon Sep 17 00:00:00 2001 From: Jean N'dah Kouagou Date: Wed, 15 Jan 2020 23:08:24 +0000 Subject: [PATCH] update --- My_binary_search_from_scratch.ipynb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/My_binary_search_from_scratch.ipynb b/My_binary_search_from_scratch.ipynb index 4b7baae..5ad1bbf 100644 --- a/My_binary_search_from_scratch.ipynb +++ b/My_binary_search_from_scratch.ipynb @@ -2,22 +2,23 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Length of the current array: 10\n", - "Length of the current array: 4\n", + "Length of the current array: 12\n", + "Length of the current array: 6\n", "Length of the current array: 2\n", "Length of the current array: 1\n", "\n", "-1\n", "\n", - "Length of the current array: 10\n", - "Length of the current array: 4\n", + "Length of the current array: 12\n", + "Length of the current array: 5\n", + "Length of the current array: 2\n", "\n", "8\n" ] @@ -48,7 +49,8 @@ " center=(n-1)//2\n", " return center, even\n", " \n", - "def binary_search(input_array, value):\n", + "def binary_search(input_array_, value):\n", + " input_array=input_array_.copy()\n", " index=-1\n", " Search=True\n", " center=binary_search_helper(input_array)[0]\n", @@ -72,8 +74,8 @@ " Search=False\n", " print()\n", " return index\n", - "test_list = [1,3,9,11,15,19,29,171,527.7,1472]\n", - "test_val1 = 25\n", + "test_list = [1,3,9,11,15,19,29,171,527.7,1472,-9,78]\n", + "test_val1 = 17\n", "test_val2 = 527.7\n", "print(binary_search(test_list, test_val1))\n", "print()\n", @@ -105,9 +107,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.7.4" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }