Skip to content

Commit

Permalink
fwjkfbel
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyustin committed Feb 24, 2024
1 parent 7c6636b commit 4581427
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: Nighthawk-Pages
description: "August 2023 to June 2024"
owner_name: Justin Nguyen
github_username: Justin Nguyen
github_username: Jyustin
github_repo: "JN-CSAblog"
baseurl: "/JN-CSAblog"
remote_theme: jekyll/minima
Expand Down
126 changes: 126 additions & 0 deletions _notebooks/2023-02-22-FRQFINAL1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"toc: true\n",
"comments: true\n",
"layout: notebook\n",
"title: APCSA FRQ QUESTION 1\n",
"description: java skill check\n",
"courses: { compsci: {row: 0} }\n",
"type: APCSA\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# QUESTION 1\n",
"\n",
"You will write three static methods, all of which are in a single enclosing class, named DiverseArray (not shown). The first method returns the sum of the values of a one-dimensional array; the second method returns an array that represents the sums of the rows of a two-dimensional array; and the third method analyzes row sums.\n",
"\n",
"\n",
"(a) Write a static method arraySum that calculates and returns the sum of the entries in a specified one-dimensional array. The following example shows an array arr1 and the value returned by a call to arraySum.\n",
"\n",
"### my ans to A:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"// Returns the sum of the entries in the one-dimensional array arr.\n",
"\n",
"public static int arraySum (int [ ] arr) {\n",
" int sum = 0;\n",
" for (int i = 0; i < arr.length; i++) {\n",
" sum += arr[i];\n",
" }\n",
" return sum;\n",
"}\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(b) Write a static method rowSums that calculates the sums of each of the rows in a given two-dimensional array and returns these sums in a one-dimensional array. The method has one parameter, a two-dimensional array arr2D of int values. The array is in row-major order: arr2D [ r ] [ c ] is the entry at row r and column c. The method returns a one-dimensional array with one entry for each row of arr2D such that each entry is the sum of the corresponding row in arr2D. As a reminder, each row of a two-dimensional array is a one-dimensional array.\n",
"\n",
"### my ans to B:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"// Returns a one-dimensional array in which the entry at index k is the sum of\n",
"// the entries of row k of the two-dimensional array arr2D.\n",
"\n",
"public static int [] rowSums(int [a] [b] arr2D) {\n",
" int [] arrSum = new int [];\n",
" for (int j = 0; j < arr2D[].length; j++) {\n",
" arr2d[i] = arr2D[i][k];\n",
" } \n",
"}\n",
"return rowSums;\n",
" \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(c) A two-dimensional array is diverse if no two of its rows have entries that sum to the same value. In the following examples, the array mat1 is diverse because each row sum is different, but the array mat2 is not diverse because the first and last rows have the same sum.\n",
"\n",
"Write a static method isDiverse that determines whether or not a given two-dimensional array is diverse. The method has one parameter: a two-dimensional array arr2D of int values. The method should return true if all the row sums in the given array are unique; otherwise, it should return false. In the arrays shown above, the call isDiverse (mat1) returns true and the call isDiverse(mat2) returns false.\n",
"\n",
"Assume that arraySum and rowSums work as specified, regardless of what you wrote in parts (a) and(b). You must use rowSums appropriately to receive full credit.\n",
"Complete method isDiverse below.\n",
"\n",
"### my ans to C:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"// Returns true if all rows in arr2D have different row sums;\n",
"//false otherwise.\n",
"\n",
"public static boolean isDiverse(int [ ] [ ] arr2D) {\n",
" int \n",
" for (int i = 0; i < arr2D.length; i++) {\n",
" for (int j = 0; j < arr2D[i].length; j++) {\n",
" int [] newRow = rowSums[i][j];\n",
" }\n",
" if newRow == newRow {\n",
" return false;\n",
" }\n",
"}\n",
"}"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Java",
"language": "java",
"name": "java"
},
"language_info": {
"name": "java"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion _posts/2024-2-16-NATM2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Night at the Museum tri 2 review
description: this is also a waste of storage
courses: { compsci: {row: 4} }
type: projecthelp
---
---

[issue if utterances doesn't work](https://github.com/Jyustin/JN-CSAblog/issues/4)
# Two Trimester focus planning
Expand Down

0 comments on commit 4581427

Please sign in to comment.