Word frequencies - functions
Define a function named GetWordFrequency that takes a vector of strings and a search word as parameters. Function GetWordFrequency() then returns the number of occurrences of the search word in the vector parameter (case insensitive).
Then, write a main program that reads a list of words into a vector, calls function GetWordFrequency() repeatedly, and outputs the words in the vector with their frequencies. The input begins with an integer indicating the number of words that follow.
Ex: If the input is:
5 hey Hi Mark hi mark
the output is:
hey 1
Hi 2
Mark 2
hi 2
mark 2
Hint: Use tolower() to set the first letter of each word to lowercase before comparing.
The program must define and use the following function:
int GetWordFrequency(vector wordsList, string currWord)
#include
#include
#include
#include
using namespace std;
/* Define your function here */
int main() {
/* Type your code here */
return 0;
}

Answers

Answer 1

Answer:

#include <iostream>

#include <vector>

#include <iomanip>

#include <string.h>

#include <string>

#include <algorithm>

using namespace std;

bool strEqual(const string& str1, const string& str2)

{

 //check each characters by case insensitive  

 return std::equal(str1.begin(), str1.end(),

                     str2.begin(), str2.end(),

                     [](char str1, char str2) {

                         return tolower(str1) == tolower(str2);

                     });

}

unsigned GetWordFrequency(vector<string>& vec,const string& str)

{

 //return the number of occurrences of the search word in the

 unsigned res=0;//the numbers of occurences

 for(auto itr:vec)

   {

     if(strEqual(itr,str))

       res++;

   }

 return res;

}

int main()

{

 int size=0;

 cin>>size;

 vector<string>vec;

 for(int i=0;i<size;i++)

   {

     string str;

     cin>>str;

     vec.push_back(str);

   }

   cout<<"Output:"<<endl;

 for(auto itr: vec)

   {

     cout<<itr<<" - "<<GetWordFrequency(vec,itr)<<endl;

   }

 return 0;

}

Explanation:


Related Questions

In a relocatable dynamic partition scheme, the ____ contains a value that must be added to each address referenced in a program so that the system will be able to access the correct memory addresses after relocation. a. compaction register b. bounds register c. load register d. relocation register

Answers

In a relocatable dynamic partition scheme, the  bounds register contains a value that must be added to each address referenced in a program.

What is bounds registers?

This is known to be two registers that has its contents that are known are used to tell an area of memory where one can have access control.

Therefore, In a relocatable dynamic partition scheme, the  bounds register contains a value that must be added to each address referenced in a program.

Learn more about bounds register from

https://brainly.com/question/15041633

#SPJ1

(a) What are computer scanning device
(b)Name the type of scanner used:

Answers

Answer
Answer A):- A scanner is a device that captures images from photographic prints, posters, magazine pages and similar sources for computer editing and display. Scanners work by converting the image on the document into digital information that can be stored on a computer through optical character recognition (OCR).

Answer b):-The information will include; cost, and how its used The four common scanner types are: Flatbed, Sheet-fed, Handheld, and Drum scanners.
Hope it Helps!

You are the computer specialist in a small business. Your company server is named FS1 and has an IP address of 10.0.0.2. The hardware in your company server started to experience intermittent failures, so you transferred the shares on the server to a spare server and took the main server offline. The spare server has an IP address of 10.0.0.3. You edit the existing A record for FS1 on your company's DNS server and redirect the hostname to the spare server's IP address of 10.0.0.3. Afterward, most users are able to access the shares on the spare server by hostname, but several users cannot. Instead, they see an error message indicating that the FS1 server could not be found. Enter the command you can run from the command prompt on these workstations that will allow them to access the shares on FS1 without performing a full restart.

Answers

The command for the above case is:

ipconfig /flushdns

Deletes local DNS name cache

What is  system command?

This is known to be a form of a user's instruction that is often given by the computer and it is one that requires for action to be done by the computer's executive program.

Note that The command for the above case is:

ipconfig /flushdns

Deletes local DNS name cache

Learn more about  IP address from

https://brainly.com/question/24930846

