1answer.
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
miskamm [114]
3 years ago
8

int) You are the head of a division of a big Silicon Valley company and have assigned one of your engineers, Jim, the job of dev

ising an algorithm to sort through an English text of n words and convert it into an Esperanto document. Jim comes up with an algorithm which takes 2n2+2n bit operations to handle an input text with n words. Suppose the computers in your business can handle one bit operation every nanosecond (1 nanosecond =10−9 seconds). How many nanoseconds would it take Jim's algorithm to convert a text with 10 wor
Computers and Technology
1 answer:
sergeinik [125]3 years ago
4 0

Answer:

Correct option is E

Explanation:

a) 2n^2+2^n operations are required for a text with n words

Thus, number of operations for a text with n=10 words is 2\cdot 10^2+2^{10}=1224 operation

Each operation takes one nanosecond, so we need 1224 nanoseconds for Jim's algorithm

b) If n=50, number of operations required is 2\cdot 50^2+2^{50}\approx 1.12589990681\times 10^{15}

To amount of times required is 1.12589990681\times 10^{15} nanoseconds which is

1125899.90685 seconds (we divided by 10^{9}

As 1$day$=24$hours$=24\times 60$minutes$=24\times 60\times 60$seconds$

The time in seconds, our algortihm runs is \frac{1125899.90685}{24\cdot 60\cdot 60}=13.0312 days

Number of days is {\color{Red} 13.0312}

c) In this case, computing order of number of years is more important than number of years itself

We note that n=100 so that 2(100)^2+2^{100}\approx 1.267650600210\times 10^{30} operation (=time in nanosecond)

Which is 1.267650600210\times 10^{21} seconds

So that the time required is 1.4671881947\times 10^{16} days

Each year comprises of 365 days so the number of years it takes is

\frac{1.4671881947\times 10^{16}}{365}=4.0197\times 10^{13} years

That is, 40.197\times 10^{12}=$Slightly more than $40$ trillion years$

You might be interested in
Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a
Ksenya-84 [330]

void Print_3_Element_Subsets(int n,const element_type S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

print("No subset found");

}

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

print(S[i],S[j],S[k]);

}

}

}

}

C++ Implementation;

#include<cstdlib>

#include<time.h>

using namespace std;

int S1[5]= {1,2,3,4,5};

int n1 = 5;

int S2[2]={1,2};

int n2 = 2;

void Print_3_Element_Subsets(int n,const int S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

printf("No subset found\n");

}

printf("3 Subsets are\n");

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

cout<<S[i]<<" "<<S[j]<<" "<<S[k]<<endl;

}

}

}

}

int main()

{

cout<<"Case 1"<<endl;

Print_3_Element_Subsets(n1,S1);

cout<<endl<<"Case 2"<<endl;

Print_3_Element_Subsets(n2,S2);

}

OUTPUT

Case 1

3 Subsets are

1 2 3

1 2 4

1 2 5

1 3 4

1 3 5

1 4 5

2 3 4

2 3 5

2 4 5

3 4 5

Case 2

No subset found

3 Subsets are

--------------------------------

Process exited after 0.0137 seconds with return value 0

Press any key to continue . . .

7 0
3 years ago
Escribe dos diferencias entre las computadoras de la primera y la sexta generacion me pueden ayudar​
Hatshy [7]

Answer:

.N. Generación & Descripción

1

Primera Generación

El período de primera generación: 1946-1959. Base del tubo de vacío.

2

Segunda Generación

El período de la segunda generación: 1959-1965. Base del Transistor

3

Tercera generación

El período de tercera generación: 1965-1971. Circuito integrado de base.

4

Cuarta Generación

El período de cuarta generación: 1971-1980. Base del Microprocesador VLSI.

5

Quinta Generación

El período de la quinta generación: 1980 en adelante. Base del Microprocesador ULSI.

Explanation:

espero y esto te sirva de algo

3 0
2 years ago
les agrees to install a new hard drive and software on marilee's computer in exchange for four of her used textbooks. after he i
WARRIOR [948]

Marilee can sue for breach of contract, because Les had a preexisting duty to do all of the work.

What is hard drive ?

The physical device that houses all of your digital stuff is a hard disk. Digital stuff that is kept on a hard drive includes your papers, photos, music, videos, applications, application preferences, and operating system. There are internal and external hard drives.

What is software?

Software is a collection of instructions, data, or computer programs that are used to run machines and carry out particular activities. It is the antithesis of hardware, which refers to a computer's external components. A device's running programs, scripts, and applications are collectively referred to as "software" in this context.

What does running program means?

Double-click the executable file or the shortcut icon pointing to the executable file on Windows to start the program. If you find it difficult to double-click an icon, you can highlight it by clicking it once and then using the Enter key on the keyboard.

Learn more about hardware and software click here:

brainly.com/question/24231393

#SPJ4

8 0
9 months ago
What US agency originally started ARPANET?
RUDIKE [14]
<span>c. Department of Advanced Research Projects Agency</span>
8 0
2 years ago
Given a string variable string 's;', implement a tokenizer to identify the unique tokens contained in this string, identify all
Flauer [41]

Answer:

#include <iostream>

#include <string>

#include <vector>

#include <cctype>

#include <algorithm>

using namespace std;

void matrixInit( vector< vector<int> >& matrix, int numRows, int numCols);

struct TokenFreq{

string token;

int freq;

};

string spaces(string& istr, string& newstr);

void printVector(vector<TokenFreq> & tfVec);

void getTokenFreqVec( string& istr, vector<TokenFreq> & tfVecVec);

void selectionSort( vector<TokenFreq> & tokFreqVector );  

void insertionSort( vector<TokenFreq> & tokFreqVector );

//main

