get_avg_ratings() takes a 2-D list similar to ratings_db as the parameter and returns a dictionary, where each {key: value} of this dictionary is {a valid movie id: the average rating this movie received by the reviewers}. I will refer to this dictionary as ratings. >>> ratings = get_avg_ratings(ratings_db) >>>> display_dict(ratings) 1: 3.92 2: 3.43 3: 3.26 4: 2.36 5: 3.07 6: 3.95 7: 3.19 8: 2.88 9: 3.12 10: 3.5 11: 3.67 12: 2.42 13: 3.12 14: 3.83 15: 3.0 16: 3.93 17: 3.78 18: 3.7 19: 2.73 20: 2.5 userId,movieId,rating,timestamp 1,1,4,964982703 5,1,4,847434962 7,1,4.5,1106635946 15,1,2.5,1510577970 17,1,4.5,1305696483 18,1,3.5,1455209816 19,1,4,965705637 21,1,3.5,1407618878 27,1,3,962685262 31,1,5,850466616 32,1,3,856736119 33,1,3,939647444 40,1,5,832058959 43,1,5,848993983 44,1,3,869251860 45,1,4,951170182 46,1,5,834787906 50,1,3,151423811
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
get_avg_ratings() takes a 2-D list similar to ratings_db as the parameter and returns a dictionary, where each {key: value} of this dictionary is {a valid movie id: the average rating this movie received by the reviewers}. I will refer to this dictionary as ratings.
>>> ratings = get_avg_ratings(ratings_db)
>>>> display_dict(ratings)
1: 3.92
2: 3.43
3: 3.26
4: 2.36
5: 3.07
6: 3.95
7: 3.19
8: 2.88
9: 3.12
10: 3.5
11: 3.67
12: 2.42
13: 3.12
14: 3.83
15: 3.0
16: 3.93
17: 3.78
18: 3.7
19: 2.73
20: 2.5
userId,movieId,rating,timestamp
1,1,4,964982703
5,1,4,847434962
7,1,4.5,1106635946
15,1,2.5,1510577970
17,1,4.5,1305696483
18,1,3.5,1455209816
19,1,4,965705637
21,1,3.5,1407618878
27,1,3,962685262
31,1,5,850466616
32,1,3,856736119
33,1,3,939647444
40,1,5,832058959
43,1,5,848993983
44,1,3,869251860
45,1,4,951170182
46,1,5,834787906
50,1,3,1514238116
54,1,3,830247330
57,1,5,965796031

Step by step
Solved in 4 steps with 2 images









