Create a file "list-ex.cpp". In this file write the code corresponding to the following statements:
The goal of this question is to implement a simplified spell checker. Given a series of words, the program should write on output a list of
the words, which are possibly misspelled.
Get the files speller.cpp and holmes.txt. The file "speller.cpp" will contain the code for the
spellchecker and needs to be completed. The file "holmes.txt" is a text in English that will be used as our "dictionnary".
You need to complete the code in the file "speller.cpp". There are three procedures that need to be completed:
Output for the test words should be:
Building dictionnary Dictionnary built speling is probably mis-spelled whree is probably mis-spelled
The goal of the exercise is to define a queue by using two std::stack. Please complete the following definition of a queue in a file named "queue.h".
#ifndef QUEUE_H
#define QUEUE_H
#include <vector>
#include <stack>
template <typename T, typename Container=std::vector<T> > class Queue {
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
explicit Queue(const Container& contents = Container());
bool empty() const;
size_type size() const;
value_type& front();
const value_type& front() const;
value_type& back();
const value_type& back() const;
void push(const value_type& x);
void pop();
};
You need to implement each method above. For that purpose you need to use two std::stack<T>.
To test your implementation, you can use the following code (to be typed in the file named "test_queue.cpp"
#include <iostream>
#include "queue.h"
int main (void) {
Queue<int> q;
q.push(1);
q.push(2);
q.push(3);
while (!q.empty()) {
std::cout << q.front() << std::endl;
q.pop();
}
return 0;
}
The output for the previous program should be:
1 2 3