Its for computer science C its C Why 2 Search on Youtube abo
It\'s for computer science
C++
its C++!
Why? 2. Search on Youtube about \'search algorithm.animation\'? Provide the link of three of them. Then write a small essay more than 200 words answering the following questio 4) What is a searching algorithm? 5) What are the programming languages that can implement \'searching algorithms 6) What is your favorite searching algorithm among the ones in your YouTube search Why? Project4. Program 1. 1. Create a SortedList called Texas.flowers with 15 names or less, each name in one line. The names may contain \"-\" to connect different words. Use the computer program to perform the following tasks in a sequence: G//n1,·M··· 1) Create a new file called Texasflowers.beautiful. 2) Calculate the number of unique names of the \'Texas.flowers\', and print the number and the names out in Texasflowers.beautuiful 3) names out in \'Texasflowers.beautiful Delete a name that is specified in the computer program, and print the rest of the 4) In the console, ask the user which is his or her favorite flower. The user may input \"coneflowers\", or other names. 5) Insert the name as the favorite flower, and print the current list of names in Texasflowers.beautiful\'. 6) Use \'isPresent\' to search whether the favorate flower that the user entered is in the list, and print the result in the console. TRSolution
Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
int main()
{
char data[100];
ifstream ifile;
vector <string> flowernames;
ifile.open(\"Texas.flowers\");
cout << \"Reading data from a file :-\" << endl << endl;
while (!ifile.eof()) {
ifile.getline(data, 100);
flowernames.push_back(data);
}
ifile.close();
vector<string> uniqueFlower;
vector<int> nInt;
for(int i=0;i<flowernames.size();i++)
{
bool duplicate=false;
for(int j=0;j<uniqueFlower.size();j++)
{
if(flowernames[i]==uniqueFlower[j])
{
nInt[j]+=1;
duplicate=true;
break;
}
}
if (duplicate==false)
{
uniqueFlower.push_back(flowernames[i]);
nInt.push_back(1);
}
}
ofstream ofile;
ofile.open(\"Texasflowers.beautiful\");
ofile << \"Number of unique names flowers:\";
ofile<< uniqueFlower.size();
ofile<<endl;
for(int i=0;i<uniqueFlower.size();i++)
ofile<<uniqueFlower[i]<<endl;
ofile<<\"Removing the name buttercup\"<<endl;
flowernames.erase(flowernames.begin()+2);
for(int i=0;i<flowernames.size();i++)
ofile<<flowernames[i]<<endl;
string str;
cout<<\"Enter your favourite flower: \"<<endl;
cin>>str;
int flag=0;
for(int i=0;i<flowernames.size();i++){
if(str==flowernames[i])
{
cout<<str<<\" already in the list!\";
flag=1;
break;
}
}
if(flag==0)
{
flowernames.push_back(str);
}
ofile<<\"Current List:\"<<endl;
for(int i=0;i<flowernames.size();i++)
ofile<<flowernames[i]<<endl;
ofile.close();
return 0;
}
Input:
bluebonnet
indian_paintbrush
buttercup
indian_blanket
verbana
indian_paintbrush
Output:
Number of unique names flowers:5
bluebonnet
indian_paintbrush
buttercup
indian_blanket
verbana
Removing the name buttercup
bluebonnet
indian_paintbrush
indian_blanket
verbana
indian_paintbrush
Current List:
bluebonnet
indian_paintbrush
indian_blanket
verbana
indian_paintbrush