int main(int argc, const char * argv[]) {

 

vector<vector<int> > matrix;

matrixInit(matrix, 3, 4);

 

string ostr1 = " I do keep the main points straight in my head most of the time, and I do know where to find the details when I need them. by Bjarne Stroustrup";

string ostr2 = " ";

string ostr3 = "Your time is limited, so don’t waste it living someone else’s life.Stay Hungry. Stay Foolish.";

//string ostr = ostr2;

string istr;

 

cout << "Enter the text: ";

getline(cin, istr);

vector<TokenFreq> tfVec;

getTokenFreqVec(istr, tfVec);

selectionSort(tfVec);

insertionSort(tfVec);

return 0;

}

//-----

void selectionSort( vector<TokenFreq> & tokFreqVector ){

TokenFreq temp;

int min;

 

for( int i = 0; i < int(tokFreqVector.size()-1); i++){

min = i;

for (int j = i+1; j <int(tokFreqVector.size()); j++){

if (tokFreqVector[j].freq < tokFreqVector[min].freq)

min = j;

}

if(min!=i)

{

temp = tokFreqVector[i];

tokFreqVector[i] = tokFreqVector[min];

tokFreqVector[min] = temp;

}

}

cout<<"-----selectionSort------------------"<<endl;

printVector(tokFreqVector);

}

void insertionSort( vector<TokenFreq> & tokFreqVector ){

TokenFreq temp;

int max;

 

for( int i = 0; i < int(tokFreqVector.size()-1); i++){

max = i;

for (int j = i+1; j < int(tokFreqVector.size()); j++){

if (tokFreqVector[j].freq > tokFreqVector[max].freq)

max = j;

}

if(max!=i)

{

temp = tokFreqVector[i];

tokFreqVector[i] = tokFreqVector[max];

tokFreqVector[max] = temp;

}

}

cout<<"-----insertionsort------------------"<<endl;

printVector(tokFreqVector);

}

string spaces(string& istr, string & newstr){

int j;

//Check double space and create new string with lowercase

for (int i = 0; i < int(istr.length()); ++i){

istr[i] = tolower(istr[i]);

if (isspace(istr[i])){

//check double space again

j = i+1;

while(true){

if (istr[j] == '\342') istr[j]=' ';

if (istr[j] == '\200') istr[j]=' ';

if (istr[j] == '\224') istr[j]=' ';

if(isspace(istr[j])) j++;

else break;

}

i=j-1;

newstr = newstr + istr[i];

}else

newstr = newstr + istr[i];

}

return newstr;

}

void getTokenFreqVec( string& istr, vector<TokenFreq> & tfVec){

string newstr;

int curr_beg = 0;

int curr_end = 0;

string word;

bool check = false;

int index=0;

 

//call func spaces to get new string

newstr = spaces(istr, newstr);

//cout << newstr << endl;

//cout << endl;

//cout << newstr << "||" << endl;

string tempstr = newstr;

 

if(newstr != " "){

tfVec.push_back(TokenFreq());

}

for (int i = 0; i < int(newstr.length()); ++i){

if(isspace(newstr[i])){

check = false;

 

curr_end = i;

word = tempstr.substr(curr_beg, curr_end - curr_beg);

curr_beg = i + 1;

 

for (int j = 0; j < int(tfVec.size()); j++){

if (tfVec[j].token == word){

tfVec[j].freq++;

check = true;

 

break;

}

}//end-for;

if (check == false && i!=(int(newstr.length())-1)){

//cout <<"**"<< word <<"**"<<word.length()<< endl;

tfVec[index].token=word;

tfVec[index].freq=1;

index++;

tfVec.push_back(TokenFreq());

}

word = "";

//add last value

}

}//end-for

 

if(!isspace(newstr[int(newstr.length())-1])){

word = tempstr.substr(curr_beg, curr_end - (int(newstr.length())-1));

tfVec[index].token=word;

tfVec[index].freq=1;

//tfVec.push_back(TokenFreq());

}

 

printVector(tfVec);

}

void printVector(vector<TokenFreq> & tfVec){

 

cout << "size= {" << tfVec.size() << endl;

for (int i = 0; i < int(tfVec.size()); i++){

cout << " [" << i << "] = (token = \""<< tfVec[i].token <<"\", freq = " << tfVec[i].freq << ")" << endl;

//cout << tfVec[i].token<<endl;;

}

cout << endl;

}

void matrixInit( vector< vector<int> >& matrix, int numRows, int numCols){

int i;

int j;

matrix.resize(numRows, vector<int>(numCols) );

for(i = 0; i< numRows; i++ ){

for(j = 0; j < numCols; j++ )

matrix[i][j] = i*j;

}

 

cout << "size of matrix is: " << numRows << "x" << numCols << endl;

for (i = 0; i < numRows; i++){

for (j = 0; j < numCols; j++){

cout<< "matrix[" << i << "][" << i << "]=" << matrix[i][j] << endl;

}

}

cout << endl;

}

Explanation:

3 0
2 years ago
Other questions:
  • 5. The shell of a document that may be used over and over in desktop publishing is called a
    14·2 answers
  • Monica is teaching herself to paint. What web resource would be the most helpful
    14·1 answer
  • Which of the following is a group of email names and addresses used for mass distribution of a message?
    5·1 answer
  • If a fire should break out in your building, which of the following actions is NOT recommended?
    9·2 answers
  • Where is the typical location of a touchpad inside of a laptop?
    13·1 answer
  • What malware looks like a useful or desired executable program but is, in reality, a program that is supposed to cause harm to y
    11·1 answer
  • Although your project has been accepted by the customer, the contract with the system vendor specifies that it will support the
    13·1 answer
  • What happens when text is added to grouped objects that is larger than an object ?
    9·2 answers
  • Name:
    13·1 answer
  • To make the most informed purchasing decision, you should:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!