#SPJ1

What was one effect of better printing methods during the Ming Dynasty? Updated trade routes A new merchant class Increased literacy rates More codes and laws

Answers

The one effect of better printing methods during the Ming Dynasty For millennia its mastery made China the only withinside the international capable of produce copies of texts in splendid numbers and so construct the biggest repository of books.

What have been 3 consequences of the printing revolution?

Printed books have become extra conveniently to be had due to the fact they have been less difficult to supply and inexpensive to make. More humans have been capable of learn how to study due to the fact they may get books to study.

As in Europe centuries later, the advent of printing in China dramatically diminished the fee of books, for that reason assisting the unfold of literacy. Inexpensive books additionally gave a lift to the improvement of drama and different kinds of famous tradition. Freed from time-ingesting hand copying, the unfold of tradition and know-how accelerated, ushering international civilization onto a brand new stage.

Read more about the Ming Dynasty:

https://brainly.com/question/8111024

#SPJ1

Answer:

c

Explanation:

Assume your organization has 200 computers. You could configure a tool to run every Saturday night. It would query each of the systems to determine their configuration and verify compliance. When the scans are complete, the tool would provide a report listing all systems that are out of compliance, including specific issues. What type of tool is being described

Answers

The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

What are compliance tools?

The Security Compliance Manager is known to be a form of downloadable tool that one can use as it helps a person to plan, ascribe, operate, and manage a person's security baselines for Windows client and other forms of server operating systems.

Note that in the case above, The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

Learn more about Security Compliance Manager from

https://brainly.com/question/24338783

#SPJ1

1. A teacher asked a student to capture and print out a one-slide presentation using MSWord,       showing everything on the screen.
i)       What keys or combination of keys can be used to carry out this operation ?
ii)     Describe the procedures to be followed by the student in carrying out this operation?
iii)  Describe the procedure to be followed by the student in carrying out this assignment using the keyboard.
b) A system Analyst was hired to set up a computer laboratory for Gan di Gan International      School,
    i.) Mention three hardware devices the analyst would need to set up the laboratory
   ii) List two database applications likely to be recommended by the analyst
  iii) State five Word Processing packages likely to be installed

Answers

The keyboard combinations that can be used to capture and print out a one-slide presentation using MSWord, showing everything on the screen is Function key + PrtScr

What is a Key Combination?

This refers to the procedure that is used to combine two or more keys on the keyboard to execute a task.

Hence, we can see that the procedure that can be used to carry out the operation is:

Enter the screen you want to capture and printPress the Function key, followed by the PrtScr. Please note this can vary slightly, depending on the keyboard.

The hardware devices that would be needed to be set up by the system analyst at a computer laboratory are:

System UnitLaptops/MonitorPower adaptersEthernet cables, etc

The database applications that can be recommended by the system analyst are:

MySQL, SQL Server

The five word processing packages that are likely to be installed are:

G00..gle DocsMsWordMSOfficeDropbox PaperCorel WordPerfect

Read more about word processing here:

https://brainly.com/question/985406

#SPJ1

Ready to attempt the final challenge? Supply the 3 passwords you received via the first 3 challenges to proceed! Password from challenge #1 (all lowercase): Password from challenge #2 (all lowercase): Password from challenge #3 (all lowercase):

Answers

Using the knowledge in computational language in python it is possible to write a code that through a list manages to organize the largest and smallest numbers in order.

Writting the code in python:

# finding largest in the list

list_max = challenge3[0]

for i in range(len(challenge3)) :

   if challenge3[i] > list_max :

       list_max = challenge3[i]        

print("largest in the list = ", list_max)

# number of times largest occurs in list

max_count = 0

for i in range(len(challenge3)) :

   if challenge3[i] == list_max :

       max_count += 1        

print("number of times largest occurs in list = ", max_count)

# finding second largest in the list

list_sec_max = challenge3[0]

for i in range(len(challenge3)) :

   if challenge3[i] > list_sec_max and challenge3[i] < list_max :

       list_sec_max = challenge3[i]        

print("second largest in the list = ", list_sec_max)

