From 6ed00eb153b561fc898ef7f4a81100382c41e501 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Sat, 17 Feb 2024 00:34:11 -0500 Subject: [PATCH 01/45] no extra line --- hws/05_online_dating/user_722-686-8362_show_matches.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/hws/05_online_dating/user_722-686-8362_show_matches.txt b/hws/05_online_dating/user_722-686-8362_show_matches.txt index 42952e5..e652c04 100644 --- a/hws/05_online_dating/user_722-686-8362_show_matches.txt +++ b/hws/05_online_dating/user_722-686-8362_show_matches.txt @@ -11,4 +11,3 @@ University of California Prairie Andres 43 University of Montana - From d35f2a5777d538be6ecfc9d918ae29f4eb4e44ae Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 20 Feb 2024 01:47:23 -0500 Subject: [PATCH 02/45] updating checkpoint 3 --- labs/07_list_implementation/README.md | 22 ++- labs/07_list_implementation/checkpoint3.cpp | 176 +++++++++----------- 2 files changed, 101 insertions(+), 97 deletions(-) diff --git a/labs/07_list_implementation/README.md b/labs/07_list_implementation/README.md index 6a944a8..cb1c90f 100644 --- a/labs/07_list_implementation/README.md +++ b/labs/07_list_implementation/README.md @@ -36,7 +36,25 @@ Linked List of NodeB nodes: 1 -> 1.41421 -> 1.73205 -> 2 -> 2.23607 -> nullptr **To complete this checkpoint**, show a TA the implementation and the output of your program. -## Checkpoint 3: Debugging a Merge Sort program. +## Checkpoint 3: Merge Two Lists. +*estimate: 30-40 minutes* + +Given two doubly-linked lists: linked list A and linked list B, and both linked lists are sorted. Data in linked list A is sorted in an ascending order. Data in linked list B is also sorted in an ascending order. Merge these two lists such that the data in the merged list is still sorted in an ascending order. + +More specifically, complete the mergeLists() function in [checkpoint3.cpp](checkpoint3.cpp), such that the program prints the following output. + +```console +$ g++ checkpoint3.cpp +$ ./a.out +1 3 5 7 9 +2 4 6 8 10 +1 2 3 4 5 6 7 8 9 10 +10 9 8 7 6 5 4 3 2 1 +``` + +**To complete this checkpoint**, explain to a TA your implementation and show the output of your program. + + diff --git a/labs/07_list_implementation/checkpoint3.cpp b/labs/07_list_implementation/checkpoint3.cpp index 29177e4..2fc1e85 100644 --- a/labs/07_list_implementation/checkpoint3.cpp +++ b/labs/07_list_implementation/checkpoint3.cpp @@ -1,107 +1,93 @@ #include -#include -// prototype of the sorting function -std::vector sortVector(std::vector& nums); +template +class Node { +public: + T value; + Node* next; + Node* prev; -// function to print the elements of a vector -void printVector(const std::vector& nums) { - for (int num : nums) { - std::cout << num << " "; - } - std::cout << std::endl; + // constructor + Node(T val) : value(val), next(nullptr), prev(nullptr) {} +}; + +// function to merge two sorted doubly linked lists +template +Node* mergeLists(Node* head_A, Node* head_B) { } int main() { - // test case 1 - std::vector test1 = {5, 2, 9, 1, 5, 6}; - std::vector result1 = sortVector(test1); - std::cout << "Test Case 1: Original Vector: "; - printVector(test1); - std::cout << "Sorted Vector: "; - printVector(result1); + // create 5 nodes and link them to form a linked list, this is linked list A. + Node* head_A = new Node(1); + Node* second_A = new Node(3); + Node* third_A = new Node(5); + Node* fourth_A = new Node(7); + Node* fifth_A = new Node(9); + + // link the nodes + head_A->next = second_A; + second_A->prev = head_A; + second_A->next = third_A; + third_A->prev = second_A; + third_A->next = fourth_A; + fourth_A->prev = third_A; + fourth_A->next = fifth_A; + fifth_A->prev = fourth_A; + + // traverse linked list A and print the values + Node* current = head_A; + while (current != nullptr) { + std::cout << current->value << " "; + current = current->next; + } std::cout << std::endl; - // test case 2 - std::vector test2 = {3, 8, 2, 7, 4}; - std::vector result2 = sortVector(test2); - std::cout << "Test Case 2: Original Vector: "; - printVector(test2); - std::cout << "Sorted Vector: "; - printVector(result2); + // create 5 nodes and link them to form a linked list, this is linked list B. + Node* head_B = new Node(2); + Node* second_B = new Node(4); + Node* third_B = new Node(6); + Node* fourth_B = new Node(8); + Node* fifth_B = new Node(10); + + // link the nodes + head_B->next = second_B; + second_B->prev = head_B; + second_B->next = third_B; + third_B->prev = second_B; + third_B->next = fourth_B; + fourth_B->prev = third_B; + fourth_B->next = fifth_B; + fifth_B->prev = fourth_B; + + // traverse linked list B and print the values + current = head_B; + while (current != nullptr) { + std::cout << current->value << " "; + current = current->next; + } + std::cout << std::endl; + + Node* head_C; + Node* tail_C; + head_C = mergeLists(head_A, head_B); + + // traverse linked list C and print the values + current = head_C; + while (current != nullptr) { + std::cout << current->value << " "; + // keep tracking current and when current reaches nullptr, tail_C will be the tail node. + tail_C = current; + current = current->next; + } + std::cout << std::endl; + + // traverse linked list C backwards and print the values + current = tail_C; + while (current != nullptr) { + std::cout << current->value << " "; + current = current->prev; + } std::cout << std::endl; return 0; } - -// merge two vectors which are already sorted -std::vector& mergeVectors(std::vector& v1, std::vector& v2){ - int size1 = v1.size(); - int size2 = v2.size(); - std::vector v(size1+size2, 0); - int index1 = 0; - int index2 = 0; - int index = 0; - // traverse v1 and v2 at the same time - while(index1=size1){ - while(index2 sortVector(std::vector& nums) { - int size = nums.size(); - // base case - if(size==1){ - return nums; - } - // general case - // split the vector into two halves. - int mid = size/2; - - // nums1 to store the first half, and nums2 to store the second half. - std::vector nums1; - std::vector nums2; - - // copy the first half - for(int i=0;i Date: Tue, 20 Feb 2024 01:51:07 -0500 Subject: [PATCH 03/45] adding comments --- labs/07_list_implementation/README.md | 2 ++ labs/07_list_implementation/checkpoint3.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/labs/07_list_implementation/README.md b/labs/07_list_implementation/README.md index cb1c90f..ffe4198 100644 --- a/labs/07_list_implementation/README.md +++ b/labs/07_list_implementation/README.md @@ -54,6 +54,8 @@ $ ./a.out **To complete this checkpoint**, explain to a TA your implementation and show the output of your program. + + + + +- Stacks allow access, insertion and deletion from only one end called the top. + - There is no access to values in the middle of a stack. + - Stacks may be implemented efficiently in terms of vectors and lists, although vectors are preferable. + - All stack operations are O(1). + +## 14.5 Additional STL Container Classes: Queues + +- Queues allow insertion at one end, called the back and removal from the other end, called the front. + - There is no access to values in the middle of a queue. + - Queues may be implemented efficiently in terms of a list. Using vectors for queues is also possible, but requires more work to get right. + - All queue operations are O(1). + +## 14.6 Leetcode Exercises + +- [Leetcode problem 1451: Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence/). Solution: [p1451_rearrange_words_in_a_sentence.cpp](../../leetcode/p1451_rearrange_words_in_a_sentence.cpp). +- [Leetcode problem 508: Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum/). Solution: [p508_most_frequent_subtree_sum.cpp](../../leetcode/p508_most_frequent_subtree_sum.cpp). +- [Leetcode problem 225: Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues/). Solution: [p225_stack_using_queues.cpp](../../leetcode/p225_stack_using_queues.cpp). +- [Leetcode problem 232: Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/). Solution: [p232_queue_using_stacks.cpp](../../leetcode/p232_queue_using_stacks.cpp). +- [Leetcode problem 102: Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/). Solution: [p102_level_order_traversal.cpp](../../leetcode/p102_level_order_traversal.cpp). + - Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how the level order traversal works. + +- [Leetcode problem 20: Valid Parentheses](https://leetcode.com/problems/valid-parentheses/). Solution: [p20_valid_parentheses.cpp](../../leetcode/p20_valid_parentheses.cpp) From 43e57dd1b9f6c1028d9957f15dd929d77ff28f34 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 26 Feb 2024 18:58:08 -0500 Subject: [PATCH 13/45] removing other leetcode problems --- lectures/14_stacks_queues/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index c1814e9..a4c8f9d 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -145,11 +145,6 @@ functionality.--> ## 14.6 Leetcode Exercises -- [Leetcode problem 1451: Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence/). Solution: [p1451_rearrange_words_in_a_sentence.cpp](../../leetcode/p1451_rearrange_words_in_a_sentence.cpp). -- [Leetcode problem 508: Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum/). Solution: [p508_most_frequent_subtree_sum.cpp](../../leetcode/p508_most_frequent_subtree_sum.cpp). - [Leetcode problem 225: Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues/). Solution: [p225_stack_using_queues.cpp](../../leetcode/p225_stack_using_queues.cpp). - [Leetcode problem 232: Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/). Solution: [p232_queue_using_stacks.cpp](../../leetcode/p232_queue_using_stacks.cpp). -- [Leetcode problem 102: Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/). Solution: [p102_level_order_traversal.cpp](../../leetcode/p102_level_order_traversal.cpp). - - Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how the level order traversal works. - - [Leetcode problem 20: Valid Parentheses](https://leetcode.com/problems/valid-parentheses/). Solution: [p20_valid_parentheses.cpp](../../leetcode/p20_valid_parentheses.cpp) From eb8ea69c519f939943505e00b6f73c0d6dcbc5e7 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 12:27:14 -0500 Subject: [PATCH 14/45] adding functor example code --- lectures/14_stacks_queues/functor.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lectures/14_stacks_queues/functor.cpp diff --git a/lectures/14_stacks_queues/functor.cpp b/lectures/14_stacks_queues/functor.cpp new file mode 100644 index 0000000..25bddb5 --- /dev/null +++ b/lectures/14_stacks_queues/functor.cpp @@ -0,0 +1,17 @@ +#include + +class MyFunctor { +public: + int operator()(int x, int y) { + return x + y; + } +}; + +int main() { + MyFunctor myFunc; + int result = myFunc(3, 4); // This calls the overloaded () operator. + // result now holds the value 7. + std::cout << "result is " << result << std::endl; + return 0; +} + From 11ab1b87085a0d34d16d8fab7453b1a92c286c27 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 12:37:47 -0500 Subject: [PATCH 15/45] adding stack example --- lectures/14_stacks_queues/README.md | 44 +++++++++++++++++++++++++++++ lectures/14_stacks_queues/stack.cpp | 26 +++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 lectures/14_stacks_queues/stack.cpp diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index a4c8f9d..8ed0a9e 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -131,11 +131,55 @@ terms of operations. One way to obtain computational efficiency is to consider a functionality.--> +- A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. - Stacks allow access, insertion and deletion from only one end called the top. - There is no access to values in the middle of a stack. - Stacks may be implemented efficiently in terms of vectors and lists, although vectors are preferable. - All stack operations are O(1). +### 14.4.1 Basic Operations of a Stack: + +- push(const T& value): Adds an element value to the top of the stack. +- pop(): Removes the top element from the stack. +- top(): Returns a reference to the top element of the stack without removing it. +- empty(): Checks if the stack is empty. Returns true if the stack is empty, false otherwise. +- size(): Returns the number of elements in the stack. + +### 14.4.2 Stack Example Program + +- Following is an example program, remember to include the stack library. + +```cpp +#include +#include + +int main() { + std::stack myStack; + + myStack.push(10); + myStack.push(20); + myStack.push(30); + myStack.push(40); + myStack.push(50); + + std::cout << "Size of stack: " << myStack.size() << std::endl; + std::cout << "Top element: " << myStack.top() << std::endl; + + if (!myStack.empty()) { + std::cout << "Stack is not empty" << std::endl; + } else { + std::cout << "Stack is empty" << std::endl; + } + + myStack.pop(); + std::cout << "Top element after pop: " << myStack.top() << std::endl; + + return 0; +} +``` + +You can compile and run this above [program](stack.cpp). + ## 14.5 Additional STL Container Classes: Queues - Queues allow insertion at one end, called the back and removal from the other end, called the front. diff --git a/lectures/14_stacks_queues/stack.cpp b/lectures/14_stacks_queues/stack.cpp new file mode 100644 index 0000000..c8388f4 --- /dev/null +++ b/lectures/14_stacks_queues/stack.cpp @@ -0,0 +1,26 @@ +#include +#include + +int main() { + std::stack myStack; + + myStack.push(10); + myStack.push(20); + myStack.push(30); + myStack.push(40); + myStack.push(50); + + std::cout << "Size of stack: " << myStack.size() << std::endl; + std::cout << "Top element: " << myStack.top() << std::endl; + + if (!myStack.empty()) { + std::cout << "Stack is not empty" << std::endl; + } else { + std::cout << "Stack is empty" << std::endl; + } + + myStack.pop(); + std::cout << "Top element after pop: " << myStack.top() << std::endl; + + return 0; +} From 3ec0e2b9b811f6aea2d4ad838bd5e1abaa31b7e7 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 12:40:49 -0500 Subject: [PATCH 16/45] adding announcement --- lectures/14_stacks_queues/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 8ed0a9e..4ddc745 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -13,6 +13,11 @@ - Computers, cell-phones, smart watches, calculators, music players, etc. are not permitted. - Practice problems from previous tests are available on the [course materials](https://submitty.cs.rpi.edu/courses/s24/csci1200/course_materials) page on Submitty. +## Other Announcement + +- Resources will be dedicated to test grading and thus no office hours on Friday in test weeks. (week of test 1, week of test 2, week of test 3) +- Jidong's new office hours (effective after the spring break): Monday 2-4pm, Wednesday 1-3pm. + ## Today’s Lecture - Function Objects From 4b3fc146d5ce1c0788907473597c4ec40793dd33 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 12:59:31 -0500 Subject: [PATCH 17/45] adding the simplify path example --- lectures/14_stacks_queues/README.md | 48 ++++++++++++++++++++++++++++- lectures/14_stacks_queues/queue.cpp | 26 ++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 lectures/14_stacks_queues/queue.cpp diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 4ddc745..b9f9180 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -142,7 +142,7 @@ functionality.--> - Stacks may be implemented efficiently in terms of vectors and lists, although vectors are preferable. - All stack operations are O(1). -### 14.4.1 Basic Operations of a Stack: +### 14.4.1 Member functions of std::stack - push(const T& value): Adds an element value to the top of the stack. - pop(): Removes the top element from the stack. @@ -177,6 +177,7 @@ int main() { } myStack.pop(); + // What is the output of this next line? std::cout << "Top element after pop: " << myStack.top() << std::endl; return 0; @@ -187,13 +188,58 @@ You can compile and run this above [program](stack.cpp). ## 14.5 Additional STL Container Classes: Queues +- A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. - Queues allow insertion at one end, called the back and removal from the other end, called the front. - There is no access to values in the middle of a queue. - Queues may be implemented efficiently in terms of a list. Using vectors for queues is also possible, but requires more work to get right. - All queue operations are O(1). +### 14.5.1 Member functions of std::queue + +- push(const T& value): Adds an element value to the rear of the queue. This operation is also known as enqueue. +- pop(): Removes the front element from the queue. This operation is also known as dequeue. +- front(): Returns a reference to the front element of the queue without removing it. +- empty(): Checks if the queue is empty. Returns true if the queue is empty, false otherwise. +- size(): Returns the number of elements in the queue. + +### 14.5.2 Queue Example Program + +- Following is an example program, remember to include the queue library. + +```cpp +#include +#include + +int main() { + std::queue myQueue; + + myQueue.push(10); + myQueue.push(20); + myQueue.push(30); + myQueue.push(40); + myQueue.push(50); + + std::cout << "Size of queue: " << myQueue.size() << std::endl; + std::cout << "Front element: " << myQueue.front() << std::endl; + + if (!myQueue.empty()) { + std::cout << "Queue is not empty" << std::endl; + } else { + std::cout << "Queue is empty" << std::endl; + } + + myQueue.pop(); + std::cout << "Front element after pop: " << myQueue.front() << std::endl; + + return 0; +} +``` + +You can compile and run this above [program](queue.cpp). + ## 14.6 Leetcode Exercises - [Leetcode problem 225: Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues/). Solution: [p225_stack_using_queues.cpp](../../leetcode/p225_stack_using_queues.cpp). - [Leetcode problem 232: Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/). Solution: [p232_queue_using_stacks.cpp](../../leetcode/p232_queue_using_stacks.cpp). - [Leetcode problem 20: Valid Parentheses](https://leetcode.com/problems/valid-parentheses/). Solution: [p20_valid_parentheses.cpp](../../leetcode/p20_valid_parentheses.cpp) +- [Leetcode problem 71: Simplify Path](https://leetcode.com/problems/simplify-path/). Solution: [p71_simplify_path.cpp](../../leetcode/p71_simplify_path.cpp) diff --git a/lectures/14_stacks_queues/queue.cpp b/lectures/14_stacks_queues/queue.cpp new file mode 100644 index 0000000..a33932d --- /dev/null +++ b/lectures/14_stacks_queues/queue.cpp @@ -0,0 +1,26 @@ +#include +#include + +int main() { + std::queue myQueue; + + myQueue.push(10); + myQueue.push(20); + myQueue.push(30); + myQueue.push(40); + myQueue.push(50); + + std::cout << "Size of queue: " << myQueue.size() << std::endl; + std::cout << "Front element: " << myQueue.front() << std::endl; + + if (!myQueue.empty()) { + std::cout << "Queue is not empty" << std::endl; + } else { + std::cout << "Queue is empty" << std::endl; + } + + myQueue.pop(); + std::cout << "Front element after pop: " << myQueue.front() << std::endl; + + return 0; +} From b85a833952c4d90b1c8a52481e7b36d550a69f1f Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 13:06:24 -0500 Subject: [PATCH 18/45] re-formatting --- lectures/14_stacks_queues/README.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index b9f9180..2da3d09 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -49,18 +49,23 @@ the less than comparison function for the type stored inside the container. How ```cpp bool float_less(float x, float y) { -return x < y; + return x < y; } ``` -- Remember how we can sort the my_data vector defined above using our own homemade comparison function -for sorting: +- And then let's define a vector called *my_data*: + +```cpp +std::vector my_data = {1.1, 2.2, 3.3, 4.4, 5.5}; +``` + +- Remember how we can sort the my_data vector defined above using our own homemade comparison function for sorting: ```cpp std::sort(my_data.begin(),my_data.end(),float_less); ``` -If we don’t specify a 3rd argument: +If we don't specify a 3rd argument: ```cpp std::sort(my_data.begin(),my_data.end()); @@ -81,7 +86,9 @@ of that class. Then, that instance/object can be used like it’s a function. We template class less { public: -bool operator() (const T& x, const T& y) const { return x < y; } + bool operator() (const T& x, const T& y) const { + return x < y; + } }; ``` @@ -97,10 +104,12 @@ during computation of the function call operator! For example: ```cpp class between_values { private: -float low, high; + float low, high; public: -between_values(float l, float h) : low(l), high(h) {} -bool operator() (float val) { return low <= val && val <= high; } + between_values(float l, float h) : low(l), high(h) {} + bool operator() (float val) { + return (low <= val && val <= high); + } }; ``` @@ -116,6 +125,7 @@ if (std::find_if(my_data.begin(), my_data.end(), two_and_four) != my_data.end()) std::cout << "Found a value greater than 2 & less than 4!" << std::endl; } ``` + Alternatively, we could create the functor without giving it a variable name. And in the use below we also capture the return value to print out the first item in the vector inside this range. Note that it does not print all values in the range. From 390fabf1f17ceebc03a381f0878ed6e2c232646e Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 13:19:01 -0500 Subject: [PATCH 19/45] adding the multiply example --- lectures/14_stacks_queues/README.md | 57 +++++++++++--------------- lectures/14_stacks_queues/multiply.cpp | 26 ++++++++++++ 2 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 lectures/14_stacks_queues/multiply.cpp diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 2da3d09..81a69e3 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -39,7 +39,7 @@ public: }; ``` -- See and run this simple functor [example](functor.cpp). +- Compile and run this simple functor [example](functor.cpp). ## 14.2 Why are Functors Useful? @@ -59,7 +59,7 @@ bool float_less(float x, float y) { std::vector my_data = {1.1, 2.2, 3.3, 4.4, 5.5}; ``` -- Remember how we can sort the my_data vector defined above using our own homemade comparison function for sorting: +- Remember how we can sort the *my_data* vector defined above using our own homemade comparison function for sorting: ```cpp std::sort(my_data.begin(),my_data.end(),float_less); @@ -96,48 +96,38 @@ public: example float) that returns a bool. That’s exactly what we need for std::sort! This ultimately does the same thing as our tiny helper homemade compare function! -## 14.3 Another more Complicated Functor Example - -Constructors of function objects can be used to specify internal data for the functor that can then be used -during computation of the function call operator! For example: +## 14.3 Another Functor Example ```cpp -class between_values { +#include + +// functor class +class MultiplyBy { private: - float low, high; + int factor; + public: - between_values(float l, float h) : low(l), high(h) {} - bool operator() (float val) { - return (low <= val && val <= high); + // constructor + MultiplyBy(int factor) : factor(factor) {} + + // overloaded function call operator + int operator()(int x) const { + return x * factor; } }; -``` -- The range between low & high is specified when a functor/an instance of this class is created. We might -have multiple different instances of the between_values functor, each with their own range. Later, when the -functor is used, the query value will be passed in as an argument. The function call operator accepts that -single argument val and compares against the internal data low & high. -- This can be used in combination with STL’s find_if construct. For example: +int main() { + // create an instance of the functor + MultiplyBy multiplyByTwo(2); -```cpp -between_values two_and_four(2,4); -if (std::find_if(my_data.begin(), my_data.end(), two_and_four) != my_data.end()) { - std::cout << "Found a value greater than 2 & less than 4!" << std::endl; + // use the functor as a function + std::cout << "Result of multiplying 5 by 2: " << multiplyByTwo(5) << std::endl; + + return 0; } ``` - Alternatively, we could create the functor without giving it a variable name. And in the use below we also -capture the return value to print out the first item in the vector inside this range. Note that it does not print -all values in the range. - -```cpp -std::vector::iterator itr; -itr = std::find_if(my_data.begin(), my_data.end(), between_values(2,4)); -if (itr != my_data.end()) { - std::cout << "my_data contains " << *itr - << ", a value greater than 2 & less than 4!" << std::endl; -} -``` +- You can compile and run this [example](multiply.cpp). ## 14.4 Additional STL Container Classes: Stacks @@ -239,6 +229,7 @@ int main() { } myQueue.pop(); + // What is the output of this next line? std::cout << "Front element after pop: " << myQueue.front() << std::endl; return 0; diff --git a/lectures/14_stacks_queues/multiply.cpp b/lectures/14_stacks_queues/multiply.cpp new file mode 100644 index 0000000..3bb1886 --- /dev/null +++ b/lectures/14_stacks_queues/multiply.cpp @@ -0,0 +1,26 @@ +#include + +// functor class +class MultiplyBy { +private: + int factor; + +public: + // constructor + MultiplyBy(int factor) : factor(factor) {} + + // overloaded function call operator + int operator()(int x) const { + return x * factor; + } +}; + +int main() { + // create an instance of the functor + MultiplyBy multiplyByTwo(2); + + // use the functor as a function + std::cout << "Result of multiplying 5 by 2: " << multiplyByTwo(5) << std::endl; + + return 0; +} From 70ad23a4d95b1c8bea887e61f80188eee5e8d1e5 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 13:21:20 -0500 Subject: [PATCH 20/45] adding one line of comment --- lectures/14_stacks_queues/README.md | 1 + lectures/14_stacks_queues/multiply.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 81a69e3..1b71a20 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -121,6 +121,7 @@ int main() { MultiplyBy multiplyByTwo(2); // use the functor as a function + // surprising: the object itself can be used like it's a function. std::cout << "Result of multiplying 5 by 2: " << multiplyByTwo(5) << std::endl; return 0; diff --git a/lectures/14_stacks_queues/multiply.cpp b/lectures/14_stacks_queues/multiply.cpp index 3bb1886..a9c0198 100644 --- a/lectures/14_stacks_queues/multiply.cpp +++ b/lectures/14_stacks_queues/multiply.cpp @@ -20,6 +20,7 @@ int main() { MultiplyBy multiplyByTwo(2); // use the functor as a function + // surprising: the object itself can be used like it's a function. std::cout << "Result of multiplying 5 by 2: " << multiplyByTwo(5) << std::endl; return 0; From 795b222c885bca4290aba518fd180d4a3dd86cca Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 13:40:32 -0500 Subject: [PATCH 21/45] adding the special constructor syntax example --- lectures/14_stacks_queues/README.md | 34 +++++++++++++++++++++++ lectures/14_stacks_queues/constructor.cpp | 32 +++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 lectures/14_stacks_queues/constructor.cpp diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 1b71a20..05da53f 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -23,6 +23,40 @@ - Function Objects - STL Queue and STL Stack +## 14.0 Some Special Syntax + +The following program demonstrates some special syntax about C++ constructors. + +```cpp +#include + +// custom class definition +class MyClass { +public: + // constructor + MyClass() { + std::cout << "Constructor called" << std::endl; + } + + // destructor + ~MyClass() { + std::cout << "Destructor called" << std::endl; + } +}; + +int main() { + MyClass(); + + MyClass A; + MyClass B; + return 0; +} +``` + +What is the output of this program? + +You can compile and run the [program](constructor.cpp). + ## 14.1 Function Objects, a.k.a. Functors - In addition to the basic mathematical operators + - * / < > , another operator we can overload for our C++ diff --git a/lectures/14_stacks_queues/constructor.cpp b/lectures/14_stacks_queues/constructor.cpp new file mode 100644 index 0000000..f9685bc --- /dev/null +++ b/lectures/14_stacks_queues/constructor.cpp @@ -0,0 +1,32 @@ +#include + +// custom class definition +class MyClass { +public: + // constructor + MyClass() { + std::cout << "Constructor called" << std::endl; + } + + // destructor + ~MyClass() { + std::cout << "Destructor called" << std::endl; + } +}; + +int main() { + /* creating a temporary object using constructor syntax. + It creates a temporary object that gets destructed immediately. + Why? Because this line creates a temporary object of type MyClass using the constructor syntax, + but it does not associate the temporary object with any variable. + This temporary object is constructed and immediately destroyed in the same line of code, + as it is not stored in any variable. + This is often used when you need to perform a one-time action using a constructor without storing the object for later use. + */ + MyClass(); + + MyClass A; + MyClass B; + return 0; +} + From a593dd557f8e2980b055c7f6e51c98b711f02717 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 27 Feb 2024 13:52:40 -0500 Subject: [PATCH 22/45] adding notes about hw6 --- lectures/14_stacks_queues/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lectures/14_stacks_queues/README.md b/lectures/14_stacks_queues/README.md index 05da53f..1921803 100644 --- a/lectures/14_stacks_queues/README.md +++ b/lectures/14_stacks_queues/README.md @@ -4,7 +4,7 @@ - Test 2 will be held Thursday, February 29th, 2024 from 6-7:50pm. - No make-ups will be given except for pre-approved absence or illness, and a written excuse from the Dean of Students or the Student Experience office or the RPI Health Center will be required. - - If you have a letter from Disability Services for Students and you have not already emailed it to ds_instructors@cs.rpi.edu, please do so ASAP. Shianne Hulbert will be in contact with you about your accommodations for the test. + - If you have a letter from Disability Services for Students and you have not already emailed it to ds_instructors@cs.rpi.edu, please do so ASAP. Shianne Hulbert will be in contact with you about your accommodations for the test. And you will go to Lally 102 for the test. - Student’s assigned test room, row, and seat assignments will be re-randomized. If you don’t have a seating assignment when you log onto Submitty, let us know via the ds_instructors list. - Coverage: Lectures 1-14, Labs 1-7, HW 1-5. - OPTIONAL: you are allowed to bring two physical pieces of 8.5x11” paper, that’s four “sides”. We will check at the start of the exam that you do not have more than two pieces of paper for your notes! @@ -13,10 +13,11 @@ - Computers, cell-phones, smart watches, calculators, music players, etc. are not permitted. - Practice problems from previous tests are available on the [course materials](https://submitty.cs.rpi.edu/courses/s24/csci1200/course_materials) page on Submitty. -## Other Announcement +## Other Announcements - Resources will be dedicated to test grading and thus no office hours on Friday in test weeks. (week of test 1, week of test 2, week of test 3) - Jidong's new office hours (effective after the spring break): Monday 2-4pm, Wednesday 1-3pm. +- HW6 will be ready on Thursday night 10pm. Only 10 students passed all test cases last semester. Not just because it's hard, it's just that submitty will stop your program if it runs too long. In order to pass some of the tricky test cases, your program must be fast enough. ## Today’s Lecture From 8ca27d380cddb49ce05f7e4c0cce43b27d48d9c1 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 20:53:22 -0500 Subject: [PATCH 23/45] adding hw6 --- .../06_inverse_word_search/README.md | 20 ++++++++++-------- .../06_inverse_word_search/README.txt | 0 .../06_inverse_word_search/example1.png | Bin .../06_inverse_word_search/example2.png | Bin .../06_inverse_word_search/out1.txt | 0 .../06_inverse_word_search/out1_onesol.txt | 0 .../06_inverse_word_search/out2.txt | 0 .../06_inverse_word_search/out3.txt | 0 .../06_inverse_word_search/out4.txt | 0 .../06_inverse_word_search/out5.txt | 0 .../06_inverse_word_search/out6.txt | 0 .../06_inverse_word_search/out7.txt | 0 .../06_inverse_word_search/out8.txt | 0 .../06_inverse_word_search/puzzle1.txt | 0 .../06_inverse_word_search/puzzle2.txt | 0 .../06_inverse_word_search/puzzle3.txt | 0 .../06_inverse_word_search/puzzle4.txt | 0 .../06_inverse_word_search/puzzle5.txt | 0 .../06_inverse_word_search/puzzle6.txt | 0 .../06_inverse_word_search/puzzle7.txt | 0 .../06_inverse_word_search/puzzle8.txt | 0 21 files changed, 11 insertions(+), 9 deletions(-) rename {old_hws => hws}/06_inverse_word_search/README.md (89%) rename {old_hws => hws}/06_inverse_word_search/README.txt (100%) rename {old_hws => hws}/06_inverse_word_search/example1.png (100%) rename {old_hws => hws}/06_inverse_word_search/example2.png (100%) rename {old_hws => hws}/06_inverse_word_search/out1.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out1_onesol.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out2.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out3.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out4.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out5.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out6.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out7.txt (100%) rename {old_hws => hws}/06_inverse_word_search/out8.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle1.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle2.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle3.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle4.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle5.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle6.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle7.txt (100%) rename {old_hws => hws}/06_inverse_word_search/puzzle8.txt (100%) diff --git a/old_hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md similarity index 89% rename from old_hws/06_inverse_word_search/README.md rename to hws/06_inverse_word_search/README.md index 61c8fac..b32f1f6 100644 --- a/old_hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -53,10 +53,10 @@ of finding and outputting one legal solution to the puzzle (if one exists). ## Algorithm Analysis For larger, more complex examples, this is a really hard problem. Your program should be able to handle -the small puzzles we have created in a reasonable amount of time. You should make up your own test cases +the small puzzles we have created in a reasonable amount of time. The UNIX/WSL time command can be prepended to your command line to estimate the running time: ```console @@ -74,18 +74,19 @@ ok if your program can’t solve the biggest puzzles in a reasonable amount of t ## Program Requirements & Submission Details Use good coding style when you design and implement your program. Organize your program into functions: -don’t put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget +don’t put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget to comment your code! Use the provided template [README.txt](./README.txt) file for notes you want the grader to read. -You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. +You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. -**Due Date**: 10/26/2023, Thursday, 23:59pm. +**Due Date**: 03/14/2024, Thursday, 10pm. ## Rubric -22 pts - - README.txt Completed (2 pts) +20 pts + - README.txt Completed (3 pts) - One of name, collaborators, or hours not filled in. (-1) - Two or more of name, collaborators, or hours not filled in. (-2) + - No reflection. (-1) - LETTER GRID REPRESENTATION (2 pts) - Grid is not represented via nested structure vector<vector<char>>, vector<vector<string>>, vector<string>, char\*\*, etc. (-1) - Lookup of a position is not O(1), uses something like<list<char>> which has lookup of O(n). (-1) @@ -104,17 +105,18 @@ You must do this assignment on your own, as described in the [Collaboration Poli - Did not finish but provides a reasonable analysis with respect to a theoretical implementation and properly justifies it. (-2) - Did not finish but provides a runtime and some small analysis for a theoretical solution. (-4) - Correct order notation for a largely incomplete implementation. (-4) - - TESTING SUMMARY & NEW TEST CASES (Included with submission and discussed in README.txt) (3 pts) + - PROGRAM STRUCTURE (6 pts) - Putting almost everything in the main function. It's better to create separate functions for different tasks. (-2) - Function bodies containing more than one statement are placed in the .h file. (okay for templated classes) (-2) - Missing include guards in the .h file. (Or does not declare them correctly) (-1) - Functions are not well documented or are poorly commented, in either the .h or the .cpp file. (-1) - Improper uses or omissions of const and reference. (-1) + - At least one function is excessively long (i.e., more than 200 lines). (-1) - Overly cramped, excessive whitespace, or poor indentation. (-1) - Poor file organization: Puts more than one class in a file (okay for very small helper classes) (-1) - Poor variable names. (-1) diff --git a/old_hws/06_inverse_word_search/README.txt b/hws/06_inverse_word_search/README.txt similarity index 100% rename from old_hws/06_inverse_word_search/README.txt rename to hws/06_inverse_word_search/README.txt diff --git a/old_hws/06_inverse_word_search/example1.png b/hws/06_inverse_word_search/example1.png similarity index 100% rename from old_hws/06_inverse_word_search/example1.png rename to hws/06_inverse_word_search/example1.png diff --git a/old_hws/06_inverse_word_search/example2.png b/hws/06_inverse_word_search/example2.png similarity index 100% rename from old_hws/06_inverse_word_search/example2.png rename to hws/06_inverse_word_search/example2.png diff --git a/old_hws/06_inverse_word_search/out1.txt b/hws/06_inverse_word_search/out1.txt similarity index 100% rename from old_hws/06_inverse_word_search/out1.txt rename to hws/06_inverse_word_search/out1.txt diff --git a/old_hws/06_inverse_word_search/out1_onesol.txt b/hws/06_inverse_word_search/out1_onesol.txt similarity index 100% rename from old_hws/06_inverse_word_search/out1_onesol.txt rename to hws/06_inverse_word_search/out1_onesol.txt diff --git a/old_hws/06_inverse_word_search/out2.txt b/hws/06_inverse_word_search/out2.txt similarity index 100% rename from old_hws/06_inverse_word_search/out2.txt rename to hws/06_inverse_word_search/out2.txt diff --git a/old_hws/06_inverse_word_search/out3.txt b/hws/06_inverse_word_search/out3.txt similarity index 100% rename from old_hws/06_inverse_word_search/out3.txt rename to hws/06_inverse_word_search/out3.txt diff --git a/old_hws/06_inverse_word_search/out4.txt b/hws/06_inverse_word_search/out4.txt similarity index 100% rename from old_hws/06_inverse_word_search/out4.txt rename to hws/06_inverse_word_search/out4.txt diff --git a/old_hws/06_inverse_word_search/out5.txt b/hws/06_inverse_word_search/out5.txt similarity index 100% rename from old_hws/06_inverse_word_search/out5.txt rename to hws/06_inverse_word_search/out5.txt diff --git a/old_hws/06_inverse_word_search/out6.txt b/hws/06_inverse_word_search/out6.txt similarity index 100% rename from old_hws/06_inverse_word_search/out6.txt rename to hws/06_inverse_word_search/out6.txt diff --git a/old_hws/06_inverse_word_search/out7.txt b/hws/06_inverse_word_search/out7.txt similarity index 100% rename from old_hws/06_inverse_word_search/out7.txt rename to hws/06_inverse_word_search/out7.txt diff --git a/old_hws/06_inverse_word_search/out8.txt b/hws/06_inverse_word_search/out8.txt similarity index 100% rename from old_hws/06_inverse_word_search/out8.txt rename to hws/06_inverse_word_search/out8.txt diff --git a/old_hws/06_inverse_word_search/puzzle1.txt b/hws/06_inverse_word_search/puzzle1.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle1.txt rename to hws/06_inverse_word_search/puzzle1.txt diff --git a/old_hws/06_inverse_word_search/puzzle2.txt b/hws/06_inverse_word_search/puzzle2.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle2.txt rename to hws/06_inverse_word_search/puzzle2.txt diff --git a/old_hws/06_inverse_word_search/puzzle3.txt b/hws/06_inverse_word_search/puzzle3.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle3.txt rename to hws/06_inverse_word_search/puzzle3.txt diff --git a/old_hws/06_inverse_word_search/puzzle4.txt b/hws/06_inverse_word_search/puzzle4.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle4.txt rename to hws/06_inverse_word_search/puzzle4.txt diff --git a/old_hws/06_inverse_word_search/puzzle5.txt b/hws/06_inverse_word_search/puzzle5.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle5.txt rename to hws/06_inverse_word_search/puzzle5.txt diff --git a/old_hws/06_inverse_word_search/puzzle6.txt b/hws/06_inverse_word_search/puzzle6.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle6.txt rename to hws/06_inverse_word_search/puzzle6.txt diff --git a/old_hws/06_inverse_word_search/puzzle7.txt b/hws/06_inverse_word_search/puzzle7.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle7.txt rename to hws/06_inverse_word_search/puzzle7.txt diff --git a/old_hws/06_inverse_word_search/puzzle8.txt b/hws/06_inverse_word_search/puzzle8.txt similarity index 100% rename from old_hws/06_inverse_word_search/puzzle8.txt rename to hws/06_inverse_word_search/puzzle8.txt From d95c1fe0a63299d43ca6334b3ea71ae13b534963 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 20:57:56 -0500 Subject: [PATCH 24/45] adding readme --- hws/06_inverse_word_search/README.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hws/06_inverse_word_search/README.txt b/hws/06_inverse_word_search/README.txt index 467d55f..3422b88 100644 --- a/hws/06_inverse_word_search/README.txt +++ b/hws/06_inverse_word_search/README.txt @@ -23,15 +23,21 @@ What's the order notation of your algorithm? -TEST CASE SUMMARY: -How did your program perform on the different test cases? Summarize -the running times. (It's ok if it didn't finish the harder examples.) -What new test cases did you create and how did it perform on those -tests? - MISC. COMMENTS TO GRADER: Optional, please be concise! + +## Reflection and Self Assessment + +Discuss the issues you encountered during development and testing. What +problems did you have? What did you have to research and learn on your +own? What kinds of errors did you get? How did you fix them? + +What parts of the assignment did you find challenging? Is there anything that +finally "clicked" for you in the process of working on this assignment? How well +did the development and testing process go for you? + +< insert reflection > From d7e45d220be6de34c7d4fa1b42cc48b1d3230df5 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 21:03:25 -0500 Subject: [PATCH 25/45] revising readme --- hws/06_inverse_word_search/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md index b32f1f6..007d781 100644 --- a/hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -67,9 +67,9 @@ Once you have finished your implementation and testing, analyze the performance order notation. What important variables control the complexity of a particular problem? The width & height of the grid (w and h), the number of required words (r), the number of forbidden words (f), the number of letters in each word (l), the number of solutions (s)? In your plain text README.txt file, write -a concise paragraph (< 200 words) justifying your answer. Also include a simple table summarizing the +a concise paragraph (< 200 words) justifying your answer. ## Program Requirements & Submission Details From 9fbe7f0e380937d1d583d4bc8e6b85a201153489 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 21:16:06 -0500 Subject: [PATCH 26/45] adding the notes --- hws/06_inverse_word_search/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md index 007d781..198cefc 100644 --- a/hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -1,3 +1,6 @@ +**Special Note 1: For this assignment, we will not deduct points if you use data structures which have not been learned in this class.** +**Special Note 2: A correct program does not necessarily pass all the test cases for this assignment, as Submitty may let you fail a test case if your program is not fast enough or consumes too much memory.** + # Homework 6 — Inverse Word Search Recursion In this homework we will build an inverse word search program using the techniques of recursion. @@ -47,7 +50,7 @@ solution, your program should just output the first legal solution it finds (it number of solutions, nor does it need to be the first solution shown in our output). If the puzzle is impossible your program should output “No solutions found”. -To implement this assignment, you must use recursion in your search. First you should tackle the problem +**To implement this assignment, you must use recursion in your search.** First you should tackle the problem of finding and outputting one legal solution to the puzzle (if one exists). ## Algorithm Analysis From 40aeed316a8ac4938e522d445d539293f864954c Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 21:22:16 -0500 Subject: [PATCH 27/45] line break --- hws/06_inverse_word_search/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md index 198cefc..ce3ec1b 100644 --- a/hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -1,4 +1,5 @@ **Special Note 1: For this assignment, we will not deduct points if you use data structures which have not been learned in this class.** + **Special Note 2: A correct program does not necessarily pass all the test cases for this assignment, as Submitty may let you fail a test case if your program is not fast enough or consumes too much memory.** # Homework 6 — Inverse Word Search Recursion From eba29b1de4403fa012806637b8d3fdbb13c99c68 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 29 Feb 2024 22:34:49 -0500 Subject: [PATCH 28/45] rearrange the notes --- hws/06_inverse_word_search/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md index ce3ec1b..49be37a 100644 --- a/hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -1,6 +1,5 @@ -**Special Note 1: For this assignment, we will not deduct points if you use data structures which have not been learned in this class.** - -**Special Note 2: A correct program does not necessarily pass all the test cases for this assignment, as Submitty may let you fail a test case if your program is not fast enough or consumes too much memory.** +**Special Note 1: A correct program does not necessarily pass all the test cases for this assignment, as Submitty may let you fail a test case if your program is not fast enough or consumes too much memory.** +**Special Note 2: For this assignment, we will not deduct points if you use data structures which have not been learned in this class. However, students who passed all test cases last semester did not use any of such data structures. In other words, using only data structures we have learned so far, is sufficient to pass all test cases.** # Homework 6 — Inverse Word Search Recursion From 0f520ed3ebf33226b56daefbd0c5a566189e4ba3 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 1 Mar 2024 13:29:35 -0500 Subject: [PATCH 29/45] editing 15 notes --- lectures/15_maps_I/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lectures/15_maps_I/README.md b/lectures/15_maps_I/README.md index 7b3cf64..eee79de 100644 --- a/lectures/15_maps_I/README.md +++ b/lectures/15_maps_I/README.md @@ -69,8 +69,7 @@ changed. It can only be erased (together with the associated value). The mechanics of using std::pairs are relatively straightforward: - std::pairs are a templated struct with just two members, called first and second. Reminder: a struct -is basically a wimpy class and in this course you aren’t allowed to create new structs. You should use classes -instead. +is basically a wimpy class. - To work with pairs, you must #include <utility>. Note that the header file for maps (#include <map>) itself includes utility, so you don’t have to include utility explicitly when you use pairs with maps. - Here are simple examples of manipulating pairs: @@ -87,7 +86,7 @@ p3.second = -1.5; // p3.first = std::string("illegal"); // (a) // p1 = p3; // (b) ``` -- The function std::make pair creates a pair object from the given values. It is really just a simplified +- The function std::make_pair creates a pair object from the given values. It is really just a simplified constructor, and as the example shows there are other ways of constructing pairs. - Most of the statements in the above code show accessing and changing values in pairs. The two statements at the end are commented out because they cause syntax errors: From 85e76a58429d78fb6e9345b89c8124d65d136625 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 1 Mar 2024 13:52:31 -0500 Subject: [PATCH 30/45] adding hw6 discussion --- hws/discussions/inverse_word_search.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 hws/discussions/inverse_word_search.txt diff --git a/hws/discussions/inverse_word_search.txt b/hws/discussions/inverse_word_search.txt new file mode 100644 index 0000000..a7af7f9 --- /dev/null +++ b/hws/discussions/inverse_word_search.txt @@ -0,0 +1,13 @@ +In-class discussion (This discussion only focus on the basic logic of the program; optimization is not the scope of this discussion) + +Discuss the following questions with students around you. + +1. What data structure is good to represent one solution? What data structure is good to represent all solutions? +2. Do we need to initialize the board(s)? +3. What shall we do in the main function? + +4. Do we need to track where exactly (in the board) a word is inserted? +5. Do we need to track if one location is occupied or not? +6. Do we need to track if a location is shared by multiple words or not? + +7. In the word search program we have discuss before relevant to this assignment? Can we use some of the logic from that program? From 015783b25b4dfeb6a08ce708117d4dd32716902e Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 1 Mar 2024 17:13:17 -0500 Subject: [PATCH 31/45] fixing typo --- hws/discussions/inverse_word_search.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hws/discussions/inverse_word_search.txt b/hws/discussions/inverse_word_search.txt index a7af7f9..bd223ac 100644 --- a/hws/discussions/inverse_word_search.txt +++ b/hws/discussions/inverse_word_search.txt @@ -10,4 +10,4 @@ Discuss the following questions with students around you. 5. Do we need to track if one location is occupied or not? 6. Do we need to track if a location is shared by multiple words or not? -7. In the word search program we have discuss before relevant to this assignment? Can we use some of the logic from that program? +7. Is the word search program we have discussed before relevant to this assignment? Can we use some of the logic from that program? From 9573ea22982ca8a60f69839bf9320c919521c67d Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Sat, 9 Mar 2024 20:35:37 -0500 Subject: [PATCH 32/45] remove the global variables restriction --- hws/06_inverse_word_search/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/hws/06_inverse_word_search/README.md b/hws/06_inverse_word_search/README.md index 49be37a..a0cd137 100644 --- a/hws/06_inverse_word_search/README.md +++ b/hws/06_inverse_word_search/README.md @@ -123,5 +123,4 @@ You must do this assignment on your own, as described in the [Collaboration Poli - Overly cramped, excessive whitespace, or poor indentation. (-1) - Poor file organization: Puts more than one class in a file (okay for very small helper classes) (-1) - Poor variable names. (-1) - - Use of global variables. (-1) - Contains useless comments like commented-out code, terminal commands, or silly notes. (-1) From 574f865f56ee837a16382abd94ca688c2278348c Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 11 Mar 2024 00:56:50 -0400 Subject: [PATCH 33/45] updating hw7 readme --- old_hws/07_search_engine/README.md | 152 +++++++++++++++++++--------- old_hws/07_search_engine/README.txt | 13 +++ 2 files changed, 116 insertions(+), 49 deletions(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index e4ac86e..9d92cf2 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -1,9 +1,7 @@ -## Clarification + # Homework 7 — Design and Implementation of a Simple Google @@ -61,7 +59,7 @@ Based on the above description, you can see there are 3 steps when implementing 2. query searching 3. page ranking -And thus, in this assignment, you are recommended to write your search engine following this same order of 3 steps (the reason this is just a recommendation, rather than a requirement, is because one mentor told us that she can produce all the results in the web crawling stage, and she doesn't need 3 steps). More details about each of these 3 steps are described below: +And thus, in this assignment, you are recommended to (but not required to) write your search engine following this same order of 3 steps. More details about each of these 3 steps are described below: ### Web Crawling @@ -131,6 +129,12 @@ Once we get the density score for the keyword *Tom* in the first document (let's #### Backlinks Score +There are typically two types of links on the Internet. + +1. **Outgoing Links**: These are links from a particular webpage on your website to other webpages or websites. Outgoing links are also known as "outbound links". They provide navigation from your webpage to other relevant resources on the internet. + +2. **Incoming Backlinks**: These are links from other websites or webpages that direct users to a specific webpage on your website. Incoming backlinks are also commonly referred to as "inbound links" or simply "backlinks". Search engines like Google consider incoming backlinks as an important factor when determining the authority, relevance, and popularity of a webpage. Pages with a higher number of quality backlinks are often perceived as more authoritative and are likely to rank higher in search engine results pages. + A backlinks score for a webpage is based on the importance of its incoming backlinks, considering that pages with fewer outgoing links are considered more valuable and contribute more to the score. Let's say there are N web pages which have links pointing to this current page. We name these pages doc_1, doc_2,... to doc_N, and we use doc_i->outgoingLinks to denote how many outgoing links document i has. Then we can calculate the backlinks score of this current page as following: @@ -144,39 +148,11 @@ Once you have both the keywords density score and the backlinks score, you can t To reduce the scope of the assignment, and hence reduce the amount of work from you, we make the following rules for this search engine. -### Rule 1. Case-sensitive Search Engine - -Search engines are usually case-insensitive, but making the search engine case-insensitive will require some extra work and likely need to call some functions we have not learned in this course. Therefore, to simplify your tasks and reduce the amount of your work, in this assignment, the search engine you are going to implement is case-sensitive. - - - -### Rule 2. Search HTML Files Only +### Rule 1. Search HTML Files Only Search Engines like Google will search all types of files on the Internet, but in this assignment, we assume all files we search are HTML files. And we consider an HTML file contains the search query only if the search query can be found within the <body> section of the HTML file. The <body> section, enclosed within the <body></body> tags in an HTML document, represents the primary content area of the web page. -Based on Rule 1 and Rule 2: when the search query is *Tom Cruise*, the second page showed in this image should not be included in your search results, unless the words *Tom Cruise* appears in the other part of the <body></body> section of this web page, which is not displayed here. - -![alt text](images/tom_cruise.png "tom cruise") - -But wait, we see *Tom Cruise* here: - -![alt text](images/tom_cruise_description.png "tom cruise description") - -That's true, but this line is not in the <body> section of the HTML file, it is created via a meta description tag which is in the <head> section of the HTML file. We will have more details on this in [a later section](#the-description) in this README. - -The same thing for this line: - -![alt text](images/tom_cruise_title.png "tom cruise title") - -this line is not in the <body> section of the HTML file, rather, it is created via a title tag which is in the <head> section of the HTML file. More details on this in [a later section](#the-title) in this README. - -### Rule 3. Search Query: No More Than 3 Words - -We also limit the user to search no more than 3 words in each query. Based on this rule, we allow users to search *Tom*, *Tom Cruise*, *Tom and Jerry*, but *Tom Hanks Academy Award* is not allowed, as it contains more than 3 words. - -### Rule 4. Local Searching Only +### Rule 2. Local Searching Only The search engine you implement will not search anything on the Internet, as that requires extensive knowledge in computer networks and will need to include network libraries, which is way beyond the scope of this course. In this assignment, we limit our searches to a local folder, which is provided as [html_files](html_files). @@ -187,18 +163,26 @@ You are also not allowed to use file system libraries such as <filesystem> Your program will be run like this: ```console -nysearch.exe html_files/index.html output.txt Tom -nysearch.exe html_files/index.html output.txt Tom Cruise -nysearch.exe html_files/index.html output.txt Tom and Jerry -nysearch.exe html_files/index.html output.txt "Tom Cruise" +nysearch.exe html_files/index.html input.txt ``` Here: - *nysearch.exe* is the executable file name. - html_files/index.html is the Seed URL. While Google maintains a list of Seed URL, in this assignment, we will just use one single HTML file as the Seed page and the path of this file is the Seed URL. -- output.txt is where to print your output to. -- *Tom* is an example of a search query which contains one word, *Tom Cruise* is an example of a search query which contains two words, *Tom and Jerry* is an example of a search query which contains three words. *"Tom Cruise"* is an example of a phrase search, in which the user wants to find an exact match to this whole phrase. +- input.txt is the input file which contains search queries. Each line of this file is a search query. + +Your program should treat each line in the input file as a search query, and print the search results corresponding to each search query into a separate file. +Name your output file(s) this way: out1.txt, out2.txt, out3.txt, out4.txt, ... + +Here +1. out1.txt contains the search results for the first search query - i.e., the query appears in line 1 of the input file. +2. out2.txt contains the search results for the second search query - i.e., the query appears in line 2 of the input file. +3. out3.txt contains the search results for the third search query - i.e., the query appears in line 3 of the input file. +4. out4.txt contains the search results for the fourth search query - i.e., the query appears in line 4 of the input file. +... + +You must name your output files in such a way. You will fail the test cases if your output files are not named as "out1.txt", "out2.txt", "out3.txt", "out4.txt", etc. And yes, if the input file has 1000 lines, then your program will produce 1000 output files. ### Phrase Search vs Regular Search @@ -206,7 +190,7 @@ Your search engine should support both phrase search and regular search. 1. When searching multiple words with double quotes, it is called a phrase search. In phrase search, the whole phrase must exist somewhere in the searched document. In other words, the search engine will search for the exact phrase, word for word, and in the specified order. 2. When searching multiple words without double quotes, it is called a regular search. In this assignment, we define the term *regular search* as such: the search engine should look for documents which contain every word of the search query, but these words do not need to appear together, and they can appear in any order within the document. -Based on the above definition, a document which only contains the following two lines (in the body section of the HTML file) is a valid document when the user searches *Tom Cruise*: +Based on the above definition, a document which only contains the following two lines (in the body section of the HTML file) is a valid document when the user performs a regular search looking for *Tom Cruise*: ```console Tom and Jerry show @@ -215,6 +199,30 @@ Have Fun And Save Now With Great Deals When You Cruise With Carnival. Book Onlin Because we can find both the word *Tom* and the word *Cruise*. But it is not a valid document if the user does a phrase search - *"Tom Cruise"*, as no exact match can be found in this document. +### Definition of Match + +When searching a document, you should follow these rules: + +### Rule 1. Case-sensitive Search Engine + +Search engines are usually case-insensitive, but making the search engine case-insensitive will require some extra work and likely need to call some functions we have not learned in this course. Therefore, to simplify your tasks and reduce the amount of your work, in this assignment, the search engine you are going to implement is case-sensitive. In other words, when searching *Tom*, the word *Tom* is a match, neither the word *TOM* nor the word *tom* is a match. + +### Rule 2. Word Boundary + +When searching the word *Tom*, we do not consider the word *Tom* in *Tomato* as a match, and we do not consider the word *Tom* in *4Tom* or *Tom32* as a match; but we do consider the word *Tom* in *Tom.*, *Tom-*, *.Tom*, *-Tom*, *_Tom*, *Tom!*, " Tom", " Tom ", etc., as a match. In other words, the word *Tom* is found in a document only if it appears as a standalone word, meaning that the character right before *Tom* and the character right after *Tom* must be a word boundary. And in this assignment, you can consider any non-alphanumeric character as a word boundary. This behavior is consistent with what Google does. + +Such a rule also applies to phrase search. We consider a phrase to be a match only if we find the phrase and the character right before the phrase and the character right after the phrase is a word boundary, i.e., a non-alphanumeric character. + +To determine if a character is an alphanumeric character or not, you can call std::isalnum(). This function considers the following characters as alphanumeric: + +```console +digits (0123456789) +uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ) +lowercase letters (abcdefghijklmnopqrstuvwxyz) +``` + +The function takes one single character as its sole argument. It return a non-zero value if the character is an alphanumeric character, 0 otherwise. + ## Input Files All the input files are HTML files, and they are provided under the [html_files](html_files) directory. Among these HTML files, there is only one HTML file which will be provided via the command line, and this file will be considered as the Seed file, and the path of this file (i.e. html_files/index.html) therefore will be used as the Seed URL. Your web crawler should search this HTML file and find links contained in this HTML file, and then follow these links to crawl other HTML files, and repeat this process until you can not reach any more files. Keep in mind that links which take you to an HTML file which you have already crawled, should be skipped, otherwise you will get into an infinite loop situation. @@ -383,28 +391,30 @@ don’t put all the code in main! Be sure to read the [Homework Policies](https: to comment your code! Use the provided template [README.txt](./README.txt) file for notes you want the grader to read. You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. -**Due Date**: 11/02/2023, Thursday, 23:59pm. +**Due Date**: 03/21/2023, Thursday, 10pm. -## Instructor's Code + ## Rubric 20 pts - - README.txt Completed (2 pts) + - README.txt Completed (3 pts) - One of name, collaborators, or hours not filled in. (-1) - Two or more of name, collaborators, or hours not filled in. (-2) - - IMPLEMENTATION AND CODING STYLE (Good class design, split into a .h and .cpp file. Functions > 1 line are in .cpp file. Organized class implementation and reasonable comments throughout. Correct use of const/const& and of class method const. ) (8 pts) - - No credit (significantly incomplete implementation) (-8) + - No reflection. (-1) + - IMPLEMENTATION AND CODING STYLE (Good class design, split into a .h and .cpp file. Functions > 1 line are in .cpp file. Organized class implementation and reasonable comments throughout. Correct use of const/const& and of class method const. ) (7 pts) + - No credit (significantly incomplete implementation) (-7) - Putting almost everything in the main function. It's better to create separate functions for different tasks. (-2) - Function bodies containing more than one statement are placed in the .h file. (okay for templated classes) (-2) - Missing include guards in the .h file. (Or does not declare them correctly) (-1) - Functions are not well documented or are poorly commented, in either the .h or the .cpp file. (-1) - Improper uses or omissions of const and reference. (-1) + - At least one function is excessively long (i.e., more than 200 lines). (-1) - Overly cramped, excessive whitespace, or poor indentation. (-1) - Poor file organization: Puts more than one class in a file (okay for very small helper classes) (-1) - - Poor variable names. (-1) + - Poor choice of variable names: non-descriptive names (e.g. 'vec', 'str', 'var'), single-letter variable names (except single loop counter), etc. (-2) - Contains useless comments like commented-out code, terminal commands, or silly notes. (-1) - DATA REPRESENTATION (7 pts) - Uses data structures which have not been covered in this class. (-7) @@ -413,3 +423,47 @@ You can test (but not view) the instructor's code here: [instructor code](http:/ - Member variables are public. (-2) - RECURSION (3 pts) - Does not use recursion in the web crawler component. (-3) + +## Appendix A - HTML File Basics + +A typical HTML file consists of two main sections: the <head> section and the <body> section. + +1. The <head> section contains metadata about the document, such as its title, character encoding, stylesheets, scripts, and other information that is not directly displayed on the web page. + +2. The <body> section contains the actual content of the document that is displayed to the user, such as text, images, links, and other elements. + +These two sections together define the structure and content of an HTML document. The following is an example, it is a basic html file. + +```html +1. +2. +3. +4. +5. +6. +7. +8. Example HTML File +9. +10. +11.

