Suppose you are to develop an indexing application with the following conditions
ID: 3712592 • Letter: S
Question
Suppose you are to develop an indexing application with the following conditions:
Input: A document (i.e., a web page) with a known number of words
Output: An index corresponding to the words of the document and their frequencies.
An example would be the portion in the figure below, which is extracted from the SEU main page.
The following is the IDs for the words mentioned in the above portion:
(ACTFL)exeperts visit the Saudi Electronic University to review and develop the Arabic Online Program and the Standrdized Arabic
1 … 11 … 14
Experts … Arabic … Standardized
1 … 2 … 1
The output index consists of two integers separated by a colon. The index for the word “Arabic” is 11:2. The first number before the colon represents the word’s ID, and the second number is the word's frequency (means, telling how many times the word has occurred in the document.)
Which data structure would you select for your solution? Give 2 reasons to justify your answer?
1 Marks
1 Marks
Explanation / Answer
To Count the frequency of words I will use the Hashtable where I will use word Id as key and value as frequency so that when ever Id occurs second time I can increase the frequncy for that word:
1) If we use hashtable than it will easy and fast to access the word based on its Id
2) for finding the frequency of the wrods we need to maintain key value pair for words with their values so it will be easy to maintain if we go with hashtable
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.