Question

Determine the size of an int variable, a double variable, and a pointer on your computer....

Determine the size of an int variable, a double variable, and a pointer on
your computer.
(a) Calculate the break-even point, as a function of n, beyond which the
array-based list is more space efficient than the linked list for lists
whose elements are of type int.
(b) Calculate the break-even point, as a function of n, beyond which the
array-based list is more space efficient than the linked list for lists
whose elements are of type double.

Homework Answers

Answer #1

(a) Consider A to be the size of the array list.

Let P be the size of pointer.

The size of an int element is 4 bytes.

Therefore, the breakeven point as a function of n, beyond which the array-based list is more space efficient than the linked list for lists whose elements are of type int is :

n> (4*D)/(P+4)

(b) Consider A to be the size of the array list.

Let P be the size of pointer.

The size of an int element is 8 bytes.

Therefore, the breakeven point as a function of n, beyond which the array-based list is more space efficient than the linked list for lists whose elements are of type double is :

n> (8*D)/(P+8)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first...
C++ questions QUESTION 1 What kind of linked list begins with a pointer to the first node, and each node contains a pointer to the next node, and the pointer in the last node points back to the first node? A. Circular, singly-linked list. B. Circular, doubly-linked list. C. Singly-linked list. D. Doubly-linked list. E. None of the above.    QUESTION 2 _________ is not an advantage of linked lists when compared to arrays. A. Dynamic memory allocation. B. Efficient...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i];...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i]; } return (double)sum/n; } Rewrite the function to eliminate the array subscripting (a[i]), using pointer arithmatic instead. Write a program that reads a line of input and checks if it is a palindrome (ignoring spaces) Write a program that takes the name of a file as a command line argument, and prints the contents of the file (similar to the linux 'cat' program). Write...
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N...
1) Develop a C++ function that determines the average value of an array of type double...
1) Develop a C++ function that determines the average value of an array of type double elements double GetAverage(double array[], int size) The function should accept as input an array of double values The function should accept as input the number of elements in the array of double values The function should return a double value which is the array's average value 2) Develop a C++ function that determines the variance of an array of type double elements double GetVariance(double...
We are using a raspberry pi in my computer systems class. We need to Write a...
We are using a raspberry pi in my computer systems class. We need to Write a statically allocated linked list in ARM assembly. Steps You Should Follow Step 1 You will statically allocate some space for your link list elements. You need to make 5 elements, each elements should have two components, the next pointer first then the value stored. First inialize next pointer to NULL. The value stored at the address will be a string pointer. It doesn't matter...
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an...
explain the relationship between a deep copy and its pointer. explain the relationship between a shallow...
explain the relationship between a deep copy and its pointer. explain the relationship between a shallow copy and its pointer. how many bytes are incremented if a pointer such as *p is incremented using pointer arithmetic such as (depending upon which primitive type it point to; int, double, char etc). write a copy constructor to copy a class object containing a dynamic array. use a member by member copy techniques shown in the textbook. using correct c++ syntax, write the...
In C language make a structure called funds funds should have variable fields of type int...
In C language make a structure called funds funds should have variable fields of type int id; char bank[10]; float balance; The program would have a function called sum which returns a float. To sum pass structure funds and a pointer called record. initialize record to equal {1, "BOA", 10023.43} call sum passing the pointer record , the function returns a float value into variable result. initialize record to equal {2, "Chase", 4239.87} call sum passing the pointer record ,...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
SanFrancisco Inc. manufactures computer supplies. San Francisco Inc. has variable expenses of $1.50 (for software) and...
SanFrancisco Inc. manufactures computer supplies. San Francisco Inc. has variable expenses of $1.50 (for software) and $2.00 (for hardware) per unit. Assume that total fixed expenses are 15,000. The devices are sold for $9 each. In the space below, first draw a blank “Break Even Chart/Graph” and then draw the fixed cost line. Draw the “Total Cost Line” and the “Total Revenue” line on the chart (HINT: Make sure these lines intersect) Now using the information provided above, calculate the...