Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3, Problem 3.65HW
The following code transposes the elements of an M × M array, where M is a constant defined by #define.
When compiled with optimization level = 01, GCC generates the following code for the inner loop of the function:
We can see that GCC has converted the array indexing to printer code.
- A. Which register holds a pointer to array element A[i] [j]?
- B. Which register holds a pointer to array element A[j] [i]?
- C. What is the value of M
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The main function, which calculates the row and column averages separately in the two-dimensional array of M × N size given to him, and calculates the row and column averages of which the difference is the smallest, taking into account these averages, and finds the row and column indices where the difference between them is the smallest. Write it in C language. Access to array elements and permissions must be made with pointers to be defined separately. Indexing (matrix (i) (j) array (j) etc.) should not be used. All array operations to be used will be processed with an external pointer, not indexing. Solutions that access the elements of arrays by indexing without using pointers will not be accepted. The number of rows and columns of the given two-dimensional array (matrix) will be different.
Write a function checkConditions that takes a two-dimensional array of integers, array, and a set of integers, conditions, as input. The function should return 0 if all elements in the array are contained in the conditions set. If any element in the array is not in the conditions set, the function should return -1.
Function signature: int checkConditions(int array[][], int rowSize, int colSize, std::set<int> conditions)
Write the implementation of the function checkConditions without using any built-in functions for searching elements in sets. You should implement your own algorithm for searching elements in the conditions set.
Example: int arr[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; std::set<int> conditions = {1,2,3,6,7,8}; int result = checkConditions(arr, 3, 4, conditions); //result will be 0 since all elements in the array are in the conditions set.
Utilizing c++, write a code to implement the following:Firstly, create(populate) an array (one with unknown size) and determine its(array's) size. Furthermore, the array should then be sorted and its output(prints out) should print each element in the array in order from the last to the 1st index.
Chapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 3.4 - Prob. 3.1PPCh. 3.4 - Prob. 3.2PPCh. 3.4 - Prob. 3.3PPCh. 3.4 - Prob. 3.4PPCh. 3.4 - Prob. 3.5PPCh. 3.5 - Prob. 3.6PPCh. 3.5 - Prob. 3.7PPCh. 3.5 - Prob. 3.8PPCh. 3.5 - Prob. 3.9PPCh. 3.5 - Prob. 3.10PP
Ch. 3.5 - Prob. 3.11PPCh. 3.5 - Prob. 3.12PPCh. 3.6 - Prob. 3.13PPCh. 3.6 - Prob. 3.14PPCh. 3.6 - Prob. 3.15PPCh. 3.6 - Prob. 3.16PPCh. 3.6 - Practice Problem 3.17 (solution page 331) An...Ch. 3.6 - Practice Problem 3.18 (solution page 332) Starting...Ch. 3.6 - Prob. 3.19PPCh. 3.6 - Prob. 3.20PPCh. 3.6 - Prob. 3.21PPCh. 3.6 - Prob. 3.22PPCh. 3.6 - Prob. 3.23PPCh. 3.6 - Practice Problem 3.24 (solution page 335) For C...Ch. 3.6 - Prob. 3.25PPCh. 3.6 - Prob. 3.26PPCh. 3.6 - Practice Problem 3.27 (solution page 336) Write...Ch. 3.6 - Prob. 3.28PPCh. 3.6 - Prob. 3.29PPCh. 3.6 - Practice Problem 3.30 (solution page 338) In the C...Ch. 3.6 - Prob. 3.31PPCh. 3.7 - Prob. 3.32PPCh. 3.7 - Prob. 3.33PPCh. 3.7 - Prob. 3.34PPCh. 3.7 - Prob. 3.35PPCh. 3.8 - Prob. 3.36PPCh. 3.8 - Prob. 3.37PPCh. 3.8 - Prob. 3.38PPCh. 3.8 - Prob. 3.39PPCh. 3.8 - Prob. 3.40PPCh. 3.9 - Prob. 3.41PPCh. 3.9 - Prob. 3.42PPCh. 3.9 - Practice Problem 3.43 (solution page 344) Suppose...Ch. 3.9 - Prob. 3.44PPCh. 3.9 - Prob. 3.45PPCh. 3.10 - Prob. 3.46PPCh. 3.10 - Prob. 3.47PPCh. 3.10 - Prob. 3.48PPCh. 3.10 - Prob. 3.49PPCh. 3.11 - Practice Problem 3.50 (solution page 347) For the...Ch. 3.11 - Prob. 3.51PPCh. 3.11 - Prob. 3.52PPCh. 3.11 - Practice Problem 3.52 (solution page 348) For the...Ch. 3.11 - Practice Problem 3.54 (solution page 349) Function...Ch. 3.11 - Prob. 3.55PPCh. 3.11 - Prob. 3.56PPCh. 3.11 - Practice Problem 3.57 (solution page 350) Function...Ch. 3 - For a function with prototype long decoda2(long x,...Ch. 3 - The following code computes the 128-bit product of...Ch. 3 - Prob. 3.60HWCh. 3 - In Section 3.6.6, we examined the following code...Ch. 3 - The code that follows shows an example of...Ch. 3 - This problem will give you a chance to reverb...Ch. 3 - Consider the following source code, where R, S,...Ch. 3 - The following code transposes the elements of an M...Ch. 3 - Prob. 3.66HWCh. 3 - For this exercise, we will examine the code...Ch. 3 - Prob. 3.68HWCh. 3 - Prob. 3.69HWCh. 3 - Consider the following union declaration: This...Ch. 3 - Prob. 3.71HWCh. 3 - Prob. 3.72HWCh. 3 - Prob. 3.73HWCh. 3 - Prob. 3.74HWCh. 3 - Prob. 3.75HW
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A(n) ______ is a variable that counts the number of times a loop repeats.
Starting Out with C++: Early Objects
Explain the problems that denormalized tables may have for insert, update, and delete actions.
Database Concepts (8th Edition)
Design a function to compare the contents of two stacks.
Computer Science: An Overview (12th Edition)
Suppose you write a program that is supposed to compute the interest on a bank account at a bank that computes ...
Problem Solving with C++ (9th Edition)
Present Value Suppose you want to deposit a certain amount of money into a savings account, and then leave it a...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Describe two properties that each candidate key must satisfy.
Modern Database Management
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
- In C++ Create an array of head pointers, statically allocated of size 101 of that type: Now, create a pointer that can point to the first element: Show how to dynamically allocate an array of 101 elements of head pointers: Write the code to initialize each element to NULL: Rewrite the code to initialize each element to NULL using pointer arithmetic:arrow_forwardCreate two dynamic arrays A and B with random numbers.a) Merge B in array A calling a function by reference.b) Delete the composite numbers from the merged array A calling a function bypointer. You have to use only two Arrays A and B throughout the code. Be carefulabout memory leakage.arrow_forwardIn c++ , perform insertion into the dynamic array at the start, end, and middle as well and perform array resizing as well. ( Drop code in words , explain the code and drop the screenshot of output as well )arrow_forward
- using c++ Define an array of n integer marks and fill it with random numbers, send it to a function that returns an array of failed marks. Hint: use pointer notations onlyarrow_forwardA function that modifies an array by using pointer arithmetic such as ++ptr to process every value should have a parameter that is Select one: a. A nonconstant pointer to constant data b. A constant pointer to constant data c. A constant pointer to nonconstant data d. A nonconstant pointer to nonconstant data c++arrow_forwardLanguage: C Reverse the elements of an array using pointers. To this end define the function void reverseArray (int* array , int arraySize). Inside the function, declare two int * pointers, one initially pointing to the first element in the array, the second one pointing to the last element in the array. Swap the values in the array indicated by each of these pointers. Increment the first pointer and decrement the second pointer. Repeat the process you reach the middle of the array. Print your original, and the reversed array. Problem 2.arrow_forward
- Passing multidimensional arrays to a functionMultidimensional arrays follow the same rules as single-dimensional arrays when passing them to a function.However the combination of decay-to-pointer, operator precedence, and the two different ways to declare amultidimensional array (array of arrays vs array of pointers) may make the declaration of such functions nonintuitive. Write code example shows the correct ways to pass multidimensional arrays.arrow_forwardThe Tribonacci sequence is a sequence of numbers where each term from the fourth term on is a sum of the previous three terms. Different versions of the sequence can be computed by changing the first three terms (known as the seed terms). Compose a function that uses dynamic programming to return the nth value of the Tribonacci sequence with seed values x, y and z. Seed values should be provided as input parameters. All array indexing must be done using pointer arithmetic. Example (where seed values are x=0, y=1, z=1): n = 0 4 8. 9. 10 2 4 13 24 44 81 149arrow_forwardThere is a close association between pointers and arrays. Recall that an array variable is actually a pointer variable that points to the first indexed variable of the array. Array elements can be accessed using pointer notation as well as array notion. One problem with static arrays is that we must specify the size of the array when we write the program. This may cause two different problems: (1) we may create an array much larger than needed; or (2) we may create one that is smaller than what is needed. In general, this problem is created because we do not know the size of the array until the program is run. This is where dynamic arrays can be used. The new expression can be used to allocate an array on the freestore. Since array variables are pointer variables, you can use the new operator to create dynamic variables that are arrays and treat these dynamic array variables as if they were ordinary arrays. Array elements can also be accessed using pointer notation as well as array…arrow_forward
- Please Help me with This Problem Language = C++ An array my_Array[] consisting ‘a’ s, ‘b’ s and ‘c’s. The task is to write a function that arranges the arraysuch that all ‘a’s are placed first, then all ‘b’s and then all ‘c’s in last. (Note : Understand the Problem and Then Answer it)arrow_forwardThere is a close association between pointers and arrays. Recall that an array variable is actually a pointer variable that points to the first indexed variable of the array. Array elements can be accessed using pointer notation as well as array notion. One problem with static arrays is that we must specify the size of the array when we write the program. This may cause two different problems: (1) we may create an array much larger than needed; or (2) we may create one that is smaller than what is needed. In general, this problem is created because we do not know the size of the array until the program is run. This is where dynamic arrays can be used. The new expression can be used to allocate an array on the freestore. Since array variables are pointer variables, you can use the new operator to create dynamic variables that are arrays and treat these dynamic array variables as if they were ordinary arrays. Array elements can also be accessed using pointer notation as well as array…arrow_forwardWRITE PROGRAM IN C LANGUAGE: Write a program which should consists of a user defined function “Task ()” [Function returns no value]. Pass 1D array to the function, along with number of elements of array and element to search. Function should implement linear search, and if the element is not found in the array, then insert that element at the end of array .Display the final array after insertion [After function is called] in the main () function. [Note: Array should be passed using by reference approach]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
Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges; Author: FreecodeCamp.org;https://www.youtube.com/watch?v=oBt53YbR9Kk;License: Standard YouTube License, CC-BY