# number of times second largest occurs in list

sec_max_count = 0

for i in range(len(challenge3)) :

   if challenge3[i] == list_sec_max :

       sec_max_count += 1        

print("number of times second largest occurs in list = ", sec_max_count)

# location of first occurence of largest in the list

first_index = -1

for i in range(len(challenge3)) :

   if challenge3[i] == list_max :

       first_index = i

       break        

print("location of first occurence of largest in the list = ", first_index)

# location of first occurence of largest in the list

last_index = -1

for i in range(len(challenge3) - 1, -1, -1) :

   if challenge3[i] == list_sec_max :

       last_index = i

       break        

print("location of first occurence of largest in the list = ", last_index)

See more about python at brainly.com/question/13437928

#SPJ1

Select the correct answer.
What does firewall software do?
A.
It improves network connectivity.
B.
It monitors network traffic to block malicious content.
C.
It adds some new features to the operating system.
D.
It installs viruses in the system.

Answers

Answer:

B

because it is an antivirus

In 25 words or fewer, explain why businesses use social media to digitally market their products.

Answers

Due to the accessibility of social media platforms, businesses have the opportunity to follow their potential customers. Social media marketers need to know more about their target market's needs, wants, and interests in order to develop a more effective marketing plan to draw in these potential customers.

What is social media?

Social media is a term used to describe online communication. Social media systems enable users to have discussions, exchange information, and create content for the internet.

Users utilize social media networks, sometimes referred to as digital marketing, as a platform to create social networks and share information in order to develop a company's brand, boost sales, and enhance website traffic.

Hence, the significance of the social media is aforementioned.

Learn more about on social media, here:

https://brainly.com/question/18958181

#SPJ1

HELP! Write a program that generates 6 random numbers between 0 and 30, prints the numbers as shown, calculates the sum and the average of these numbers, and prints them

Answers

The program that generates 6 random numbers between 0 and 30 and makes mathematical computations is:

import random

import statistics

a = random.random()

b = random.random()

c = random.random()

d = random.random()

e = random.random()

f = random.random()

print("Generated Numbers:")

print(a, b, c, d, e, f)

seq = (a, b, c, d, e, f)

mean = statistics.mean(seq)

median = statistics.median(seq)

mode = statistics.mode(seq)

print("Mean =", mean)

print("Median =", median)

print("Mode =", mode)

Read more about programming here:

https://brainly.com/question/23275071

#SPJ1

_____ are standard settings that control how the screen is set up and how a document looks when you first start typing

Answers

The standard settings that control how the screen of a computer is set up and how a document looks when you first start typing is called default settings.

What is a word processing software?

A word processing software can be defined as a type of software that is designed and developed so as to enable its end users type, format and save text-based documents such as:

In Computer technology, the standard settings that control how the screen of a computer is set up and how a document looks when you first start typing on a word processing software is called default settings.

Read more on word processing here: brainly.com/question/24043728

#SPJ1

Self-driving cars are a result of developments in which field of computer
science?

Answers

Answer: I think Artificial Intelligence (AI)

Explanation:

As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After several days, you notice that the system locks up and reboots from time to time. You suspect that a recent update is causing the problem. How can you quickly restore the computer to its state before the updates

Answers

Answer is restore the system using a restore point.
Explained: System Restore lets you roll your system settings back to a specific date when everything was working properly.

which Yandere Simulator update removed the box of matches?

Answers

Answer:

Fixed the glitchy physics of Yandere-chan’s latest hairstyle. Removed exploit that allowed players to keep a character stationary indefinitely by talking to a student about their Task and never dismissing the Task Window. Adjusted the pathfinding grid so that it should be less likely for a student’s path to the male locker room to be blocked.

Explanation:

Answer:

i couldnt find the exact year but heres a list of bug fixes n stuff if this helps

Explanation:

https://yandere-simulator.fandom.com/wiki/Update_History

Which web-authoring software enables users to create sophisticated web pages without knowing any html code?.

Answers

Answer: One of the best software

Explanation: Dreamweaver!

