subject

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 search 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?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:10
1. declare a constant named cents_per_pound and initialize with 25. 2. get the shipping weight from user input storing the weight into shipweightpounds. 3. using flat_fee_cents and cents_per_pound constants, assign shipcostcents with the cost of shipping a package weighing shipweightpounds.
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
Which is a possible benefit of having a good credit history? having a checking account low interest rate on a car loan high interest rate on a credit card offer bankruptcy
Answers: 1
question
Computers and Technology, 24.06.2019 10:40
Joe needs to see the slide transitions and animations he has applied to his slides in a large view. which presentation view should he use? in which tab would joe find the animations option to make further changes, if any?
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
Ideally, the backrest is tilted back slightly, so when you turn the wheel your shoulders are the seat.
Answers: 2
You know the right answer?
A pair is a simple struct with two data members, one of type T1 and one of type T2. A set and a map...
Questions
question
History, 01.04.2020 17:17
question
Mathematics, 01.04.2020 17:17
question
Mathematics, 01.04.2020 17:17
question
Mathematics, 01.04.2020 17:17
Questions on the website: 13722360