DUE: Tuesday 5/26 (by 11:59pm)
Once fully tested, submit your C++ source file(s) by zipping them up and emailing the ZIP (or tar) file to me.
keyword_search keywords.txt search-file.txt results.txt
apple pear banana cherry orange grapefruit
once upon an orange morning the grapefruit went to buy an apple but only found a pear actually several pears and an orange the grapefruit bought a pear and another pear but then the grapefruit wanted an apple anyway so the grapefruit went to the banana and orange store there the grapefruit found applesauce and once again an orange but again did not find an apple the grapefruit went to orange lane where the rest of the orange family was waiting
apple 3 banana 1 cherry 0 grapefruit 6 orange 6 pear 3
Max keyword occurrences = 6 Number of max keywords = 2 Max keywords: grapefruit orange
DUE: Monday 6/8 (by 11:59pm)
Once fully tested, submit your C++ source file(s) by zipping them up and emailing the ZIP (or tar) file to me.
+---+---+---+ |.45|...|.7.| |8..|.29|6.3| |.6.|15.|..8| +---+---+---+ |.2.|6.5|9..| |.57|...|84.| |..3|7.4|.1.| +---+---+---+ |9..|.38|.6.| |7.2|54.|..1| |.3.|...|28.| +---+---+---+
DUE: Wednesday 6/17 (by 11:59pm)
Once fully tested, submit your C++ source file(s) by zipping them up and emailing the ZIP (or tar) file to me.
Similar to what we've done in class, your job for this assignment is to implement a series of templated functions for the templated Node<T> class shown below:
template <class T>
class Node { // each Node object is part of only one list
public:
T value;
int position; // numeric index (0..n-1) of where the Node object is in the list
Node<T>* next;
Node<T>* prev;
};
These functions must not be member functions of any class.
// prints the list forward and backward (to help test next and prev pointers)
template <class T>
void print_list( string s, Node<T>* head )
{
cout << s;
if ( !head ) {
cout << " <empty>" << '\n';
}
else
{
Node<T>* p = head;
Node<T>* q = 0;
// forwards
while ( p ) {
cout << " [" << p->position << ']' << p->value;
q = p;
p = p->next;
}
cout << " <--->";
// backwards
while ( q ) {
cout << " [" << q->position << ']' << q->value;
q = q->prev;
}
}
cout << endl;
}
template <class T> void add_to_front( Node<T>* & head, const T& value )
template <class T> void add_to_back( Node<T>* & head, const T& value )
template <class T> int remove_each( Node<T>* & head, const T& value )
template <class T> Node<T>* ordered_merge( Node<T>* head_of_list1, Node<T>* head_of_list2 )
#include <iostream>
using namespace std;
#include "llist.h"
int main()
{
Node<int> * head1 = 0; // list is initially empty
print_list( "LIST (should be empty):", head1 );
add_to_front( head1, 300 );
add_to_front( head1, 200 );
add_to_front( head1, 100 );
add_to_back( head1, 300 );
add_to_back( head1, 400 );
add_to_back( head1, 500 );
print_list( "LIST 1 (should be in sorted order):", head1 );
int n = remove_each( head1, 300 );
cout << "Removed " << n << " elements (should be 2)" << '\n';
print_list( "LIST 1 (should be 4 elements in sorted order):", head1 );
Node<int> * head2 = 0;
add_to_front( head2, 350 );
add_to_front( head2, 250 );
add_to_back( head2, 400 );
add_to_back( head2, 450 );
print_list( "LIST 2 (should be 4 elements in sorted order):", head2 );
Node<int> * head_sorted = ordered_merge( head1, head2 );
print_list( "LIST 3 (combined sorted order):", head_sorted );
remove_each( head1, 100 );
remove_each( head1, 200 );
remove_each( head1, 400 );
remove_each( head2, 250 );
remove_each( head2, 350 );
remove_each( head2, 450 );
print_list( "LIST 3 (should be same as above):", head_sorted );
return 0;
}
DUE: Tuesday 6/23 (by 11:59pm)
Once fully tested, submit your C++ source file(s) by zipping them up and emailing the ZIP (or tar) file to me.
Write an interactive hangman game with rules and specifications as described below.
computer giraffe CSCI-1200: data structures Sarah Palin for president! David Letterman for president! R2-D2 for president?
Here's the puzzle: _ _ _ _ - 1 2 0 0 : _ _ _ _ _ _ _ _ _ _ _ _ _ _
Here's the puzzle: _ _ _ _ - 1 2 0 0 : _ _ _ _ _ _ _ _ _ _ _ _ _ _ Guess a letter: t Good guess! _ _ _ _ - 1 2 0 0 : _ _ t _ _ t _ _ _ t _ _ _ _ guessed letters: t Guess a letter: k Sorry, no 'k' _ _ _ _ - 1 2 0 0 : _ _ t _ _ t _ _ _ t _ _ _ _ guessed letters: k t Guess a letter: c Good guess! c _ c _ - 1 2 0 0 : _ _ t _ _ t _ _ c t _ _ _ _ guessed letters: c k t ...
------- | | | O | --|-- | | | / \ | | =============