Welcome to My Website

+12.

This is the body content of the HTML file. You can add any content you like here.

+13. +18. +19. +``` + +Here: + +- line 3 and line 9 marks the head section of this html file. + +- line 10 and line 18 marks the body section of this html file. + +- line 5 is the description tag. + +- line 8 is the title tag. + +- line 14, line 15, and line 16 are some outgoing links. diff --git a/old_hws/07_search_engine/README.txt b/old_hws/07_search_engine/README.txt index b97f87e..6381d47 100644 --- a/old_hws/07_search_engine/README.txt +++ b/old_hws/07_search_engine/README.txt @@ -22,3 +22,16 @@ ESTIMATE OF # OF HOURS SPENT ON THIS ASSIGNMENT: < insert # hours > MISC. COMMENTS TO GRADER: (optional, please be concise!) + +## Reflection and Self Assessment + +Discuss the issues you encountered during development and testing. What +problems did you have? What did you have to research and learn on your +own? What kinds of errors did you get? How did you fix them? + +What parts of the assignment did you find challenging? Is there anything that +finally "clicked" for you in the process of working on this assignment? How well +did the development and testing process go for you? + +< insert reflection > + From 2a2c44d106c847db5888e43446673e369df789e3 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 12 Mar 2024 16:51:28 -0400 Subject: [PATCH 34/45] adding input1 --- old_hws/07_search_engine/input1.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 old_hws/07_search_engine/input1.txt diff --git a/old_hws/07_search_engine/input1.txt b/old_hws/07_search_engine/input1.txt new file mode 100644 index 0000000..c907b1a --- /dev/null +++ b/old_hws/07_search_engine/input1.txt @@ -0,0 +1,16 @@ +Tom +Tom Cruise +Tom and Jerry +"Tom Brady" +Tom Hanks +Tomato +tomato +Facebook +Golden State Warriors +Splash Brothers +Denver Nuggets +Nikola Jokic +Kobe Bryant Vanessa Bryant +Devin Booker Kendall Jenner +Keep Up With the Kardashians +The Tonight Show Starring Jimmy Fallon From f55a86db7e560bea3c4fbf8a5e585e88aff80522 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 12 Mar 2024 16:53:35 -0400 Subject: [PATCH 35/45] the double quote issue doesn't exist anymore --- old_hws/07_search_engine/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index 9d92cf2..d72a60b 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -320,7 +320,8 @@ if (lastSlashPos != std::string::npos) { directory = URL.substr(0, lastSlashPos + 1); } ``` -- erase: when doing a phrase search, we enclose our query with double quotes. Unfortunately, the autograder is not smart enough to handle this, and it will pass the double quotes as a part of the query string. And therefore, in your program, you need to remove the double quotes, and you can do so using code like this: + + ## Provided Functions @@ -387,9 +389,9 @@ Make sure you still include the fstream library. In this assignment, you are required to use either std::map or std::set. You can use both if you want to. You are NOT allowed to use any data structures we have not learned so far, but feel free to use any data structures we have already learned, such as std::string, std::vector, std::list. In addition, **the web crawler component of your program must be recursive**. Use good coding style when you design and implement your program. Organize your program into functions: -don’t put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget +don’t put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget to comment your code! Use the provided template [README.txt](./README.txt) file for notes you want the grader to read. -You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. +You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. **Due Date**: 03/21/2023, Thursday, 10pm. From bb41dd3e0be29bde9cab9f5f8c46d8ea6173ce60 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 19:35:50 -0400 Subject: [PATCH 36/45] clarify on the body section, only use body section when constructing snippets --- old_hws/07_search_engine/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index d72a60b..c227149 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -150,7 +150,7 @@ To reduce the scope of the assignment, and hence reduce the amount of work from ### Rule 1. Search HTML Files Only -Search Engines like Google will search all types of files on the Internet, but in this assignment, we assume all files we search are HTML files. And we consider an HTML file contains the search query only if the search query can be found within the <body> section of the HTML file. The <body> section, enclosed within the <body></body> tags in an HTML document, represents the primary content area of the web page. +Search Engines like Google will search all types of files on the Internet, but in this assignment, we assume all files we search are HTML files. ### Rule 2. Local Searching Only @@ -190,7 +190,7 @@ Your search engine should support both phrase search and regular search. 1. When searching multiple words with double quotes, it is called a phrase search. In phrase search, the whole phrase must exist somewhere in the searched document. In other words, the search engine will search for the exact phrase, word for word, and in the specified order. 2. When searching multiple words without double quotes, it is called a regular search. In this assignment, we define the term *regular search* as such: the search engine should look for documents which contain every word of the search query, but these words do not need to appear together, and they can appear in any order within the document. -Based on the above definition, a document which only contains the following two lines (in the body section of the HTML file) is a valid document when the user performs a regular search looking for *Tom Cruise*: +Based on the above definition, a document which only contains the following two lines is a valid document when the user performs a regular search looking for *Tom Cruise*: ```console Tom and Jerry show @@ -279,22 +279,22 @@ In all HTML files we provide, in the <head> section of the HTML, we have a ``` -Here, "Boston Celtics Scores, Stats and Highlights" is the description. Keep in mind that this description tag is always in the <head> section, rather than in the <body> section, and thus a match found in the description should not be counted as a valid match. +Here, "Boston Celtics Scores, Stats and Highlights" is the description. ### The Snippet This snippet contains an excerpt from the page's content that is directly related to the search query. In this assignment, the requirements for this snippet is: -1. It should contain exactly 120 characters. +1. when constructing the snippet, you should only consider the <body> section of the HTML files. In other words, the snippet must come from the <body> sectiono only. -2.1 For a phrase search, the snippet should start from the beginning of a sentence which contains the query; This means the query itself may not appear in the snippet: this is possible when a sentence contains the query, but that query does not appear in the first 120 characters of the sentence. If the query appears multiple times in a document, consider the first occurrence only. In other words, to construct the snippet, your program should search the first occurrence of the query in the document. +2. The snippet should contain exactly 120 characters. -2.2 For a regular search, if an exact match can be found in the document, the snippet should start from the beginning of a sentence which contains the query, and if the query appears multiple times in the document, consider the first occurrence only; if an exact match can not be found, the snippet should start from the beginning of a sentence which contains the first keyword of the query, and if the first keyword appears multiple times in the document, consider the first occurrence only. +3.1 For a phrase search, the snippet should start from the beginning of a sentence which contains the query; This means the query itself may not appear in the snippet: this is possible when a sentence contains the query, but that query does not appear in the first 120 characters of the sentence. If the query appears multiple times in a document, consider the first occurrence only. In other words, to construct the snippet, your program should search the first occurrence of the query in the <body> section of the document. + +3.2 For a regular search, if an exact match can be found in the <body> section of the document, the snippet should start from the beginning of a sentence which contains the query, and if the query appears multiple times in the <body> section of the document, consider the first occurrence only; if an exact match can not be found in the <body> section of the document, the snippet should start from the beginning of a sentence which contains the first keyword of the query, and if the first keyword appears multiple times in the <body> section of the document, consider the first occurrence only. **Note**, to simplify the construction of the snippets, we have tailored the provided HTML files such that you can identify the beginning of a sentence via searching the period sign before the sentence. In this assignment, you can assume that there is always a period sign before the sentence which contains the snippet you are going to construct, however, it is possible that there are some whitespaces in between the period and the start of the sentence. -**Note 2**, when constructing the snippet, you should only consider the <body> section of the HTML files. - ## Useful String Functions You may find the following functions to be useful (most of them are string functions, except *std::isspace*): From 95499cee2f9ba47bad3f3d1069d349b5e9b6f0fd Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 19:41:17 -0400 Subject: [PATCH 37/45] clarify on the input files --- old_hws/07_search_engine/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index c227149..367d2fc 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -225,7 +225,9 @@ The function takes one single character as its sole argument. It return a non-ze ## Input Files -All the input files are HTML files, and they are provided under the [html_files](html_files) directory. Among these HTML files, there is only one HTML file which will be provided via the command line, and this file will be considered as the Seed file, and the path of this file (i.e. html_files/index.html) therefore will be used as the Seed URL. Your web crawler should search this HTML file and find links contained in this HTML file, and then follow these links to crawl other HTML files, and repeat this process until you can not reach any more files. Keep in mind that links which take you to an HTML file which you have already crawled, should be skipped, otherwise you will get into an infinite loop situation. +Your program takes two types of input files: the HTML files and the input.txt file, which contains all the search query terms. + +All the HTML files are provided under the [html_files](html_files) directory. Among these HTML files, there is only one HTML file which will be provided via the command line, and this file will be considered as the Seed file, and the path of this file (i.e. html_files/index.html) therefore will be used as the Seed URL. Your web crawler should search this HTML file and find links contained in this HTML file, and then follow these links to crawl other HTML files, and repeat this process until you can not reach any more files. Keep in mind that links which take you to an HTML file which you have already crawled, should be skipped, otherwise you will get into an infinite loop situation. ## Output File Format From ff223fec7cb04120f29c8b8e530b94ee6844b88c Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 19:42:37 -0400 Subject: [PATCH 38/45] fixing typo --- old_hws/07_search_engine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index 367d2fc..d5fdfeb 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -287,7 +287,7 @@ Here, "Boston Celtics Scores, Stats and Highlights" is the description. This snippet contains an excerpt from the page's content that is directly related to the search query. In this assignment, the requirements for this snippet is: -1. when constructing the snippet, you should only consider the <body> section of the HTML files. In other words, the snippet must come from the <body> sectiono only. +1. when constructing the snippet, you should only consider the <body> section of the HTML files. In other words, the snippet must come from the <body> section only. 2. The snippet should contain exactly 120 characters. From 10af091cdf61fa0f14d12f6d3d600b293ef7bc44 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 19:44:06 -0400 Subject: [PATCH 39/45] word to substring --- old_hws/07_search_engine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index d5fdfeb..10e3f31 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -209,7 +209,7 @@ Search engines are usually case-insensitive, but making the search engine case-i ### Rule 2. Word Boundary -When searching the word *Tom*, we do not consider the word *Tom* in *Tomato* as a match, and we do not consider the word *Tom* in *4Tom* or *Tom32* as a match; but we do consider the word *Tom* in *Tom.*, *Tom-*, *.Tom*, *-Tom*, *_Tom*, *Tom!*, " Tom", " Tom ", etc., as a match. In other words, the word *Tom* is found in a document only if it appears as a standalone word, meaning that the character right before *Tom* and the character right after *Tom* must be a word boundary. And in this assignment, you can consider any non-alphanumeric character as a word boundary. This behavior is consistent with what Google does. +When searching the word *Tom*, we do not consider the substring *Tom* in *Tomato* as a match, and we do not consider the substring *Tom* in *4Tom* or *Tom32* as a match; but we do consider the substring *Tom* in *Tom.*, *Tom-*, *.Tom*, *-Tom*, *_Tom*, *Tom!*, " Tom", " Tom ", etc., as a match. In other words, the word *Tom* is found in a document only if it appears as a standalone word, meaning that the character right before *Tom* and the character right after *Tom* must be a word boundary. And in this assignment, you can consider any non-alphanumeric character as a word boundary. This behavior is consistent with what Google does. Such a rule also applies to phrase search. We consider a phrase to be a match only if we find the phrase and the character right before the phrase and the character right after the phrase is a word boundary, i.e., a non-alphanumeric character. From 19e7eb45a8d5fffd5245328997de18e31d8495b4 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 19:45:29 -0400 Subject: [PATCH 40/45] updating due date --- old_hws/07_search_engine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/old_hws/07_search_engine/README.md b/old_hws/07_search_engine/README.md index 10e3f31..22f81cb 100644 --- a/old_hws/07_search_engine/README.md +++ b/old_hws/07_search_engine/README.md @@ -395,7 +395,7 @@ don’t put all the code in main! Be sure to read the [Homework Policies](https: to comment your code! Use the provided template [README.txt](./README.txt) file for notes you want the grader to read. You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. -**Due Date**: 03/21/2023, Thursday, 10pm. +**Due Date**: 03/21/2024, Thursday, 10pm. -For each keyword, the keyword's density score is a measure of how the keyword's frequency in a document compares to its occurrence in all documents, and we can use the following formula to calculate the density score of one keyword. +For each keyword, the keyword's density score is a measure of how the keyword's frequency in a document compares to its occurrence in all documents, and we can use the following formula to calculate the density score of one keyword. (**Note:** here the term "all documents" literally means all documents, not just the documents which contain the query.) ```console Keyword Density Score = (Number of Times Keyword Appears) / (Total Content Length of this One Document * Keyword Density Across All Documents) From bd88f2ab84caaf1d08b06ba1b7140fff8cdef639 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 14 Mar 2024 21:59:27 -0400 Subject: [PATCH 44/45] move hw7 to hws --- {old_hws => hws}/07_search_engine/README.md | 0 {old_hws => hws}/07_search_engine/README.txt | 0 .../07_search_engine/html_files/file1.html | 0 .../07_search_engine/html_files/file2.html | 0 .../07_search_engine/html_files/index.html | 0 .../07_search_engine/html_files/subdir1/file3.html | 0 .../html_files/subdir1/subdir2/file4.html | 0 .../html_files/subdir1/subdir2/file5.html | 0 .../html_files/subdir1/subdir2/file6.html | 0 .../html_files/subdir1/subdir2/file7.html | 0 .../html_files/subdir1/subdir2/subdir3/file10.html | 0 .../html_files/subdir1/subdir2/subdir3/file8.html | 0 .../html_files/subdir1/subdir2/subdir3/file9.html | 0 .../subdir1/subdir2/subdir3/subdir4/file11.html | 0 .../subdir1/subdir2/subdir3/subdir4/file12.html | 0 .../subdir1/subdir2/subdir3/subdir4/file13.html | 0 .../subdir1/subdir2/subdir3/subdir5/file14.html | 0 .../subdir1/subdir2/subdir3/subdir5/file15.html | 0 .../subdir1/subdir2/subdir3/subdir5/file16.html | 0 .../subdir3/subdir5/subdir6/subdir7/file17.html | 0 .../subdir3/subdir5/subdir6/subdir7/file18.html | 0 .../subdir3/subdir5/subdir6/subdir7/file19.html | 0 .../subdir5/subdir6/subdir7/subdir8/file20.html | 0 .../subdir5/subdir6/subdir7/subdir8/file21.html | 0 .../subdir5/subdir6/subdir7/subdir8/file22.html | 0 .../subdir5/subdir6/subdir7/subdir8/file23.html | 0 .../subdir6/subdir7/subdir8/subdir9/file24.html | 0 .../subdir6/subdir7/subdir8/subdir9/file25.html | 0 .../subdir7/subdir8/subdir9/subdir10/file26.html | 0 .../subdir7/subdir8/subdir9/subdir10/file27.html | 0 .../subdir7/subdir8/subdir9/subdir10/file28.html | 0 .../07_search_engine/images/celtics.png | Bin .../07_search_engine/images/no_match.png | Bin .../07_search_engine/images/tom_cruise.png | Bin .../images/tom_cruise_description.png | Bin .../07_search_engine/images/tom_cruise_title.png | Bin {old_hws => hws}/07_search_engine/input.txt | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename {old_hws => hws}/07_search_engine/README.md (100%) rename {old_hws => hws}/07_search_engine/README.txt (100%) rename {old_hws => hws}/07_search_engine/html_files/file1.html (100%) rename {old_hws => hws}/07_search_engine/html_files/file2.html (100%) rename {old_hws => hws}/07_search_engine/html_files/index.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/file3.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/file4.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/file5.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/file6.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/file7.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/file10.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/file8.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/file9.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file11.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file12.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file13.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file14.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file15.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file16.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file17.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file18.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file19.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file20.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file21.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file22.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file23.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file24.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file25.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file26.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file27.html (100%) rename {old_hws => hws}/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file28.html (100%) rename {old_hws => hws}/07_search_engine/images/celtics.png (100%) rename {old_hws => hws}/07_search_engine/images/no_match.png (100%) rename {old_hws => hws}/07_search_engine/images/tom_cruise.png (100%) rename {old_hws => hws}/07_search_engine/images/tom_cruise_description.png (100%) rename {old_hws => hws}/07_search_engine/images/tom_cruise_title.png (100%) rename {old_hws => hws}/07_search_engine/input.txt (100%) diff --git a/old_hws/07_search_engine/README.md b/hws/07_search_engine/README.md similarity index 100% rename from old_hws/07_search_engine/README.md rename to hws/07_search_engine/README.md diff --git a/old_hws/07_search_engine/README.txt b/hws/07_search_engine/README.txt similarity index 100% rename from old_hws/07_search_engine/README.txt rename to hws/07_search_engine/README.txt diff --git a/old_hws/07_search_engine/html_files/file1.html b/hws/07_search_engine/html_files/file1.html similarity index 100% rename from old_hws/07_search_engine/html_files/file1.html rename to hws/07_search_engine/html_files/file1.html diff --git a/old_hws/07_search_engine/html_files/file2.html b/hws/07_search_engine/html_files/file2.html similarity index 100% rename from old_hws/07_search_engine/html_files/file2.html rename to hws/07_search_engine/html_files/file2.html diff --git a/old_hws/07_search_engine/html_files/index.html b/hws/07_search_engine/html_files/index.html similarity index 100% rename from old_hws/07_search_engine/html_files/index.html rename to hws/07_search_engine/html_files/index.html diff --git a/old_hws/07_search_engine/html_files/subdir1/file3.html b/hws/07_search_engine/html_files/subdir1/file3.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/file3.html rename to hws/07_search_engine/html_files/subdir1/file3.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/file4.html b/hws/07_search_engine/html_files/subdir1/subdir2/file4.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/file4.html rename to hws/07_search_engine/html_files/subdir1/subdir2/file4.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/file5.html b/hws/07_search_engine/html_files/subdir1/subdir2/file5.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/file5.html rename to hws/07_search_engine/html_files/subdir1/subdir2/file5.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/file6.html b/hws/07_search_engine/html_files/subdir1/subdir2/file6.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/file6.html rename to hws/07_search_engine/html_files/subdir1/subdir2/file6.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/file7.html b/hws/07_search_engine/html_files/subdir1/subdir2/file7.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/file7.html rename to hws/07_search_engine/html_files/subdir1/subdir2/file7.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file10.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file10.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file10.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file10.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file8.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file8.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file8.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file8.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file9.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file9.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file9.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/file9.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file11.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file11.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file11.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file11.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file12.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file12.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file12.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file12.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file13.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file13.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file13.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir4/file13.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file14.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file14.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file14.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file14.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file15.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file15.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file15.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file15.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file16.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file16.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file16.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/file16.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file17.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file17.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file17.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file17.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file18.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file18.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file18.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file18.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file19.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file19.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file19.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/file19.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file20.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file20.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file20.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file20.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file21.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file21.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file21.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file21.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file22.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file22.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file22.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file22.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file23.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file23.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file23.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/file23.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file24.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file24.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file24.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file24.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file25.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file25.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file25.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/file25.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file26.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file26.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file26.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file26.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file27.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file27.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file27.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file27.html diff --git a/old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file28.html b/hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file28.html similarity index 100% rename from old_hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file28.html rename to hws/07_search_engine/html_files/subdir1/subdir2/subdir3/subdir5/subdir6/subdir7/subdir8/subdir9/subdir10/file28.html diff --git a/old_hws/07_search_engine/images/celtics.png b/hws/07_search_engine/images/celtics.png similarity index 100% rename from old_hws/07_search_engine/images/celtics.png rename to hws/07_search_engine/images/celtics.png diff --git a/old_hws/07_search_engine/images/no_match.png b/hws/07_search_engine/images/no_match.png similarity index 100% rename from old_hws/07_search_engine/images/no_match.png rename to hws/07_search_engine/images/no_match.png diff --git a/old_hws/07_search_engine/images/tom_cruise.png b/hws/07_search_engine/images/tom_cruise.png similarity index 100% rename from old_hws/07_search_engine/images/tom_cruise.png rename to hws/07_search_engine/images/tom_cruise.png diff --git a/old_hws/07_search_engine/images/tom_cruise_description.png b/hws/07_search_engine/images/tom_cruise_description.png similarity index 100% rename from old_hws/07_search_engine/images/tom_cruise_description.png rename to hws/07_search_engine/images/tom_cruise_description.png diff --git a/old_hws/07_search_engine/images/tom_cruise_title.png b/hws/07_search_engine/images/tom_cruise_title.png similarity index 100% rename from old_hws/07_search_engine/images/tom_cruise_title.png rename to hws/07_search_engine/images/tom_cruise_title.png diff --git a/old_hws/07_search_engine/input.txt b/hws/07_search_engine/input.txt similarity index 100% rename from old_hws/07_search_engine/input.txt rename to hws/07_search_engine/input.txt From 60d92f8b10fbba50a6a518e546049898d295ec6d Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 15 Mar 2024 00:02:16 -0400 Subject: [PATCH 45/45] adding instructor code link --- hws/07_search_engine/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hws/07_search_engine/README.md b/hws/07_search_engine/README.md index 0e90104..647e9ba 100644 --- a/hws/07_search_engine/README.md +++ b/hws/07_search_engine/README.md @@ -1,5 +1,3 @@ -**Note:** Sample output files will be added later; submitty autograder will not open until Friday afternoon. - +You can test (but not view) the instructor's code here: [instructor code](http://ds.cs.rpi.edu/hws/search/). This page allows you to view those intermediate results. ## Rubric @@ -410,7 +408,7 @@ You can test (but not view) the instructor's code here: [instructor code](http:/ - One of name, collaborators, or hours not filled in. (-1) - Two or more of name, collaborators, or hours not filled in. (-2) - No reflection. (-1) - - IMPLEMENTATION AND CODING STYLE (Good class design, split into a .h and .cpp file. Functions > 1 line are in .cpp file. Organized class implementation and reasonable comments throughout. Correct use of const/const& and of class method const. ) (8 pts) + - IMPLEMENTATION AND CODING STYLE (8 pts) - No credit (significantly incomplete implementation) (-8) - Putting almost everything in the main function. It's better to create separate functions for different tasks. (-2) - Function bodies containing more than one statement are placed in the .h file. (okay for templated classes) (-2)