Difference between revisions of "CISC220 F2023 Lab2"

From class_wiki
Jump to: navigation, search
(Lab #2)
(Lab #2)
Line 1: Line 1:
 
==Lab #2==
 
==Lab #2==
  
'''(5 points)''' Implement a templated singly-linked list class called SL_List in C++, plus a simple command language for testing
+
'''(5 points)''' Implement a templated singly-linked list class called <tt>SL_List</tt> in C++, plus a simple command language for testing
  
 
* Starter code is provided [https://drive.google.com/file/d/1KGKBZvAOnd8q8ibcgPAFgXfRuD4q4pVz/view?usp=sharing here].  A node class called <tt>S_Node</tt> is implemented for you in <tt>s_node.hh</tt>.  The shell of the list class, to be filled in by you as detailed below, is in <tt>sl_list.cpp</tt>.  <tt>main()</tt> already provides code to read in a "command file" line by line and word by word.  Currently, it only echoes the file that it reads.  You will need to comment out the echo block and replace it with a very simple parsing scheme for the command language described below.
 
* Starter code is provided [https://drive.google.com/file/d/1KGKBZvAOnd8q8ibcgPAFgXfRuD4q4pVz/view?usp=sharing here].  A node class called <tt>S_Node</tt> is implemented for you in <tt>s_node.hh</tt>.  The shell of the list class, to be filled in by you as detailed below, is in <tt>sl_list.cpp</tt>.  <tt>main()</tt> already provides code to read in a "command file" line by line and word by word.  Currently, it only echoes the file that it reads.  You will need to comment out the echo block and replace it with a very simple parsing scheme for the command language described below.
 
* <tt>SL_List</tt> functions to declare and define:
 
* <tt>SL_List</tt> functions to declare and define:
** insertHead        : Put new node with specified value at head of list (1 ARGUMENT)  
+
** <tt>insertHead</tt>         : Put new node with specified value at head of list (1 ARGUMENT)  
** deleteHead        : Remove node at head of list.  If list is empty, nothing happens (0 ARGUMENTS)  
+
** <tt>deleteHead</tt>         : Remove node at head of list.  If list is empty, nothing happens (0 ARGUMENTS)  
** insertAt          : insert node with specified value by index -- head is 0.  If index is invalid, do nothing (2 ARGUMENTS)  
+
** <tt>insertAt</tt>           : insert node with specified value by index -- head is 0.  If index is invalid, do nothing (2 ARGUMENTS)  
** deleteAt          : Remove node by index.  If index is invalid, do nothing (1 ARGUMENT)
+
** <tt>deleteAt</tt>           : Remove node by index.  If index is invalid, do nothing (1 ARGUMENT)
** printSize          : Print current number of nodes in list, followed by newline (0 ARGUMENTS)
+
** <tt>printSize</tt>         : Print current number of nodes in list, followed by newline (0 ARGUMENTS)
** printValue        : Print value of node at index, followed by newline.  If index is invalid, print "ERROR" (1 ARGUMENT)
+
** <tt>printValue</tt>         : Print value of node at index, followed by newline.  If index is invalid, print "ERROR" (1 ARGUMENT)
** printAllValues    : Print value of every node in list from head to tail on its own line (0 ARGUMENTS)
+
** <tt>printAllValues</tt>     : Print value of every node in list from head to tail on its own line (0 ARGUMENTS)
** printFrequency    : Print how many times the value occurs in the full list, followed by a newline (1 ARGUMENT)
+
** <tt>printFrequency</tt>     : Print how many times the value occurs in the full list, followed by a newline (1 ARGUMENT)
** printIndex        : Print index of first instance of value in list ("-1" if not found), followed by newline (1 ARGUMENT)
+
** <tt>printIndex</tt>         : Print index of first instance of value in list ("-1" if not found), followed by newline (1 ARGUMENT)
 
      
 
      
 
* You may optionally work with a partner on this assignment.  Any late days used will be subtracted from both of your balances.
 
* You may optionally work with a partner on this assignment.  Any late days used will be subtracted from both of your balances.

Revision as of 07:46, 7 September 2023

Lab #2

(5 points) Implement a templated singly-linked list class called SL_List in C++, plus a simple command language for testing

  • Starter code is provided here. A node class called S_Node is implemented for you in s_node.hh. The shell of the list class, to be filled in by you as detailed below, is in sl_list.cpp. main() already provides code to read in a "command file" line by line and word by word. Currently, it only echoes the file that it reads. You will need to comment out the echo block and replace it with a very simple parsing scheme for the command language described below.
  • SL_List functions to declare and define:
    • insertHead  : Put new node with specified value at head of list (1 ARGUMENT)
    • deleteHead  : Remove node at head of list. If list is empty, nothing happens (0 ARGUMENTS)
    • insertAt  : insert node with specified value by index -- head is 0. If index is invalid, do nothing (2 ARGUMENTS)
    • deleteAt  : Remove node by index. If index is invalid, do nothing (1 ARGUMENT)
    • printSize  : Print current number of nodes in list, followed by newline (0 ARGUMENTS)
    • printValue  : Print value of node at index, followed by newline. If index is invalid, print "ERROR" (1 ARGUMENT)
    • printAllValues  : Print value of every node in list from head to tail on its own line (0 ARGUMENTS)
    • printFrequency  : Print how many times the value occurs in the full list, followed by a newline (1 ARGUMENT)
    • printIndex  : Print index of first instance of value in list ("-1" if not found), followed by newline (1 ARGUMENT)
  • You may optionally work with a partner on this assignment. Any late days used will be subtracted from both of your balances.

3. Submission

  • Let's try submitting completely through Gradescope this week. You will submit exactly two files: (1) "README" (no PDF or other fancy formatting, just plain text) and (2) "sl_list.cpp". As before, the README should contain any AI tool citations/explanations, notes on any limitations or issues with your code, your interpretation of any ambiguities in the assignment instructions, and the names of yourself and your partner if you had one. The code file should also have your name(s) and AI citations per the syllabus.
  • Resubmit as many times as you like until the deadline, but be aware that the submission window is kept open for some students to use late days, so a resubmission 2 days after the deadline is not free.