Difference between revisions of "CISC220 F2023 Lab2"
From class_wiki
(→Lab #2) |
(→Lab #2) |
||
Line 8: | Line 8: | ||
** <tt>deleteHead</tt> : 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) | ||
** <tt>insertAt</tt> : insert node with specified value by index -- head is 0. If index is invalid, do nothing (2 ARGUMENTS: value, index) | ** <tt>insertAt</tt> : insert node with specified value by index -- head is 0. If index is invalid, do nothing (2 ARGUMENTS: value, index) | ||
− | ** <tt>deleteAt</tt> : Remove node by index. If index is invalid, do nothing (1 ARGUMENT: index). '''You can use AI to help with this one''' | + | ** <tt>deleteAt</tt> : 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''' |
** <tt>printSize</tt> : 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) | ||
** <tt>printValue</tt> : Print value of node at index, followed by newline. If index is invalid, print "ERROR" (1 ARGUMENT: index) | ** <tt>printValue</tt> : Print value of node at index, followed by newline. If index is invalid, print "ERROR" (1 ARGUMENT: index) |
Revision as of 08:58, 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 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. Some examples:
- insertHead dog
- deleteHead
- insertAt cat 3
- printAll
- printFrequency elephant
- # Ignore this line
- 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.