diff --git a/_notebooks/2024-04-22-Searching.ipynb b/_notebooks/2024-04-22-Searching.ipynb index f5cc93c..62bdd20 100644 --- a/_notebooks/2024-04-22-Searching.ipynb +++ b/_notebooks/2024-04-22-Searching.ipynb @@ -126,11 +126,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [], "source": [ "import java.util.ArrayList;\n", @@ -195,11 +191,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -217,11 +209,7 @@ { "cell_type": "code", "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -247,11 +235,7 @@ { "cell_type": "code", "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -367,11 +351,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -447,11 +427,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -506,11 +482,7 @@ { "cell_type": "code", "execution_count": 19, - "metadata": { - "vscode": { - "languageId": "java" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -676,8 +648,16 @@ "metadata": {}, "source": [ "1. Is sequential/linear or binary more efficient? Why?\n", + "\n", + "It depends on what index you trying to find but in general, the binary search tends to be much more efficient for most cases because of the fact that it can eliminate multiple values fast, reducing the number of iterations that happen\n", + "\n", "2. Why might you not always be able to use binary search?\n", - "3. Which of the following implements a method named contains for searching an array sequentially, confirming whether or not the array contains a requested element?\n" + "\n", + "When there is a value that your looking for that is very early on in the Array List, you might not want to use the binary search since it might take more iterations than you might want it to and linear might taken less iterations \n", + "\n", + "3. Which of the following implements a method named contains for searching an array sequentially, confirming whether or not the array contains a requested element?\n", + "\n", + "2" ] }, { @@ -733,7 +713,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Answer:" + "### Answer:\n", + "\n", + "Indubitably is printed 16 times:\n", + "i = 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19" ] } ], @@ -747,7 +730,7 @@ "codemirror_mode": "java", "file_extension": ".jshell", "mimetype": "text/x-java-source", - "name": "Java", + "name": "java", "pygments_lexer": "java", "version": "17.0.9+9-Ubuntu-120.04" }