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, 24.06.2019 07:50
Write a defining table and then a program that determines if you can sleep in or not. your program should get all its input from your computer’s clock. on all weekdays (monday through friday) that are not holidays, your program should output “get up! ” on all other days (weekends and holidays), your program should output “sleep in.” the three holidays that your program must check for are january 1 (new year’s day), july 4 (u.s. independence day), and december 25 (christmas). you don’t need to include other holidays in your program because most other holidays do not occur on a fixed day each year.
Answers: 1
question
Computers and Technology, 24.06.2019 19:20
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
question
Computers and Technology, 25.06.2019 00:00
He computer component that disperses heat from the microprocessor to the cooling fan is a cooler thermometer heat sink
Answers: 1
question
Computers and Technology, 25.06.2019 07:50
Identify an advantage of centralized processing
Answers: 1
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
Questions on the website: 13722359