Answer:
See explaination
Explanation:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <sstream>
using namespace std;
// structure to hold the word, frequency and list of lines in which word appears
struct wordFrequency
{
string word;
int frequency;
vector<int> lineNumber;
};
// main method
int main()
{
// input file name. You can change the input file name if your file name is different
string inputFileName = "data.txt";
// creating a map class object to hold words uniquely
map<string, wordFrequency> map_word;
// ifstream class object to open and read from file
ifstream fin(inputFileName);
// validating if file is opened or not
if (!fin.is_open())
{
cout << "Error in opening file!";
exit(1);
}
// string to hold line from file
string line;
// int variable to keep track of line number
int lineNumber = 0;
// fetching lines from file
while (getline(fin, line))
{
// increasing the lineNumber count because we fetch another line
++lineNumber;
// breaking a line into words using stringstream class object
string word;
stringstream iss(line);
// iterating over all the words in a line
while (iss >> word)
{
// if the word is not in the map then we create and add a new pair
auto it = map_word.find(word);
if (it == map_word.end())
{
// creating a new struct object to store new word
wordFrequency w;
w.word = word;
w.frequency = 1;
w.lineNumber.push_back(lineNumber);
map_word.insert({word, w});
}
else
{
// if the word is already there then incresing frequency and push line number into list
it->second.frequency += 1;
it->second.lineNumber.push_back(lineNumber);
}
}
}
// closing the input file
fin.close();
// creating a new output file
ofstream fout("WordFrequency.txt");
if (fout.is_open())
{
// iterating over a map
for (auto word : map_word)
{
// writing data to a output file
fout << "Word is : " << word.second.word << endl;
fout << "Frequency is : " << word.second.frequency << endl;
fout << "Appears in line : ";
for (auto i : word.second.lineNumber)
{
fout << i << " ";
}
fout << endl
<< endl;
}
// closing output file
fout.close();
}
else
{
cout << "Error! Not able to create output file!";
}
}
Incomplete question. Here's the full question:
Data-Time Inc. is a company that manages databases for a large city in Colorado. Included in these databases is information collected from the city’s homeless shelters and free clinics. Specifically, the databases contain personal information of the users of these services over the past 10 years; this includes people’s Social Security numbers and health records.
This data is highly secure and only accessible to the employees of Data-Time Inc. Employees are given a laptop when they are hired which allows them to access the database remotely. Unfortunately, one of these laptops is stolen and the security of the database is compromised.
A majority of the people whose information was compromised are homeless; therefore there is no easy way to contact them in order to alert them of the security breach. How should Data-Time Inc. manage this breach in security?
Explanation:
Since the emphasis is not on reversing the breach that has occurred, but on managing the level of security damage that could occur, it is important measures are directed towards preventing unauthorized access to sensitive information.
For example, the Media Access Control Address (MAC address) of the laptop if known could be greylisted from accessing the server that contains the sensitive information.
Answer:
hybrid topology
Explanation:
The type of topology that is being described is known as a hybrid topology. Like mentioned in the question this is an integration of two or more different topologies to form a resultant topology which would share the many advantages and disadvantages of all the underlying basic topologies that it is made up of. This can be seen illustrated by the picture attached below.
Answer:
D.
Explanation:
edge 2021
Answer:
#include<iostream>
using namespace std;
//main function
int main(){
//initialization
float a1,a2;
//display the message
cout<<"Enter the first number: ";
cin>>a1; //store the value
cout<<"Enter the second number: ";
cin>>a2; //store the value
//display the calculation result
cout<<"The sum is: "<<a1+a2<<endl;
cout<<"The Subtraction is: "<<a1-a2<<endl;
cout<<"The product is: "<<a1*a2<<endl;
cout<<"The Quotient is: "<<a1/a2<<endl;
}
Explanation:
Create the main function and declare the two variables of float but we can enter the integer as well.
display the message on the screen and then store the input enter by the user into the variable using the cin instruction.
the same process for second input as well, display the message and store the input.
after that, print the output of the calculation. the operator '+' is used to add the two numbers like a1+a2, it adds the number stored in the variable.
similarly, the subtraction operator is '-', product '*' and quotient operator '/'.
and finally, we get the desired output.
Picking the largest one of input or partitioned data as pivot value
Median of input or partitioned data is expensive to calculate
Data is sorted already and always pick the median as pivot
Choose the incorrect statement:
When the median is always picked as pivot in input/partitioned data, then quicksort achieves the best-case time complexity.
Mergesort has O(N(log(N)) time complexity for its worst case, average case and best case
Insertionsort reaches its best-case time complexity O(N log(N)) when the input data is pre-sorted
Quicksort is practically fast and frequently used sorting algorithm.
Choose the incorrect statement:
In the lower bound analysis by using decision tree, each branch uses one comparison to narrow down possible cases
In the lower bound analysis by using decision tree, he number of required comparisons can be represented by height of decision tree
A decision tree to sort N elements must have N^2 leaves
O(N log(N)) lower bound means that comparison-based algorithm cannot achieve a time complexity better than O(N log(N))
Choose the incorrect statement regarding time complexity of union-find operation:
Inverse Ackermann function does not depend on N and is a constant factor.
When we use arbitrary union and simple find for union-find operation, the worst-case time complexity is O(MN) for a sequence of M operations and N elements
Union-by-size and Union-by-rank both improve the time complexity to O(M log(N)) for a sequence of M operations and N elements
To finish the entire equivalence class computation algorithm, we need to go over each pair of elements, so if we use union-by-rank with path compression for find operation, then the overall time complexity is O(N^2 log*N), where log*N denotes the inverse Ackermann function.
Choose the incorrect statement regarding Dijstraâs algorithm
Dijstraâs algorithm is a greedy algorithm
Dijstraâs algorithm requires to dynamically update distance/costs/weights of paths.
To begin with, Dijstraâs algorithm initializes all distance as INF
Dijstraâs algorithm can be implemented by heaps, leading to O(|E|+|V| log(|V|)) time complexity, where, particularly, log(|V|) is due to "insert" operation in heaps.
i) Picking the largest one of input or partitioned data as pivot value.
ii) Insertion sort reaches its best-case time complexity O(N log(N)) when the input data is pre-sorted
iii) A decision tree to sort N elements must have N^2 leaves
iv) Inverse Ackermann function does not depend on N and is a constant factor.
v) Dijstraâs algorithm requires to dynamically update distance/costs/weights of paths.
To learn more about quicksort refer to:
#SPJ4