Skip to content

Commit

Permalink
searching hacks completed
Browse files Browse the repository at this point in the history
  • Loading branch information
JishnuS420 committed Apr 24, 2024
1 parent 6c64160 commit eba98bd
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions _notebooks/2024-04-22-Searching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [],
"source": [
"import java.util.ArrayList;\n",
Expand Down Expand Up @@ -195,11 +191,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -217,11 +209,7 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -247,11 +235,7 @@
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -367,11 +351,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -447,11 +427,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -506,11 +482,7 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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"
]
}
],
Expand All @@ -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"
}
Expand Down

0 comments on commit eba98bd

Please sign in to comment.