
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Consider the following code segment that includes a method called
multiply. The multiply method is a sample method for the multiplication
of an n by m array and an m by p array. Suppose the multiply method is
invoked as shown, what will be the value of the expression
a5[1][1]?
Note that the initializeArray method puts a 0 to every cell of the array
passed to initializeArray. *](https://content.bartleby.com/qna-images/question/fc4eba69-32ba-41f1-b37c-e11be6514d08/5ba5aba5-7f82-4f39-a9a0-d732afc1f6dd/rf6hkrc_thumbnail.png)
Transcribed Image Text:Consider the following code segment that includes a method called
multiply. The multiply method is a sample method for the multiplication
of an n by m array and an m by p array. Suppose the multiply method is
invoked as shown, what will be the value of the expression
a5[1][1]?
Note that the initializeArray method puts a 0 to every cell of the array
passed to initializeArray. *
![int[][] quantities = {{1,2,1},
{2,1,1},
{3,1,2}};
int[][] costs = {{18,5,3},
{20,10,6},
{30,15,9}};
int[][] a5 = new int[quantities. length][costs[0].1ength];
a5 = multiply(quantities,costs);
// more statements here
public static int[][] multiply(int[][] a1, int[][] a2) {
int[][] product = neu int[al.length][a2[0].1ength];
int element = 0;
int r, c;
initializeArray(product);
for (r = 0; r < product.length; r++) {
for (c = 0; c < product[r].1ength; c++) {
for (int x = 0; x < al[r].iength; x++) {
product[r][c] += al[r][x] * a2[x][c];
return product;](https://content.bartleby.com/qna-images/question/fc4eba69-32ba-41f1-b37c-e11be6514d08/5ba5aba5-7f82-4f39-a9a0-d732afc1f6dd/rv0igyr_thumbnail.png)
Transcribed Image Text:int[][] quantities = {{1,2,1},
{2,1,1},
{3,1,2}};
int[][] costs = {{18,5,3},
{20,10,6},
{30,15,9}};
int[][] a5 = new int[quantities. length][costs[0].1ength];
a5 = multiply(quantities,costs);
// more statements here
public static int[][] multiply(int[][] a1, int[][] a2) {
int[][] product = neu int[al.length][a2[0].1ength];
int element = 0;
int r, c;
initializeArray(product);
for (r = 0; r < product.length; r++) {
for (c = 0; c < product[r].1ength; c++) {
for (int x = 0; x < al[r].iength; x++) {
product[r][c] += al[r][x] * a2[x][c];
return product;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Assume you have an array and a linked-list that each contain a list of 10 books. Which of the following is true? Group of answer choices 1. It is faster to access the 5th book in the array than to access the 5th book in the linked-list because arrays allow for directly accessing the appropriate spot in memory, while a linked list requires stepping through the previous 4 elements. 2. Shuffling the order of the Books in the linked-list will be easier than for the array. 3. It is faster to add a new book to the end of the linked list than to the array, because the entire array needs to be copied to a larger space in memory in order to add a new element. 4. All options are true.arrow_forwardjava - netbeansarrow_forwardD3 no. D4. Coding. Thearrow_forward
- Now, write another function that prints the values of any array in reverse order. (The function should not change the original array). As an example, if a [] = {1, 2, 3, 4, 5}; The function would print the values in reverse as: 5, 4, 3, 2, 1arrow_forwardGiven the following, write a line of code that will initialize p to point to the “7” inthe array).unsigned char x[] = {2, 3, 5, 7, 11, 13, 17};unsigned char *p, *q; If pointer q in the previous question points to some element of array x, whatexpression will return the index of the element pointed to? E.g., if q points to the 13in the above array, then your expression should return 5 In C Programming Please!arrow_forward4. Arrays. In order to test the functions in this question, you will need an array. We can create a three- dimensional test array as follows: testArray xijk - máx rij,k i=1 i=1 i=1 (b) Now suppose we want a function testFn2 which returns the d2 x d3 matrix {zj.k} where di Zj,k = Σ i=1arrow_forward
- in Pseudo code Create an array of size 10 and name RandArray populate the RandArray with random integer from 1 to 20. Every element in the RandArray must be changed as follows: If the value of the element is less than the array index, the element must be replaced with the index plus 10. If the value of the element is equal to the index, the element must be doubled. If the value of the element is greater than the index, the element must be replaced by the index squared. Print the original number and the changed number of the RandArray .arrow_forwardJAVA Programming Write a function that returns true if you can partition an array into one element and the rest, such that this element is equal to the product of all other elements excluding itself. Examples canPartition ([2, 8, 4, 1]) → true // 8 = 2 x 4 x 1 canPartition ([-1, -10, 1, -2, 20]) → false canPartition ([-1, -20, 5, -1, -2, 2]) truearrow_forward: You are given an array-like data structure Listy which lacks a sizemethod. It does, however, have an elementAt ( i) method that returns the element at index i in 0( 1) time. If i is beyond the bounds of the data structure, it returns -1. (For this reason, the data structure only supports positive integers.) Given a Listy which contains sorted, positive integers,find the index at which an element x occurs. If x occurs multiple times, you may return any index.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education