CISC220 F2023 Lab2

From class_wiki
Jump to: navigation, search

Requirements

(5 points) Implement a templated singly-linked list class called SL_List in C++, plus read 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 using an STL vector of strings for convenience. 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: value)
    • 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: value, index)
    • deleteAt  : Remove node by index. If index is invalid, do nothing (1 ARGUMENT: index). You can use AI programming assistance tools to help with this one
    • 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: index)
    • 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: value)
    • printIndex  : Print index of first instance of value in list ("-1" if not found), followed by newline (1 ARGUMENT: value)
  • The command files consist of one command per line. Each command line starts with zero or some whitespace, followed by a string with the exact name of one of the functions above, and then whitespace-separated arguments if the function takes them, terminated by a newline. Ignore blank lines or lines whose first non-whitespace text is not one of the function names. If a command has too few or too many arguments, ignore it. Some examples:
    • insertHead dog
    • deleteHead
    • insertAt cat 3
    • printAll
    • printFrequency elephant
    • # Ignore this line
  • A handful of test input files and correct output for them are provided. You should create many more of your own to thoroughly test your solution. The Gradescope autograder tests will not be available until at least Sunday
  • The required functions above are the minimum -- you may create additional "helper" functions and/or member variables as needed. No STL or outside libraries may be referenced in your SL_List class.
  • You may optionally work with a partner on this assignment. Any late days used will be subtracted from both of your balances.

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.
  • As I said in class, although 5 possible points will be available through the autograder, this is not guaranteed to be your final lab grade. The TAs and I will be checking that your submission (both README and code) satisfies any or all of the above requirements for you to earn full credit.