When evaluating a website's content, whether or not the information is up to date is considered part of the ________ element.

Answers

The currency element constitutes information whether the information of the website is current or up to date.

Website

A website is a term used to describe unique publicly accessible web pages that are identified by a domain name. Information on websites is typically updated by website owners, hence, some websites may not be updated frequently when compared to others. Thus, the currency element is an element users take into consideration when evaluating a website's content, whether or not the information is up to date.

You can learn more about the currency element here https://brainly.in/question/48673521

#SPJ1

If you want to stop a loop before it goes through all of its iterations, the break statement may be used. Group of answer choices True False

Answers

Answer:

Answer is true

Explanation:

(n) ____ operator requires a single operand either before or after the operator. unary single binary

Answers

A unary operator requires a single operand either before or after the operator.

Who is a  unary operator?

This is known to be a person or  an operator that is often known to use or operate only on a single operand so as to return a new value.

Note that A unary operator requires a single operand either before or after the operator.

Learn more about   unary operator from

https://brainly.com/question/13814474

#SPJ1

1. Explain what peer to peer networking is.
2. Describe at least one pro and one con of peer to peer networking.
3. Describe at least one pro and one con of network printer connections.
4. Describe at least one pro and one con of local printer connections.
5. Choose and explain, step by step, one method of backing up student files either manually or using a cloud service.

Answers

Peer-to-peer networking

Peer-to-peer networking is a term used to describe a system of communication that allows a group of computers to exchange information in a permissionless way.

One pro of -peer-to-peer networking is that it decentralizes how information is transferred and secured since files are stored on just a single device.

On the other hand, a con of peer-to-peer networking is the possible exposure to harmful data such as malware. been transferred from another computer.

You can learn more about peer-to-peer networks from a similar question here https://brainly.com/question/1932654

#SPJ1

Chris is responding to a security incident that compromised one of his organization's web servers. He believes that the attackers defaced one or more pages on the website. What cybersecurity objective did this attack violate

Answers

The cybersecurity objective that the above attack violate is known as Integrity.

What is Cybersecurity aims?

Their objectives is majorly to protect any computers system, networks, and other kinds of software programs from any type of cyber attacks.

Note that The cybersecurity objective that the above attack violate is known as Integrity as they are not the kind of people that keep to their words.

Learn more about cybersecurity from

https://brainly.com/question/12010892

#SPJ1

Write a method reverse that takes an array as an argument and returns a new array with the elements in reversed order. Do not modify the array.

Answers

Answer:

public class ArrayUtils

