Answer:
def occurencesOfWords(words,freq):
frequency_dictionary={}
matched_frequency_words=[]
for i in range(len(words)):
counter=1
a=words[i].lower()
for j in range(len(words)):
if(i==j):
continue
b=words[j].lower()
if(a==b):
counter+=1
frequency_dictionary[words[i]]=counter
for key in frequency_dictionary:
if(frequency_dictionary[key]==freq):
matched_frequency_words.append(key)
return matched_frequency_words
if __name__=='__main__':
user_input=input()
freq=int(input())
words=user_input.split(" ");
required_words=occurencesOfWords(words,freq)
for s in required_words:
print(s)
Explanation:
- Inside the occurencesOfWords function, initialize a frequency_dictionary that is used to store the string and the frequency of that specific string
.
- matched_frequency_words is an array that is used to store each string whose frequency matches with the provided frequency
- Run a nested for loop up to the length of words and inside the nested for loop, skip the iteration if both variables i and j are equal as both strings are at same index.
- Increment the counter variable, if two string are equal.
- Loop through the frequency_dictionary to get the matching frequency strings
.
- Finally test the program inside the main function.
Answer:
Certain country in the Caribbean Sea recently held an election to choose its president. Every vote cast was electronic, but unfortunately, a recent power surge caused a malfunction in the system just before votes were counted. The only information saved consists of the following facts:
Explanation:
• All the N citizens casted their vote.
• Exactly one candidate received more than N/2 votes.
• We don’t know how many candidates there were.
You are hired to help using your expertise in algorithms.
<span>Password procedures, information encryption software, and firewalls are examples of measures taken to address are all measures taken to safeguard information security and protect users data from being tampered or manipulated by invaders.
In web, if we leave our information without encryption or if we leave our system without firewall, different types of security threats might arise: such as, information being hacked, manipulated or sent to wrong places. To avoid this information encryption is done. We might also need to firewall our system so that we can avoid unwanted access and invading of our privacy using malwares and other tools. </span>
Answer:
The base case
Explanation:
Required
The part that determines the termination of a recursion
This part of a recursion is referred to as the base case.
Take for instance, the following:
<em>factorial(int n)
{
</em>
<em> if (n < = 1) { return 1; }
</em>
<em> else { return n*factorial(n-1); } }</em>
<em />
The base case of the above is if (n < = 1) { return 1; }
Because the recursion will continue to be executed until the condition is true i.e. n less than or equals 1
I don’t know really really I don’t know