Let us define the overlap between two words as the count of unique letters they have in common. Thus, the overlap between JANE and MICK is 0. Here are some more examples: - The overlap between JANE and MIKE is 1 (E is common) - The overlap between JANE and MEEK is 1 (E is common; we do not double count a letter) - The overlap between JANE and JEDI is 2 (J and E are common) - The overlap between JANE and PANEL is 3 (A, N, and E are common) - The overlap between JANE and ANKLE is 3 ( A, N, and E are common) - The overlap between JANE and JAUNDICE is 4 (J, A, N, and E are common) Let us define the total overlap between a word W and a collection of words L as the sum of the overlap between W and each of the words contained in L. Thus the total overlap between the word JANE and the collection of words: [MIKE, MEEK, JEDI, PANEL, ANKLE, JAUNDICE] = 1+1+2+3+3+4 = 14 For Project 5, you will be provided with a collection of 5,163 names (in all caps) inside a text file. Each line in the text file contains a single name. Write a program that finds the total overlap between your first name (in all caps) and this collection. If you are using Visual Studio on Windows, the text file you should use is “names_win.txt”. If you are using a Mac to write your programs, the text file to use is “names_mac.txt”. The reason for two different files is that on Windows, the end of line marker is different than on Mac. Other than this, the content of both files are exactly the same. General Guidelines ————————— Here are some general guidelines for writing this program. - You may decide to write this program without any functions. However, it would be to your advantage if you use functions. - The general procedure for writing this program should be: (1) read the file content into an array of strings of appropriate size, (2) for each name in this array, compute the overlap with your own first name, and keep track of the sum of the total overlap, and (3) print out the total overlap. - I am providing a C++ program that contains some useful functions that shows how to read names from a file, and work with strings. You may use ideas from this program. - If the first name of the student is JANE, then the total overlap based on all the names in the file is is 9190. You can use this fact to double check the correctness of your algorithm, if you want to. File link: https://drive.google.com/open?id=1rwUqcfM1kJ3GSqRsKPN8qXOGG5bNLL6J Please answer this question using C++, thank you.
Put names_win.txt and .cpp file(this code) in the same folder to access the names file.
Use CodeBlocks for Successful compilation.
This code is giving accurate result - 9190 for name JANE.
https://pastebin.com/H6Y0iY9K - Copy this code from this link
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <set>
using namespace std;
//Algorithm to find duplicates b/w two strings
//Time complexity is O(m + n) m is length of s1 and n is length
of s2.
int totalOverlaps(string s1, string s2)
{
//Remove all duplicate character in both string.
//e.g. s1 = REEEK will become REK (Removed all duplicates of
E)
// Do this for both string
//Set is used because it does not store duplicates
set < char > str1;
for(int i = 0; i < s1.length(); i++)
str1.insert(s1[i]);
set < char > str2;
for(int i = 0; i < s2.length(); i++)
str2.insert(s2[i]);
//This array is used to store mark all characters
// 124 size reason -> Characters starts from 65 to 122(All small
and large capitals)
int hashArray[124] = {0};
//Iterate from both set to find duplicates.
set < char > ::iterator it;
for(it = str1.begin(); it != str1.end(); it++)
hashArray[*it]++;
for(it = str2.begin(); it != str2.end(); it++)
hashArray[*it]++;
int count = 0;
// From 65 reason -> 'A' ascii code is 65 and 'Z' is 90. 'a' code is 97 and 'z' is 122
for(int i = 65; i < 124; i++)
{
// if any cell has value 2 that means it is present in both
strings. means it is a duplicate.
if(hashArray[i] == 2)
count++;
}
return count;
}
int main()
{
// Read from file
ifstream file("names_win.txt");
string str;
string firstName = "JANE";
vector < string > names;
// Read line by line from file
while (std::getline(file, str))
{
// Push all names in names array one by one.
names.push_back(str);
}
int totalNumberOfOverlaps = 0;
for(string str : names)
{
totalNumberOfOverlaps += totalOverlaps(firstName, str);
}
cout << "Total Number of Overlaps with name " + firstName + " are = " << totalNumberOfOverlaps << "\n";
return 0;
}
Output is equal to the value you mentioned in question.

// Comment if you have any query
Let us define the overlap between two words as the count of unique letters they have...
9. Java coder Courtney is writing a program that derives a list of unique words contained in a given text file: the word values themselves, and a total count for the file. What Collection type would be best suited for the job? Check only one) O (a) BinarySearch (b) List □ (c) Map (d) Set D (e) Queue 10.Software-Engineer Ellie is designing a similar program to Courtney. She needs to track a count for each unique word contained in a...
Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make a word. This type of arrangement is generally referred to as an anagram, it's known as a permutation in mathematics. This assignment will give you some experience thinking about and writing recursive functions. Write a C++ program that searches for ``anagrams'' in a dictionary. An anagram is a word obtained by scrambling the letters of some string. For example, the...
I just need an algorithm for this please! I have C++ code for
it but I dont know how to creat an algorithm ..
CSE 1311-Project 4 Part I: Create and print out the two arrays: (Be sure to do this first) You are allowed to hard code these arrays into your program. You can also put the data into a file and read the information into the program. The data is as follows: 150 250 Anne Bob Ralph 305...
CSC110
Lab 6 (ALL CODING IN JAVA)
Problem: A text file contains a paragraph. You are to read the
contents of the file, store the UNIQUEwords and count the
occurrences of each unique word. When the file is completely read,
write the words and the number of occurrences to a text file. The
output should be the words in ALPHABETICAL order along with the
number of times they occur and the number of syllables. Then write
the following statistics to...
Background: The first step towards helping someone 'decode' a message is often to count how many times each letter of the alphabet appears in the message. Then divide each count by the total number of letters to compute the relative 'frequency'. From these frequencies, it may be easier to recognize which letters are assigned to the vowels. For your own reference, here is a table of standard letter frequencies from typical English text. (You do NOT need to display this...
Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...
Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that work with text files is the problem of locating a specific substring within the file. I am sure we’ve all done this many times when working with Word, Notepad, or other editors. Since we don’t have a GUI or other means of displaying the contents of a file all at once, let’s modify the problem slightly. Rather than locating a specific substring within a...
18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...
please write c++ (windows) in simple way and show all the
steps with the required output
Write a C++ program that simulates the operation of a simple online banking system The program starts by displaying its main menu as shown in Figure1 splay Account nformatson verity Your credit Card elect vour choice Figure 1 Main menu of the program The menu is composed of the following choices 1. When choice 1 is selected (Display Account information), the program should display...