{

//function to reverse the elements in given array

public static void reverse(String words[])

{

//find the length of the array

int n = words.length;

//iterate over the array up to the half

for(int i = 0;i < (int)(n/2);i++)

{

//swap the first element with last element and second element with second last element and so on.

String temp;

temp = words[i];

words[i] = words[n - i -1];

words[n - i - 1] = temp;

}

}

public static void main(String args[])

{

//create and array

String words[] = {"Apple", "Grapes", "Oranges", "Mangoes"};

//print the contents of the array

for(int i = 0;i < words.length;i++)

{

System.out.println(words[i]);

}

//call the function to reverse th array

reverse(words);

//print the contents after reversing

System.out.println("After reversing............");

for(int i = 0;i < words.length;i++)

{

System.out.println(words[i]);

}

}

Explanation:

Think about how you view your emails—either the email service you use yourself or an email service you would choose to use. Describe that email service and then explain whether you use POP3 or IMAP to access your email. How do you know it’s POP3 as opposed to IMAP?

Answers

Answer:

and POP3, followed in later years. POP3 is still the current version of the protocol, though this is often shortened to just POP. While POP4 has been proposed, it's been dormant for a long time.

IMAP, or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don't include the number.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage.

Think about how you view your emails is either the email service you use yourself or an email service you would choose to use POP3, followed in later years.

What is POP3?

POP3, followed in later years as the POP3 is still the current version of the protocol, though this is often shortened to just POP. While POP4 has been proposed, it's been dormant for a long time.

IMAP, or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don't include the number.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage.

Therefore, Think about how you view your emails is either the email service you use yourself or an email service you would choose to use POP3, followed in later years.

Learn more about emails on:

https://brainly.com/question/14666241

#SPJ2

The four memory management techniques presented in this chapter share the requirement that the entire program being executed must be ____.

Answers

The four memory management techniques requires that the entire software program that's being executed must be loaded into memory.

What are the 4 memory management techniques?

In Computer science, there are four memory management techniques and these include the following:

Single contiguous allocation.Partitioned allocation.Paged memory management.Segmented memory management.

As a general rule, the aforementioned memory management techniques requires that the entire software program that's being executed must be loaded into memory.

Read more on memory here: https://brainly.com/question/13081782

#SPJ1

Write a function named swapFrontBack that takes as input an array of integers and an integer that specifies how many entries are in the array. The function should swap the first element in the array with the last element in the array. The function should check if the array is empty to prevent errors. Test your function with arrays of different length and with varying front and back numbers.

Answers

Answer:

#include <iostream>

#include <vector>

using namespace std;

void swapFrontBack(vector<int>& nums) {

if(nums.size() < 2) {

return;

}

swap(nums[0], nums[nums.size()-1]);

}

void printit(vector<int>& arr) {

for(int i = 0; i < arr.size(); i++) {

cout << arr[i] << " ";

}

cout << endl;

}

int main() {

vector<int> num1;

swapFrontBack(num1);

printit(num1);

num1.push_back(1);

swapFrontBack(num1);

printit(num1);

num1.push_back(2);

swapFrontBack(num1);

printit(num1);

vector<int> num2(10, 1);

num2[9] = 2;

swapFrontBack(num2);

printit(num2);

return 0;

}

Explanation:

Which type of input devices used in big hero 6 movie

Answers

The  Input Devices Used in Movie Big Hero are:

A joystick medical robot Armored exoskeleton Jet-boots.

What are input device?

This is known to be a is a piece of instrument that helps gives or provide data to any information processing system.

Note that the Input Devices Used in Movie Big Hero “6”  are  a medical robot made by by Tadashi Hamada., Armored exoskeleton and others.

Learn more about input device from

https://brainly.com/question/24455519

#SPJ1

10101 base 2 - 110+2​

Answers

Answer:

-87

Explanation:

(10101 base 2) = 21

21 - 110 +2 = -87

Despite how well you might take care of your computer, problems can always arise. when troubleshooting problems you encounter, at what point should you engage a professional for assistance? why? at what point might you consider purchasing a new computer?

Answers

If troubleshooting problems is the one you encounter, the best thing to do is for one to get a professional to help one to see if the problem with the hardware  is one that is within the computer chassis.

What is troubleshooting?

Troubleshooting is known to be a form of systematic method that is often used in problem-solving that is known to help one to see and also correct issues that are linked with complex machines, electronics, computers and software systems.

Hence, If troubleshooting problems is the one you encounter, the best thing to do is for one to get a professional to help one to see if the problem with the hardware  is one that is within the computer chassis.

Learn more about troubleshooting from

https://brainly.com/question/9572941

#SPJ1

Which feature of cryptography is used to prove a user's identity and prevent an individual from fraudulently reneging on an action?

Answers

A feature of cryptography which is used to prove an end user's identity and prevent an individual from fraudulently reneging on an action is nonrepudiation.

What is nonrepudiation?

Nonrepudiation can be defined as an assurance that the sender of a message is given a proof of delivery and the recipient of this message is also provided with a proof of the sender’s identity, so none of them can deny having processed this message.

This ultimately implies that, nonrepudiation is a security service which has a feature of cryptography and it can be used to prove an end user's identity and prevent an individual from fraudulently reneging on an action

Read more on nonrepudiation here: brainly.com/question/14631388

#SPJ1

A license may limit the use of a software application to a specific device. Group of answer choices True False

Answers

Answer:

true

Explanation:

The constructor for Object supports methods that are used to retrieve and define properties for any object. True False

Answers

The constructor for Object supports methods that are used to retrieve and define properties for any object is a True statement.

What is the constructor of an object?

The Object constructor is known to be one that forms an object wrapper for any kind of given value.

When the value is null or undefined , it will form and return an empty object and as such, The constructor for Object supports methods that are used to retrieve and define properties for any object is a True statement.

Learn more about Object supports  from

https://brainly.in/question/34445581

#SPJ1

Other Questions
How would you answer this?: z^3/z^9 Read the list of Supreme Court cases. Brown v. Board of Education Engel v. Vitale Miranda v. Arizona Gideon v. Wainwright Who was Chief Justice of the Supreme Court in those cases? John Marshall John Marshall Warren Burger Warren Burger Earl Warren Earl Warren William Rehnquist Enter the correct answer in the box. Write your answer in the form y - mx + b, using the appropriate inequality symbol in place ofthe equal sign.What inequality is shown in the graph? Which statement is correct?(2.06 times 10 Superscript negative 2 Baseline) (1.88 times 10 Superscript negative 1 Baseline) less-than StartFraction 7.69 times 10 Superscript negative 2 Baseline Over 2.3 times 10 Superscript negative 5 Baseline EndFraction (2.06 times 10 Superscript negative 2 Baseline) (1.88 times 10 Superscript negative 1 Baseline) greater-than-or-equal-to StartFraction 7.69 times 10 Superscript negative 2 Baseline Over 2.3 times 10 Superscript negative 5 Baseline EndFraction(2.06 times 10 Superscript negative 2 Baseline) (1.88 times 10 Superscript negative 1 Baseline) greater-than StartFraction 7.69 times 10 Superscript negative 2 Baseline Over 2.3 times 10 Superscript negative 5 Baseline EndFraction(2.06 times 10 Superscript negative 2 Baseline) (1.88 times 10 Superscript negative 1 Baseline) = StartFraction 7.69 times 10 Superscript negative 2 Baseline Over 2.3 times 10 Superscript negative 5 Baseline EndFraction Maths Trigonometry Question100 points up for grabs!Will give brainliest to whoever answers (PLEASE HELP I WILL MARK BRAINLIEST) Dilate the figure by the scale factor. Then enterthe new coordinates.K = 3C(-4,-2)A' = ([?],B' = ([],B (3-1) C'=(,A(1,2)Hint: To calculate thex-value of A', multiply thex-value of A by 3. In Freudian theory, which one of the following is an example of an Eros instinct, which includes survival, social cooperation, and reproduction?A. speeding in a car.B. skydiving.C. stealing from an electronics store.D. organizing a neighborhood food drive Find the HCF of xy and x^2 Use the internet to find out more about kidney machines and kidney transplants . how is the donor's kidney tested to see whether it is suitable? why is rejection of the new kidney a problem and how is it dealt with? After World War II, relations between the Soviet Union and theUnited States were marked by1 pointO Reliance on international peace organizations to resolve disputes.O Slow but steady decreases in military forces and armaments.O Refusal to negotiate on any issues.O Conflicts where the superpowers supported opposing sides, but did notconfront each other directly.GEDERECER x^3(x^2-13)=-36xIf x>0, what is one possible solution to the equation shown above? On the average, 1.8 customers per minute arrive at any one of the checkout counters of a grocery store. What probability distribution can be used to find the probability that there will be no customers arriving at a checkout counter in the next minute Which rectangular equation represents the parametric equations x =t superscript one-half and y = 4t? I need some help please Hello people ~help me with the question attached.Thanks in advance. Newtons laws of motion are an inherent part of our everyday life. Starting from the beginning of the day till the end, Newtons laws find their applications in a number of activities we do. Assuming technology and production techniques are fixed and cannot change, if beyond some point of production a firm experiences declining units of additional output with each additional unit of labor input, then the firm is experiencing the effects of the law of ______. 8. What is 3x times (3x - 5)?a.3x + 5x -5b.9x-5c.9x - 15xd.15x - 25x Which asset made belgium a good place to establish the first industrialized textile manufacturer. What percentage of the area under the normal distribution is shaded?