Question

Define fixed heap-dynamic arrays. (b) Write a code snippet (in your favourite language) that creates a...

Define fixed heap-dynamic arrays. (b) Write a code snippet (in your favourite language) that creates a fixed heap-dynamic array?

Homework Answers

Answer #1

Dynamically allocated memory is allocated on heap and thus heap-dynamic array refers to dynamic arrays .

Dynamic array is an array which doesn't occupies a limited space or memoy.

It is initialised as:

int * arr= new int(n);

CODE IN C++:

#include<iostream>
using namespace std;
int main()
{
int size;//size of array
cout<<"Enter the size of array : ";
cin>>size;
int *arr=new int(size);
cout<<"Enter the array elements : ";
for(int i=0;i<size;i++)
{
cin>>arr[i];
}
cout<<"The array contains : ";
for(int i=0;i<size;i++)
{
cout<<arr[i];
}

}

OUTPUT SNIPPET:

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
Write a PHP code that: 1- Creates an array that holds 10 random integer numbers between...
Write a PHP code that: 1- Creates an array that holds 10 random integer numbers between 1 and 100. 2- Moves all multiple of 3-numbers in the array that created in part-a into a new array. 3- Moves all multiple of 5-numbers in the array that created in part-a into a new array. 4- Find the maximum and the minimum multiple of 3-numbers, if exist. 5- Find the maximum and the minimum multiple of 5-numbers, if exist. 6- Prints the...
Write the C55x assembly code for each of the following C snippet code shown below. Assume...
Write the C55x assembly code for each of the following C snippet code shown below. Assume the 8-bit values a, b, c, and d are stored in locations 0x600, 0x601, 0x602, and 0x603 respectively in the memory. Store the result x in location 0x604 and y in location 0x60C. Do not use software to generate the assembly code and comment your code. x = (a - b)3 - (c*d); for (j=0;j<=200;j++)   y = y + (a * b);
/** * 1. Write the method plusTwo(). * * Your method will take 2 int arrays...
/** * 1. Write the method plusTwo(). * * Your method will take 2 int arrays as parameters. * Each will have a length of 2. Your method must * create and return a new array with a length of 4, * containing all their elements. * * Here are some examples: * plusTwo({1, 2}, {3, 4}) returns {1, 2, 3, 4} * plusTwo({4, 4}, {2, 2}) returns {4, 4, 2, 2} * plusTwo({9, 2}, {3, 4}) returns {9, 2,...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
IN JAVA!! You may be working with a programming language that has arrays, but not nodes....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes. In this case you will need to save your BST in a two dimensional array. In this lab you will write a program to create a BST modelled as a two-dimensional array. The output from your program will be a two-dimensional array.   THEN: practice creating another array-based BST using integers of your choice. Once you have figured out your algorithm you will be able...
In JAVA Find the code for sorts in your language some where online. You will copy...
In JAVA Find the code for sorts in your language some where online. You will copy code from the internet (with citation!) and modify it to test. Make a random array of integers, then perform each search on them. LINEAR SEARCH Write a linear search method to find a number in the list. Call this before each of your sort methods. Include a comment explaining how Linear Search works, when to use it, when you cannot. BINARY SEARCH Write a...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's length, width, and area Define an overloaded constructor and use it when creating the Rectangle object instead of using the setters. Change this program to calculate and display the rectangle's perimeter. Example: In feet, how wide is your house? 20 In feet, how long is your house? 25 The house is 20.00 feet wide. The house is 25.00 feet long. The house has 500.00...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
(a) Write an algorithm (use pseudo-code) to determine whether a function f ∶ Z100 → Z100...
(a) Write an algorithm (use pseudo-code) to determine whether a function f ∶ Z100 → Z100 is surjective. That is, supply a “Method” to go with Input: A function (array) f with f(i) ∈ Z100 for i = 0, 1, . . . , 99. Output: Boolean B. B=‘true’ if f is surjective, ‘false’ otherwise. Try to make your algorithm as efficient as possible. Do NOT include an implementation of your algorithm in a programming language. (b) How many comparisons...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT