Use the Concept of vector and string to do the following
question
1) Write a program that creates a vector of string called V. Vector
V grows and shrinks as the user processes the transactions from a
data file called “data.txt”. The transaction file can only include
three commands: Insert, Delete and Print. With Insert command, you
get two more information, the information you need to insert and
the position it should be inserted. With Delete, you get one more
information that indicates which element (index) should be deleted.
Print command means the content of the vector should be printed on
the screen. For example, you may have the following information in
your file:
Insert Hello
4
Delete
5
Print
The first line indicates that The word “Hello” should be located in
the forth index which means v[4]. Of course you should check if
this insert is possible. This insert is possible if the position
you are attempting to insert the element is not beyond the size of
the vector. The second line means v[5] should be removed. Again
this operation should only be allowed if the index is not beyond
the current size of the vector. Test your program with the
following transaction file:
Insert Total 0
Insert Normal 0
Insert Perfect 1
Insert Program 1
Insert Book 2
Print
Insert Perfect 5
Delete 1
Delete 7
Insert Money 2
Delete 3
Print
I need this using c++ using
#include <iostream>
#include <iomanip>
#include <vector>
#include <fstream>
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Use the Concept of vector and string to do the following question 1) Write a program...
in c++
Program 1 Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions I. void selSort (vector string &v: sorts the vector using selection sort 2. void display (const vector <string & v): displays the vector contents . int binSearch (const vector <ing& v, string key): searches the vector for a key returns the...
CSC331: Data Structures NOTE: Please read the instructions carefully. If you do not understand please do not attempt to answer the question. This is Data Structure. The question is not asking to write a C++, the C++ code is already provided. The question is asking to use COMMAND PROMPT find the cpp file where the code is written, display the message “Hello World!” through COMMAND PROMPT. Then using COMMAND PROMPT to also output the message “Hello World!” into a text...
Hi, I have C++ programming problem here:
Problem:
Please modify your string type vector in for push_back()
function as below:
void push_back(string str)
{
// increase vector size by one
// initialize the new element with str
}
In addition, the standard library vector doesn't provide
push_front(). Implement
push_front() for your vector. Test your code with the main function
below.
int main()
{
vector v1(3);
cout<<"v1: ";
v1.print(); // this should display -, -, -
for...
Must be written in C++ Display results and comments Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions: 1. void selSort (vector <string> & v): sorts the vector using selection sort 2. void display (const vector <string> & v): displays the vector contents 3. int binSearch (const vector <string> & v, string key): searches...
implement a doubly-linked list in C. Each node in the linked list should contain a string, a pointer to the previous node (or NULL), and a pointer to the next node (or NULL). The nodes should be sorted by their strings. struct node_t { char* str; struct node_t* prev; struct node_t* next; } To maintain the doubly-linked list, you should keep a pointer to the head node of the list (or NULL if the list is empty), and a pointer...
Hi I how do i use a vector to search a array for a string that user has enter into the console. here is some of the instructions for the programing I am trying to work on The purpose of this program is to write a class whose job is to read up to 10,000 names into a string array. The class sorts the names and then the user can ask the class to find full names containing a name...
Written in C++ language Write a program that keeps track of a telephone directory. The program should create a structure, Person, with the following data: struct Person { string firstName; string lastName; string phoneNumber; }; The program should then create a vector of Person structs, called directory. Your program should have functions to: - Read the vector data from a data file “telephoneData.txt” into the vector directory. - Print the details of all Persons in the vector. You may use...
Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...
Example program
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
vector<int> factor(int n)
{
vector <int> v1;
// Print the number of 2s that divide n
while (n%2 == 0)
{
printf("%d ", 2);
n = n/2;
v1.push_back(2);
}
// n must be odd at this point. So we can
skip
// one element (Note i = i +2)
for (int i = 3; i <=...
Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...