Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab, you are asked to complete similars.c program file which has been already given in Moodle. Inthis program, there are four functions, namely,
In this lab, you are asked to complete similars.c program file which has been already given in Moodle. Inthis program, there are four functions, namely, main, hashtext, strongsimilar, and weaksimilar.main function is already provided, and it is supposed to remain as it is you should not change it You arerequired to implement hashtext, strongsimilar, and weaksimilar functions. Although this lab is verysimilar to the previous lab, in this time, you will solve your problem using structures.There are a few global declarations in the program which are listed as below:Definitions of constant macros as follows: STRLEN, MAXELEM, and HASHSIZE.A structure defined with several elements to keep the name, last name, namelastname, andstrong hash and weak hash values. The name of the defined type is Student. The hash values,and all other critical information is kept as a record by using the structure of the type of Student. Prototypes of the functions listed above.Here are the operations performed in main function:An array of records in the type of Student is created and initialized to some values. Although thehash values are set to zero, the names are initialized.In the for loop, the name lastname pairs are concatenated and the hash values for strongsimilarity are computed.strongsimilar function is called to find the same namelastname pairs and fill the twodimensionalarray called same to keep the mapping of similarities.The namelastname pairs, the calculated hash values and similarity mapping is printed on thestandard output.weaksimilar function is called to calculate the hash values of each name and surname separately,then build the weak similarity mapping using hash values calculated.The name lastname pairs, and weak similarity mapping is printed on the standard output.Task : Implement hashtext function.unsigned int hashtext char list ;A character pointer holding names and surnames is sent as an input, and the hash value of the input textis returned. During the calculation a basic formula is used as follows when the name is ali. The ascii codefor a is for l is and for i is The function calculates the hash value by the following formula;hash The algorithm should be applied to all symbols including whitespaces between name and surname. At theend mod of hash value should be returned.hash hash mod Consider the below example run:elements with hash valuesahmet yuksel mehmet arslan mustafa kemal ali kemal mustafa kemal mustafa kemal mehmet arslan kemal ahmet ali kaan kemal kaan Task : Implement strongsimilar function.void strongsimilar Student studentListMAXELEM intmapMAXELEMMAXELEMCalculated hash values of all nameslastname pairs are sent to the function. The function modifies andreturns the map of exact matches. Exact matching of the entries is calculated only by using hashed values.Consider the below example run:The matches are calculated and printed through the main program by calling the strongsimilarfunction. Once the strongsimilar function is called in main function, the above output is printed.elements with hash valuesahmet yuksel mehmet arslan mustafa kemal ali kemal mustafa kemal mustafa kemal mehmet arslan kemal ahmet ali kaan kemal kaan elements with hash values and similarities:ahmet yuksel mehmet arslan mustafa kemal ali kemal mustafa kemal mustafa kemal mehmet arslan kemal ahmet ali kaan kemal kaan Task : Implement weaksimilar function.void weaksimilar Student studentListMAXELEM int mapMAXELEMMAXELEMArray of structure of the type of Student is sent as input and previously calculated similarity map is sentas inputoutput parameter.The function calculates hash values of names and lastnames for each pair separately by calling hashtextfunction. Once the hash values of all names and lastanmes are calculated the function updates the maparray to mark the weak similarities either names or surnames are same For example;ali kemal and mustafa kemal are weakly similar. They both are weakly similar to kemal ahmet.Consider the below example run:Once the weaklysimilar function is called in main function, the above output is printed.elements with weak similarities:ahmet yuksel mehmet arslan mustafa kemal ali kemal mustafa kemal mustafa kemal mehmet arslan kemal ahmet ali kaan kemal kaan Once the weaklysimilar function is called in main function, the above output is printed.
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