The hashtags in the list produced will appear in

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Wars film in 2015”, “Happy that the #cs116 midterm was rescheduled. Hope the power stays on tonight.”, “Passed my #cs116ae midterm :-)”], “#cs116”) produces [“Working on my #cs116 assignment now. #Ihatehomework”, “Happy that the #cs116 midterm was rescheduled. Hope the power stays on tonight.”]. 2. Write a function called list_hashtags, that consumes a list of non ­empty strings (tweets) and produces a list of strings. The list that is produced contains the hashtags that appear in tweets. However, each hashtag will only appear once in the list that is produced. The hashtags in the list produced will appear in order based on the first occurrence of that hashtag in tweets. For example, list_hashtags([“Working on my #cs116 assignment now. #Ihatehomework”, “Disney has acquired Lucasfilm for $4.05B & plans to release a new #StarWars film in 2015”, “Happy that the #cs116 midterm was rescheduled. Hope the power stays on tonight.”], “Passed my #cs116ae midterm :-)”) produces [“#cs116”, “#Ihatehomework”, “#StarWars”, “#cs116ae”]. 3. Write a function trending that consumes a non ­empty list of hashtags, L (which may contain duplicate values) and produces a list of the most frequently occurring hashtag(s). Note that more than one hashtag may appear the same number of times. The first occurrence of the frequently occurring hashtag in L determines the order in the list that is produced. For example trending([“#cs116”, “#Ihatehomework”, “#StarWars”, “#StarWars”, “#cs116”, “#cs116ae”]) produces [“#cs116”, #StarWars”]. It is not necessary to sort the list in order to solve this problem, however that is one approach. If you choose to sort the list, remember that you cannot use the built ­in sorting techniques or recursion – you must use iterat...
View Full Document

Ask a homework question - tutors are online