Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE PROVIDE PYTHON CODES FOR THE FOLLOWING SHORT FUNCTIONS IN PARTS (A) TO (E). PLEASE ADD COMMENTS AND PROVIDE SCREENSHOT OF THE CODES AS WELL.
PLEASE PROVIDE PYTHON CODES FOR THE FOLLOWING SHORT FUNCTIONS IN PARTS (A) TO (E).
PLEASE ADD COMMENTS AND PROVIDE SCREENSHOT OF THE CODES AS WELL.
LET THE FILENAME BE 'T1'.
a) Write a function readFile(filename) that reads the text file with the given filename and returns a list of the lines of text in the file. b) Write a function getWordsFromLineList(list) that parse the list of the lines of text into words and returns a list of all words found. c) Write a function countFrequency(list) that computes the frequency of each word in the list and returns a list of tuples in the form: (word, frequency). d) Implement a function merge Sort(list, column, ascending=True) that takes a list of tuples already loaded and uses Merge Sort to sort the data by the given column in ascending or descending order. For example, considering the list of tuples of the form: (word, frequency) a. merge Sort(Ist, 0, True) will sort the list by words in alphabetical order. b. merge Sort(Ist, 1, False) will sort the list by frequency in descending order. e) Implement a function quickSort(list, column, ascending=True) that takes a list of tuples and uses Quick Sort to sort the data by the given column in ascending or descending order. The pivot element can be randomly selected
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started