answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
artcher [175]
1 year ago
8

Write three functions in C/C++: one that declares a large array statically, one that declares the same large array on the stack,

and one that creates the same large array from the heap. Call each of the subprograms a large number of times (at least 100,000) and output the time required by each. Explain the results. Explain why or why not you cant do this in Java, what are the implication of this? If you can’t specify which type of array can you not declare.
Computers and Technology
1 answer:
Nikolay [14]1 year ago
7 0

Answer:

See explaination

Explanation:

#include<iostream>

#include<stack>

#include <algorithm> // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap

#include <vector> // std::vector

using namespace std;

void StaticArray()

{

unsigned int array[64536];

for(unsigned int i=0;i<64536;i++)

array[i]=i;

}

void Stack()

{

stack<unsigned int> mystack;

for(unsigned int i=0;i<64536;i++)

mystack.push(i);

}

void Heap()

{

unsigned int myints[64536];

for(unsigned int i=0;i<64536;i++)

myints[i]=i;

vector<unsigned int> v(myints,myints+64535);

make_heap (v.begin(),v.end());

push_heap (v.begin(),v.end());

}

int main()

{

StaticArray();

Stack();

Heap();

return 0;

}

You might be interested in
Writing in Java, write a program that prompts the user to input an integer and then outputs both the individual digits of the nu
larisa [96]

Answer:

//Here is code in java.

import java.util.*;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

       int in;

     //scanner class object to read the input

    Scanner scr=new Scanner(System.in);

     // variable to keep running total

    int total=0;

    System.out.println("please enter an Integer:");

     // read the input first time

    in=scr.nextInt();

    System.out.print("individual digits of "+in+" is ");

    if(in<0)

    {

        in=-(in);

    }

   

 

     //call the function to print the digits of number

   print_dig(in);

   System.out.println();

    //calculate the sum of all digits

   do{

       int r=in%10;

       total=total+r;

       in=in/10;

   }while(in>0);

    //print the sum

   System.out.println("total of digits is: "+total);

     

   }catch(Exception ex){

       return;}

}

 //recursive function to print the digits of number

public static void print_dig(int num)

{  

    if(num==0)

    return;

    else

    {

    print_dig(num/10);

    System.out.print(num%10+" ");

    }

}

}

Explanation:

Read a number with the help of object of scanner class.if the input is negative

then make it positive number before calling the function print_dig().call

the recursive method print_dig() with parameter "num".It will extract the digits

of the number and print then in the order. Then in the main method, calculate

sum of all the digits of number.

Output:

please enter an Integer:                                                                                                  

3456                                                                                                                      

individual digits of 3456 is 3 4 5 6                                                                                      

total of digits is: 18

please enter an Integer:                                                                                                  

-2345                                                                                                                      

individual digits of -2345 is 2 3 4 5                                                                                      

total of digits is: 14

6 0
2 years ago
Which data type change will require the app builder to perform the additional steps in order to retain existing functionalities?
Readme [11.4K]

Answer:

Option D is the correct option.

Explanation:

The following option is correct because the lead alteration from number to text and the number to text types of data will reconstruct the important number of the app builder to accomplish those steps which is extra to continue to have that functionality which is in the existence. That's why the app builder has to be reconstructed the types of data for the custom fields.

7 0
1 year ago
The word “computer” has become associated with anything related to screens and keyboard. However, these are not the only parts t
Digiron [165]

Explanation: The CPU is the main control chip which calculates what has to be done in order for your computer to function.

(Very interesting question you had. Hope this answer helps)

4 0
2 years ago
Given the macro definition and global declarations shown in the image below, provide answers to the following questions:
galben [10]

Answer:

A. 243

B. True

C. 0

Explanation:

Macro instruction is a line of coding used in computer programming. The line coding results in one or more coding in computer program and sets variable for using other statements. Macros allows to reuse code. Macro has two parts beginning and end. After the execution of statement of quiz4 x, 4 the macro x will contain 243. When the macro is invoked the statement will result in an error. When the macro codes are executed the edx will contain 0. Edx serve as a macro assembler.

4 0
2 years ago
Which telecommunications device is widely used in industries that require closed communication?
Stella [2.4K]

The telecommunications device that  is widely used in industries that require closed communication are walkie-talkies. Correct answer: D

Walkie-talkies are hand-held, portable, two-way radio transceivers which enable secure communication between the two points, without being part of a network.

3 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following is ideal for long distance communication ?
    5·1 answer
  • Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
    13·1 answer
  • python A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun
    15·2 answers
  • In defining security implemention, what are the roles of the following committees. 1) gateway committee 2) project committee 3)
    8·1 answer
  • Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the givenprogram:Gus Bob Zoeshort_names
    13·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest
    10·1 answer
  • Two-dimensional array indexes are listed as
    8·1 answer
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • When pasting an object which has been copied from a different slide, where on the slide does the object paste, assuming nothing
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!