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
Concept explainers
Question
Chapter 5, Problem 5.17HW
Program Plan Intro
Given C Code:
void* basic_memset(void *s, int c, size_t n)
{
size_t cnt = 0;
unsigned char *schar = s;
while (cnt < n)
{
*schar++ = (unsigned char) c;
cnt++;
}
return s;
}
Cycles per element (CPE):
- The CPE denotes performance of program that helps in improving code.
- It helps to understand detailed level loop performance for an iterative program.
- It is appropriate for programs that use a repetitive computation.
- The processor’s activity sequencing is controlled by a clock that provides regular signal of some frequency.
Loop unrolling:
- It denotes a program transformation that would reduce count of iterations for a loop.
- It increases count of elements computed in each iteration.
- It reduces number of operations that is not dependent to program directly.
- It reduces count of operations in critical paths of overall computations.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write only the function definition:
Implement the following function definition:
int CrazyWord(char word [ ]);
//input: a character array with a null character (string)
//sets all of the characters in the word to lowercase letters
//changes any lowercase ‘o’ letters to hashtags ‘#’
//returns the number of hashtags that are now in the word
This is c-language. The main issue I am having is specifiers errors in compiling the output of my matrix. Can you check where I am getting issues at printing my matrix?
#include <stdio.h>#include <math.h>#include <stdlib.h>#define NROWS 5#define NCOLS 5
int main(void){ int i,j, max, min, m, n; float M[NROWS][NCOLS]; char key_hit; //Input the sizes printf("ROW size(1-5) : ");scanf("%d",&m); printf("Column size(1-5): ");scanf("%d",&n); //Size Check while(m>NROWS || n>NCOLS) { printf("Please re-enter the sizes. \n"); printf("Row size(1-5) : ");scanf("%d", &m); printf("Column size(1-5) : ");scanf("%d", &n); } //Input the Matrix Data for(i=0; i<m; i++) for(j=0; j<n; j++) { printf("M[%d][%d] = ", i,j); scanf("%f", &M[i][j]); } //Print the Matrix Data for(i=0; i<m; i++); { for(j=0; j<n; j++)…
Answer the given question with a proper explanation and step-by-step solution.
ANSWER IN C++
Chapter 5 Solutions
Computer Systems: A Programmer's Perspective (3rd 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
- In C++ please and thank you!arrow_forwardWhat is the correct way to assign the pointer p to the address of x?. Single choice. p = %x; p = &x; &p = *x; *p = &x;arrow_forwardWrite a Python function def isSubArray(A,B) which takes two arrays and returns True if the first array is a (contiguous) subarray of the second array, otherwise it returns False. You may solve this problem using recursion or iteration or a mixture of recursion and iteration. For an array to be a subarray of another, it must occur entirely within the other one without other elements in between. For example: [31,7,25] is a subarray of [10,20,26,31,7,25,40,9] [26,31,25,40] is not a subarray of [10,20,26,31,7,25,40,9] A good way of solving this problem is to make use of an auxiliary function that takes two arrays and returns True if the contents of the first array occur at the front of the second array, otherwise it returns False. Then, A is a subarray of B if it occurs at the front of B, or at the front of B[1:], or at the front of B[2:], etc. Note you should not use A == B for arrays.arrow_forward
- Implement the following function, without using any data structure. /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2)arrow_forwardin c++ languagee pleaseeearrow_forwardJava code: write a java code that can perform SQUARE-MATRIX-MULTIPLY-RECURSIVE. A; B(Strassen's Algorithms)/ and ordinary multiplication. The program should ask the user for input file and output file locations, and give output for both methods. It should also check if both outputs match and include error handing for incorrect Matrix Multiplication input.arrow_forward
- Write a function/ program that produces the following: int findDifference(const string a1[], int n1, const string a2[], int n2); Return the position of the first corresponding elements of a1 and a2 that are not equal. n1 is the number of interesting elements in a1, and n2 is the number of interesting elements in a2. If the arrays are equal up to the point where one or both runs out, return the smaller of n1 and n2. Notwithstanding each function's behavior described below, all functions that return an int must return −1 if they are passed any bad arguments (e.g. a negative array size, or a position that would require looking at the contents of an element past the last element we're interested in). Unless otherwise noted, passing 0 to the function as the array size is not itself an error; it merely indicates the function should examine no elements of the array. Here's an example: string cast[5] = { "samwell", "jon", "margaery", "daenerys", "tyrion" }; string roles[4] = { "samwell",…arrow_forwardAnswer this question in C++ Programming: Write a sort() function that takes a two dimensional array of strings and sorts the words within each of the rows of words (sentences) passed to it in ascending order (smallest to largest - alphabetically). Also, write a binary search function that takes the same two dimensional array of strings, a word to search for and two integers for the row and column number where the search word may be found, and searches for the word in all rows of the array. if the word is found within any of the rows, the function must return true and assign the row and column number within the array, where the word was found, to the two integer parameters passed. If the word is not found, the function must return false and leave the row and column parameters unassigned. In main, initialize a 6 x 10 two dimensional array of strings to the following words (see "Introduction to Arrays" for an example of initializing an array of strings). "the", "a", "this", "that",…arrow_forwardpls give mommens by expression and statements , thanks Recall that in C++, there is no check on an array index out of bounds. However, during program execution, and array index out of bounds can cause serious problems. Also, in C++, the array index starts at zero. Design and implement the class myArray that solves the array index out of bounds problem, and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements: myArray<int> list(5); //Line 1 myArray<int> myList(2, 13); //Line 2 myArray<int> yourList(-5, 9); //Line 3 This statement in line one declares list to be an array of five components, the component type is int, and components are: list[0], list[1],…, list[4];…arrow_forward
- Using oops concept Pls solve this question in java languagearrow_forwardWrite a function in C++ which (normally) allocates new space for a double array. It should alter its pointer argument to point to the newly allocated space. The size of the array should be a second argument. If this argument is not a valid array size, allocate a single double instead of an array. An example call might be: double * p; allocate(p, 25); // p now points to an array of 25 doubles -- if successfularrow_forwardCreate a recursive function in a file called ab_equality.py: def ab_equal(n, k, current): Print out all of the strings of a's and b's of length n so that the number of a's and b's are equal. For n = 2, there's ab and ba. For n = 3 there are no strings since they'd have to have 2 a's and 1 b, or 2 b's a 1 a so not equal. For n = 4, there will be 6 of these strings, and for n = 5, zero again. Hint: use k to track the difference between a's and b's. So for instance if your current is aaabb then k should be equal to either 1 or -1 (your choice depending). When you call the function, you should call it from your main or testing function with the length in the n parameter, 0 should be put into the k parameter, and then an empty string will be passed in for current.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning