Assume an array descriptor has the format:
type ArrayDescriptor =
record
VirtualOrigin: integer; Multiplier1, Multiplier2: integer;
LowerBound1, UpperBound1, LowerBound2, UpperBound2: integer
end;
so that when row-major order is used, the storage mapping function for an array a is:
location(a[i,j]) = VirtualOrigin + i*Multiplier1 + j*Multiplier2.
For each of the following 6 cases, assume that the first word of storage allocated is decimal location 4000. Give (a) the number of words of storage required for the array; (b) the array’s descriptor; and (c) the location of M[2,3] in each declared array. Assume that each R requires one word and that each S requires two words.
(1) var M: array [1..3, 1..3] of R
(2) var M: array [0..3, 0..4] of R
(3) var M: array [-1..2, 2..4] of R
(4) var M: array [1..3, 1..3] of S
(5) var M: array [0..3, 0..4] of S
(6) var M: array [-1..2, 2..4] of S


Assume an array descriptor has the format: type ArrayDescriptor = record &nbs
1. Which of the following code snippets will load an array named fives(), consisting of 10 elements with the starting value of the first element = 0 and will load each subsequent element counting by 5's, ending with the last element = 45. In other words, the elements in the fives() array should be (0, 5, 10, 15, ... 45). A. var fives = new Array(); for(j = 1; j < 11; j++) fives[j] = j + 5; B. var...
Consider the following matrix transpose routines: typedef int array[4][4]; void transpose (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[i][j] = src[i][j]; } } } void transpose2 (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[j][i] = src[j][i]; } } } Assume this code runs on...
using matlab
In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...
Refer to the following program sample to answer the parts (a-i) below. Keep in mind that low and high are both indices of array A. /1 Assume that A is a sorted array containing N integers // Assume that x is a variable of type int int low= 0; // Line 1 int high- N; // Line 2 while (low- high) I/ Line 3 m- (lowthigh)/2; // Line 4 (This is integer division) if (A [m]<) I/Line 5 then low-...
Maximum Value But Limited Neighbors You are given an array a[1..n] of positive numbers and an integer k. You have to produce an array b[1..n], such that: (i) For each j, b[j] is 0 or 1, (ii) Array b has adjacent 1s at most k times, and (iii) sum_{j=1 to n} a[j]*b[j] is maximized. For example, given an array [100, 300, 400, 50] and integer k = 1, the array b can be: [0 1 1 0], which maximizes the...
Write a C program with a filename netID_intarray.c that has 2 arrays. One is a two-dimensional array of strings which contains 5 words, each word can be a max of 20 characters long. The list of strings should be static in your code. The second integer array is populated by prompting the user for 10 integers to be stored in the array. Here is the simple output: $ ./run Number Work Enter integer 1 for the array: 45 Enter integer...
Java Array The method rotateLeft() takes in a reference a to an integer array and a positive integer n and it returns a new array whose contents is the contents of the input array rotated to the left n places. So each element a[i] of the input array should be placed at location b[i-n] of the returned array. If the index i-n is negative, then that index should "wrap" around to the end of the output array. For example, if...
having trouble with the following swift 5 problem. It is just printing the number 4 twice and it seems to be ignoring camelCasePhraseTwo, please help if you can: /* Problem 4 Write a function that takes in a camel-case string and returns an integer representing the number of words in the string Notes: - Assume all input will contain only letters, and the string will be a valid camel-cased phrase - Do not loop through the array manually. */ func...
I have questions declare of array several form. Question . Write array declarations for the following data: i) x = An array of 15 double type numbers ii) ? = [ 1 0 0 2 0 0 3 0 0] iii) word = 10 words of at most 9 characters each iv) Z = A 5 × 10 matrix of all zeroes THX! language is C
Hi, I have programming problem related to array, sorting, and.
swap operation
Thank you,
Best Regards..
A non-empty array A consisting of N integers is given. You can perform a single swap operation in array A. This operation takes two indices I and J, such that 0 S13 J<N, and exchanges the values of A[i] and A[J]. The goal is to check whether array A can be sorted into non-decreasing order by performing at most one swap operation. For example,...