subject

Note: 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: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:30
Me2540 week 5 assignment what do i want to know?
Answers: 1
question
Computers and Technology, 22.06.2019 06:50
Match the personality traits with their description
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Which text format is this, "the text is transcribed exactly as it sounds and includes all the utterances of the speakers. "?
Answers: 2
question
Computers and Technology, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
You know the right answer?
Note: A pair is a simple struct with two data members, one of type T1 and one of type T2. A set and...
Questions
question
Physics, 13.09.2021 16:20
question
Mathematics, 13.09.2021 16:20
question
English, 13.09.2021 16:20
question
Spanish, 13.09.2021 16:20
question
Mathematics, 13.09.2021 16:20
question
Arts, 13.09.2021 16:30
Questions on the website: 13722361