Computer Systems: A Programmer's Perspective (3rd Edition)
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
Question
Book Icon
Chapter 5.11, Problem 5.9PP
Program Plan Intro

Given C code:

void merge(long src1[], long src2[], long dest[], long n)

{

long i1 = 0;

long i2 = 0;

long id = 0;

while(i1<n && i2<n)

{

if(src1[i1]<src2[i2])

dest[id++] = src1[i1++];

else

dest[id++] = src2[i2++];

}

while(i1<n)

dest[id++] = src1[i1++];

while(i2<n)

dest[id++] = src2[i2++];

}

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.

Memory aliasing:

  • It denotes a case where two pointers might designate to memory location that is same.
  • The compiler should assume that unlike pointers might be aliased for safe optimizations.
  • The program aspects that could limit chances for a compiler in generating optimized code denote optimization blockers.
  • If a compiler is unable to determine whether two pointers might be aliased, it should adopt that either case would be possible.
  • The possible optimization set is been limited in this case.

Blurred answer
Students have asked these similar questions
Using functional C++ programming, not OOP Given set A = {23, 56, -7, 6, 0, 75, 2.7, -3.6, 8, -4.77, 43, 678} and set B = {5, 8, 46, -98, 46} a. Using merge sort approach, sort the numbers in set A and B jointly. b. Using RAM diagrams, show the values of parameters that are passed between the partition() function and sort() function.
Consider the following list of elements (M-2) 18, 40, 16, 82, 64, 67, 57, 50, 37, 47, 72,14, 17, 27, 35Using quicksort algorithm, Use pivot as the median of the first, last, and middle elements of the list.a. What is the pivot?b. Give the resulting list after one call to the partition procedure. (Data structure and algorithm in c++)
Q2: Besides the while-loop in Q1, I want to implement a 2nd while-loop running in parallel with the first while: while(1) { wt(1); XX); } However, on an MCU there is no parallelism. (For ex., on Arduino I can define only one loop() function.) Write a single while that does the job of both whiles. (a) Write it in a procedural style. (b) Write it the super-loop style (state-machine with fixed heartbeat).
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education