COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
3rd Edition
ISBN: 9780134671123
Author: Bryant
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 5.12, Problem 5.10PP
A.
Program Plan Intro
Given C Code:
void copy_array(long *src, long *dest, long n)
{
long i;
for(i=0; i<n; i++)
dest[i] = src[i];
}
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.
B.
Program Plan Intro
Given C Code:
void copy_array(long *src, long *dest, long n)
{
long i;
for(i=0; i<n; i++)
dest[i] = src[i];
}
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.
C.
Program Plan Intro
Given C Code:
void copy_array(long *src, long *dest, long n)
{
long i;
for(i=0; i<n; i++)
dest[i] = src[i];
}
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.
D.
Program Plan Intro
Given C Code:
void copy_array(long *src, long *dest, long n)
{
long i;
for(i=0; i<n; i++)
dest[i] = src[i];
}
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
computer science question
(C++) I need a quicksort algorithm implementation which returns the indices of the sorted array in an array without modifying the array itself:ie,Before sortingindex : 0 1 2 3 4 5values: 70 60 40 20 30 50After sortingindex : 3 4 2 5 1 0values: 70 60 40 20 30 50
function returns an array with indexes: [3 4 2 5 1 0]
M. 0om question 6.
Chapter 5 Solutions
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
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
- 1) Consider an integer array a of length n with indexing starting at 0, where n is a positive integer.If the elements of array a are to be written out in reverse order, which of the following C++ code fragment does NOT do the job? Question options: a. int i=n-1; while (i>=1){cout << a[i] << endl; i = i-1;} cout << a[i] << endl; b. int i=n-1; while (i>=1){cout << a[i] << endl; i = i-1;} c. int i=n-1; while (i>=0){cout << a[i] << endl; i = i-1;} d. int i=n; while (i>0){cout << a[i-1] << endl; i = i-1;} 2) Assume we use 8-bit cell to store floating point numbers, 1 bit for sign, 3 bits for excessed exponent, and 4 bits for significand. What is the decimal value for a cell with bit pattern 0 111 1101 Question options: a. 125 b. 224…arrow_forwardsolve 7 ,8 and 9 please and fast in c++arrow_forwardFor each of the following problems, all functions should be implemented using a call stack. Problem 2: Write a program that defines two integer array that are pre-sorted and the same size (e.g., [3, 7, 9, 11, 15, 21] and [1, 4, 6, 14, 18, 19]) and a function merge that takes the two arrays (and their size) as inputs and populates a single array of twice the size of either input array that contains the elements of both arrays in ascending order. In the example arrays given, then output would be [1, 3, 4, 6, 7, 9, 11, 14, 15, 18, 19, 21]. Have your 'main' function (not the merge function) print out the final array using a comma as a delimiter.arrow_forward
- c++ problemarrow_forward(Exhaustive Search: The Assignment Problem) Complete the application of exhaustive search to The following assignment: [9 2 7 8] 64 37 5818 769 4 C = 1, 2, 3, 4 1, 2, 4, 3 1, 3, 2, 4 1, 3, 4, 2 1, 4, 2, 3 1, 4, 3, 2 Complete the remaining cases: Answer: cost = 9+4+1+4 = 18 cost = 9+4+8+9 = 30 cost = 9+3+8+4 = 24 cost = 9+3+8+6 = 26 cost = 9+7+8+9 = 33 cost = 9+7+1+6 = 23arrow_forwardOCAML programming (Lights Out) The mechanics described in this exercise can be used to implement a game lights out. 1. Create a function flip val flip : bool array array -> int -> int -> bool array array = <fun> that given a bool matrix and two integers i; j. it negates the values(true!false, false!true) at location i; j in the matrix, as well negatingthe values on the (up to) 4 horizontally/vertically adjacent elements. 2. Create a function print matrix val print_matrix : bool array array -> unit = <fun> that given a bool matrix, it prints it on screen (true !"T", false!"F"). Sample input: # let matrix= [|[|false; true; true; false|]; [|true; false; false; true|];[|false; false; true; true|]|];;# print_matrix matrix;;FTTFTFFTFFTT# flip matrix 1 4;;# print_matrix matrix;;FTFTTFFFFFTTarrow_forward
- Language: JavaScript (Node.js) • Autocomplete Ready O 1 > 'use strict';... 5. Use array.map to double each 26 number 27 / * 28 * Complete the 'double' function below. 29 Use array.map to complete the double function. The function is expected to double each number in an array. 30 * The function is expected to return an INTEGEF 31 * The function accepts INTEGER_ARRAY arr as par 32 * / 33 34 function double(arr) { 35 36 37 38 > function main() {….. Test Results Custom Innut :::::::arrow_forwardMany engineering applications require "nomalizing" an n-element vector F. Each element wy of the normalized vector W is defined as follows: Wi yn-1 Li=0 Write the C++ code with the following specifications to solve for the calculation of Based on the given formula w, write a class called Vector that contains o an array as class members for vector V (n can be up to ten elements) and other necessary data member(s) o necessary member functions to get input from user, normalize the data member(s) and output the result of w. Display the results to the screen as well as data file named 'normalize.txt. o constructor to initialize vectors to 1. Write a main function that tests your class and constructor. Following is the example of the output at screen and the data file. Screen: Data file: from constructor: The normalized vector: (e] - 0.316228 normalize - Notepad File Edit Format View Help The vectors are: 5 3 2 6 The normalized vector: 0.316228 0.316228 0.316228 0.316228 0.316228 0.316228…arrow_forwardIn c++ using the given codearrow_forward
- Q.1. Implement insertion sort using C++ STL with following constrain and write a program : The insertion sort procedure uses searching procedure to find the position of the unsorted array elements in sorted array. This searching procedure can start from the beginning index of the sorted array or ending index of the sorted array. Here your program should consider the searching procedure that should starts from beginning index of the sorted array. Q.2. Implement insertion sort using C++ STL with following constrain and write a program : To find the position of the unsorted-array elements in insertion sort, it is depending on searching procedure. In this procedure it stops at a position after identifying the first occurred element (in sorted-array) which is greater than the element (in unsorted-array). Here the programmer should apply intelligence in such a way that, the position of an element can be identified after finding the closet element in sorted-array. Example: Let the elements…arrow_forwardPlease written by computer source Question 1: Suppose we wish to write a procedure that computes the inner product of two vectors u and v. An abstract version of the function has a CPE of 14–18 with x86- 64 for different types of integer and floating-point data. By doing the same sort of transformations we did to transform the abstract program combine1 into the more efficient combine4, we get the following code: Our measurements show that this function has CPEs of 1.50 for integer data and 3.00 for floating-point data. For data type double, the x86-64 assembly code for the inner loop is as follows: Assume that the functional units have the characteristics listed in Figure 5.12. **See last page for figures A. Diagram how this instruction sequence would be decoded into operations and show how the data dependencies between them would create a critical path of operations, in the style of textbook Figures 5.13 and 5.14. vmovsd vmovsd vmulsd vaddsd | | | |…arrow_forwardneed help with c++...paste indented code plzzarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr