Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 8.3, Problem 8.3.1CP
Show the output of the following code:
int[][] array = {{1, 2}, {3, 4}, {5, 6}} ;
for (int i = array. Length - 1 ; i >= 0 ; i--) {
for (int j = array[i].length - 1 ; j >= 0 ; j--)
System.out.print(array[i] [j] + " " );
System.out.println();
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include
#include
main () {
int array [3] [2] [2], value=0, i, j, k;
int *p= (int *) array;
}
for (i = 0; i < 3; i++) {
for(j=
}
=
0; j < 2; j++) {
for (k = 0; k < 2; k++) {
array[i][j] [k] = value;
value = value + 1;
}
}
for (i = 0; i < 12; i++)
printf("%d ", p[i]);
printf("\n");
printf ("Examine memory now.\n");
In C++ whats the answer from below ?
int size = 10;
for ( int i = -1; i < size ; i++) { arr[size - i] = i; }
This array:
has 12 positions
is out of bounds
has 10 positions
has 11 positions
public int[] selectionSort(int[] array) {for (int i = 0; i < array.length - 1; i++) {int min = array[i];int minIndex = i;for (int j = i + 1; j < array.length; j++) {if (min > array[j]) {min = array[j];minIndex = j;}}if (minIndex == i) {array[minIndex] = array[i];array[i] = min;}}return array;}
Chapter 8 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 8.2 - Declare an array reference variable for a...Ch. 8.2 - Prob. 8.2.2CPCh. 8.2 - What is the output of the following code? int[] []...Ch. 8.2 - Which of the following statements are valid? int...Ch. 8.3 - Show the output of the following code: int[][]...Ch. 8.3 - Show the output of the following code: int[][]...Ch. 8.4 - Show the output of the following code: public...Ch. 8.5 - Prob. 8.5.1CPCh. 8.6 - What happens if the input has only one point?Ch. 8.7 - What happens if the code in line 51 in Listing 8.4...
Ch. 8.8 - Declare an array variable for a three-dimensional...Ch. 8.8 - Assume char[][][] x =new char[12][5][2], how many...Ch. 8.8 - Show the output of the following code: int[][][]...Ch. 8 - (Sum elements column by column) Write a method...Ch. 8 - (Sum the major diagonal in a matrix) Write a...Ch. 8 - (Sort students on grades) Rewrite Listing 8.2,...Ch. 8 - (Compute the weekly hours for each employee)...Ch. 8 - (Algebra: add two matrices) Write a method to add...Ch. 8 - (Algebra: multiply two matrices) Write a method to...Ch. 8 - (Points nearest to each other) Listing 8.3 gives a...Ch. 8 - (All closest pairs of points) Revise Listing 8.3,...Ch. 8 - Prob. 8.9PECh. 8 - (Largest row and column) Write a program that...Ch. 8 - (Game: nine heads and tails) Nine coins are placed...Ch. 8 - (Financial application: compute tax) Rewrite...Ch. 8 - (Locate the largest element) Write the following...Ch. 8 - (Explore matrix) Write a program that prompts the...Ch. 8 - (Geometry: same line ?) Programming Exercise 6.39...Ch. 8 - (Sort two-dimensional array) Write a method to...Ch. 8 - (Financial tsunami) Banks lend money to each...Ch. 8 - (Shuffle rows) Write a method that shuffles the...Ch. 8 - (Pattern recognition: four consecutive equal...Ch. 8 - Prob. 8.20PECh. 8 - (Central city) Given a set of cities, the central...Ch. 8 - (Even number of 1s) Write a program that generates...Ch. 8 - (Game: find the flipped cell) Suppose you are...Ch. 8 - (Check Sudoku solution) Listing 8.4 checks whether...Ch. 8 - Prob. 8.25PECh. 8 - (Row sorting) Implement the following method to...Ch. 8 - (Column sorting) Implement the following method to...Ch. 8 - (Strictly identical arrays) The two-dimensional...Ch. 8 - (Identical arrays) The two-dimensional arrays m1...Ch. 8 - (Algebra: solve linear equations) Write a method...Ch. 8 - (Geometry: intersecting point) Write a method that...Ch. 8 - (Geometry: area of a triangle) Write a method that...Ch. 8 - (Geometry: polygon subareas) A convex four-vertex...Ch. 8 - (Geometry: rightmost lowest point) In...Ch. 8 - (Largest block) Given a square matrix with the...Ch. 8 - (Latin square) A Latin square is an n-by-n array...Ch. 8 - (Guess the capitals) Write a program that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the total serial transfer time for the eight bits in Figure 1-62? What is the total parallel transfer t...
Digital Fundamentals (11th Edition)
Explain how entities are transformed into tables.
Database Concepts (8th Edition)
What happens if you write a class with no constructor whatsoever?
Starting out with Visual C# (4th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
Write a program that reads three whole numbers and displays the average of the three numbers.
Java: An Introduction to Problem Solving and Programming (7th Edition)
How many cells can be in a computers main memory if each cells address can be represented by two hexadecimal di...
Computer Science: An Overview (12th Edition)
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
- public int[] selectionSort(int[] array) {for (int i = 0; i < array.length - 1; i++) {int min = array[i];int minIndex = i;for (int j = i + 1; j < array.length; j++) {if (min > array[j]) {min = array[j];minIndex = j;}}if (minIndex == i) {array[minIndex] = array[i];array[i] = min;}}return array;}arrow_forwardHow do you initialize an array in C? a. int arr[3] = (1,2,3); b. int arr(3) = {1,2,3}; C. int arr(3) = [1,2,3]; Od. int arr[3] = {1,2,3};arrow_forwardAn array int[] intArray can be initialized during its definition by A.) It can't be initialized B.) by writing int[] intArray = {1.0f}; C.) by writing int[] intArray = {0,1,2}; D.) by writing int[0-10] intArray = {0,1,2,3,4,5,6,7,8,9};arrow_forward
- Print the elements of the array ‘a’ using the mentioned notations: int a[]={1,2,3,4,5}; int *p; p = a; for (int i = 0; i< 5; i++) { //Subscript notation with name of array //Subscript notation with pointer 'p' //Offset notation using array name //Offset notation using pointer 'p' }arrow_forwardpublic int[] bubbleSort(int[] array) {int n = array.length;int temp = 0;}arrow_forwardConsider the following code: int a[5] = {1,3,5,7,9};int b = a[3]; // <--- here Rewrite the last statement (marked “here”) without using array brackets [ ]. Group of answer choices int b = a + 3; int b = *(a + 3); int b = *a + 3; int b = *(a + 2);arrow_forward
- int X[10]={2,0,6,11,4,5,9,11,-2,-1); From the code above, what is the value of X[8] ?arrow_forwardFor an array declartion of int number [25];, what will be the ending index? 0 1 24 25arrow_forward#include for(int i = 0; i { int main() for(int j = 0; j< 2; j++) { { int matrix[2][2] = { printf(" %d", matrix[i][j]); } {2,3,}, //rowo printf("\n"); } {5,7}//row1 getch(); }; } printf("\n Resultant \n"); Try to execute, screenshot the resul and try to explain the sequence of the program. Post it in space-ners provided. FRAMEWORK HTPE ADACHE e OrcE outATION roR TECHO A LEarrow_forward
- fix the error in this code. #include<stdio.h> int insert(int *); int display(int *); int del(int *); void main() { int a[100]; int ch; while(1) { { printf("-------Menu-------"); printf("\nEnter 1 to insert element in array:\t"); printf("\nEnter 2 to display element in array:\t"); printf("\nEnter 3 to Delete element in array:\t"); printf("\nEnter 4 to Exit:\t"); printf("\n enter the choice \n"); scanf("%d",&ch); switch(ch) { case 1:insert(a); break; case 2:display(a); break; case 3:del(a); break; case 4:exit(0); } } } } int insert(int *a) { int i,n; printf("Enter the no. of elements in array:\t"); scanf("%d",&n); printf("\nEnter %d elements in array:\t",n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } a[i]='\0'; return *a; } int display(int *a) { int j;…arrow_forwardpublic int binarySearch(int[]array, int num) {int low = 0;//low rangeint high = array.length -1; //high range int mid; //mid rangewhile () //while low is less than or equal to high{mid = ; //set middle range to be (low + high) /2if () { //if the array in the middle range = input number//return mid range }elseif () { //if the array in the middle range > input number//set the high value to be the mid value minus 1 }else{//set low value to be mid value plus one } }//return -1 here because that would mean that the number is not found in the loop}arrow_forwardint main() { int inStock[10][4]; int alpha[20]; int beta[20]; int gamma[4] = {11, 13, 15, 17}; int delta[10] = {3, 5, 2, 6, 10, 9, 7, 11,1, 8};. . .} a. Write the definition of the function setZero that initializes any onedimensional array of type int to 0. b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. d. Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma. e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License