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
satela [25.4K]
3 years ago
10

A pair is a simple struct with two data members, one of type T1 and one of type T2. A set and a map are organized as binary sear

ch trees; anunordered_set and an unordered_map are organized as hash tables that never allow the load factor to exceed some constant, and a loop that visits every item in a hash table of N items is O(N).
Suppose UCLA has C courses each of which has on average S students enrolled. For this problem, courses are represented by strings (e.g. "CS 32"), and students by their int UIDs. We will consider a variety of data structures, and for each determine the big-O time complexity of the appropriate way to use that data structure to determine whether a particular student s is enrolled in course c. For example, if the data structure were vector>>, where each pair in the outer vector represents a course and all the students in that course, with those students being sorted in order, then if the pairs are in no particular order in the outer vector, the answer would be O(C + log S). (The reason is that we'd have to do a linear search through the outer vector to find the course, which is O(C), and then after that do a binary search of the S students in the sorted vector for that course, which is O(log S).) In these problems, we're just looking for the answer; you don't need to write the reason.

e. unordered_map>. What is the big-O complexity to determine whether a particular student s is enrolled in course c?

f. Suppose we have the data structure map> and we wish for a particular course c to write the id numbers of all the students in that course in sorted order. What is the big-O complexity?

g. Suppose we have the data structure unordered_map> and we wish for a particular course c to write the id numbers of all the students in that course in sorted order (perhaps using an additional container to help with that). What is the big-O complexity?

h. Suppose we have the data structure unordered_map> and we wish for a particular student s to write all the courses that student is enrolled in, in no particular order. What is the big-O complexity?
Computers and Technology
1 answer:
madam [21]3 years ago
7 0

Answer:

(e) unordered_map<string, unordered_set<int>>

The outer unordered_map is a hash table, so to search the course c it would take constant time O(1). and once we have the course and its unordered_set , which is again a hash table so to serach the student s it would take constant time O(1).So total time is O(1), constant.

(f) map<string, set<int>>

The outer map is a binary search tree, so to search the course c it would take logC time and once we have the course and its set, which is a binary tree, to list the ids in sorted order we need to do an inorder traversal of the tree that would take O(S) time.So total time is O(logC+S)

(g) unordered_map<string, unordered_set<int>>

The outer unordered_map is a hash table, so to search the course c it would take constant time O(1). and once we have the course and its onordered_set , which is another hash table, to list the ids in sorted order we need to loop through all elements in the hash table which takes O(S) time and sort them using any sorting algorithms or else construct another container set<int> that takes O(SlogS) time. So total time is O(SlogS).

(h) unordered_map<string, set<int>>

The outer unordered_map is a hash table, so we loop through each course in it and do search for the student s in its set<int>, which is a binary search tree, if found we print the course else not. The search takes logS time for each course, so total time is O(ClogS).

You might be interested in
When writing research questions, use action words, such as
irina1246 [14]

Answer: Effect

Explanation:

Research questions are demonstrated as the questions that directs or specifies the dimension of the research for a particular work and helps to determine the objectives of the paper or essay.

As per the question, while writing or farming research questions, action verb like 'effect' must be used as it would help determine the impact of a particular research question on the content and efficacy of the research and thus, frame questions that propose a clear, concise, intricate, and debatable thesis statement and offer an effective dimension to the essay that creates a valid impact on the audience.

6 0
3 years ago
Read 2 more answers
What is a method whereby new problems are solved based on the solutions from similar cases solved in the past?
mario62 [17]

Answer:

"Case-Based Reasoning" is the answer for the above question.

Explanation:

  • Case-Based Reasoning is a process of decision-making theory in which the new problems were solved based on the previously solved problem.
  • It is used in artificial intelligence and robots. This helps to make any AI and robots to do the work and take decisions on its own.
  • The theory is used to make any computer that behaves like humans. It can take decisions like a human.
  • The above question asked about the method by which the new problem is solved on behalf of the old problem. Hence the answer is "Case-Based Reasoning".
4 0
4 years ago
List four reasons of meaningful use that demonstrate the capabilities and processes required for the provider to show active use
Naily [24]

<span>1.       </span>Improve quality of care and reduce health disparities.

<span>2.       </span>Read the orders in the medical record and make sure to read it back again to verify accuracy.

<span>3.       </span>Maintain the security and privacy of patient health information.

<span>4.       </span>Talk to the patients and families in management of their health care.






7 0
4 years ago
Telepresence provides the opportunity for people to work from home and attend virtually. True False
ira [324]
The answer is true.
Telepresence is essentially things like video-chat that allows people to participate in meetings even if they are not physically present.

I hope this helps! :)
~ erudite 
7 0
3 years ago
Read 2 more answers
What are the possible consequences of plagiarism?
Semenov [28]

Answer:

Students who plagiarize or otherwise engage in academic dishonesty face serious consequences. Sanctions may include, but are not limited to, failure on an assignment, grade reduction or course failure, suspension, and possibly dismissal.

3 0
3 years ago
Other questions:
  • Which of the following is an example of a direct payment subsidy?
    12·1 answer
  • zeroIt is a function that takes one argument and returns no value. The function stores the value 0 back into the parameter. x is
    8·1 answer
  • You are a technical support engineer and provide help desk support for the network in a manufacturing company. You receive a cal
    10·1 answer
  • You are given 6 training examples for a binary classification problem as follows:
    12·1 answer
  • Gear systems with __________ can have both drive and driven gears on the same shaft. a. an odd number of gears b. an even number
    6·1 answer
  • A user contacted the help desk to report that the laser printer in his department is wrinkling the paper when printed. The user
    5·1 answer
  • Can anyone fill in the space please
    6·1 answer
  • The response from a Google Form can be seen in how many ways?
    10·1 answer
  • How do I install another part on campaign call of duty cold war? please help.(best answer will get branliest.)
    15·2 answers
  • La estructura basica de una pagina web en Html​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!