From 9df39726c12b3a79ec8c5da638c5ff5f5ee0bc9d Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Mon, 6 Jul 2015 06:44:09 -0400 Subject: [PATCH] Fixed Python2 vs Python3 division compatibility. --- sorting_searching/merge_sort/merge_sort_solution.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sorting_searching/merge_sort/merge_sort_solution.ipynb b/sorting_searching/merge_sort/merge_sort_solution.ipynb index 3d721a4..93da0ea 100644 --- a/sorting_searching/merge_sort/merge_sort_solution.ipynb +++ b/sorting_searching/merge_sort/merge_sort_solution.ipynb @@ -33,7 +33,6 @@ "source": [ "## Constraints\n", "\n", - "* Is a naiive solution sufficient?\n", " * Yes" ] @@ -87,6 +86,9 @@ }, "outputs": [], "source": [ + "from __future__ import division\n", + "\n", + "\n", "def merge(left, right):\n", " l = 0\n", " r = 0\n", @@ -111,7 +113,7 @@ "def merge_sort(data):\n", " if len(data) < 2:\n", " return data\n", - " mid = len(data) / 2\n", + " mid = int(len(data) / 2)\n", " left = data[0:mid]\n", " right = data[mid:len(data)]\n", " left = merge_sort(left)\n",