renaming labs
This commit is contained in:
@@ -1,156 +0,0 @@
|
|||||||
# Overview
|
|
||||||
|
|
||||||
Welcome to CSCI 1200 Data Structures lab! Please listen carefully
|
|
||||||
when your graduate lab TA and undergraduate programming mentors
|
|
||||||
introduce themselves at the start of class. They are here to answer
|
|
||||||
any questions about the course materials and work with you one-on-one
|
|
||||||
to master strong programming and debugging skills. Also, introduce
|
|
||||||
yourself to the other students in your lab section. You may ask your
|
|
||||||
fellow students questions about the lab. This will help reduce the
|
|
||||||
burden on the TAs and will reduce your waiting time in lab. **Note: Each student must produce his/her own exercise solutions.**
|
|
||||||
|
|
||||||
There will be three graded "checkpoints" associated with each lab.
|
|
||||||
If you have a question or when you have completed each checkpoint,
|
|
||||||
raise your hand or put your name in the appropriate queue and your
|
|
||||||
graduate TA or one of the programming mentors will check your work.
|
|
||||||
Part of earning each checkpoint for the lab will involve answering
|
|
||||||
short questions about the material. If you have done the checkpoint
|
|
||||||
and understood it, you should have no trouble earning this credit. If
|
|
||||||
you have relied on help from other students too much, you may find the
|
|
||||||
questions hard to answer.
|
|
||||||
|
|
||||||
**Do not wait until the end of lab to be checked off for multiple
|
|
||||||
checkpoints.** If there is a queue the TA/mentor will only check you
|
|
||||||
off for one checkpoint at a time and ask you to add your name to the
|
|
||||||
end of the queue for the next checkpoint. Class ends 10 minutes
|
|
||||||
before the hour and no checkpoints may be earned after this time.
|
|
||||||
|
|
||||||
*IMPORTANT NOTE: No phones, no email, no texting, no social media,
|
|
||||||
no web surfing, no game-playing, no distraction! With the exception
|
|
||||||
of downloading lab files provided by the instructor at the start of
|
|
||||||
lab, and occasional use of online C++ reference material (e.g., to
|
|
||||||
look up the the details of a particular built-in function or class),
|
|
||||||
you are not allowed to use the internet during lab. Anyone
|
|
||||||
caught using their cell phones, the internet, for activities not relevant to the lab will be given an immediate 0 for
|
|
||||||
that lab and asked to leave.*
|
|
||||||
|
|
||||||
**Today we focus on using the terminal command line and g++ to
|
|
||||||
compile, run, and inspect the results of your program.** After today's
|
|
||||||
lab you are welcome to explore other options for your C++ development
|
|
||||||
environment. However, for the homework assignments, your code must
|
|
||||||
compile and run correctly under gcc/g++ 9.4 and/or llvm/clang++ 10.0 on
|
|
||||||
Ubuntu 20.04. This streamlined grading process allows the TAs to
|
|
||||||
spend more time giving you constructive feedback on programming style,
|
|
||||||
individual tutoring, and debugging help.
|
|
||||||
|
|
||||||
## Checkpoint 1
|
|
||||||
*estimate: 30 minutes + installation delays??*
|
|
||||||
|
|
||||||
- The course website includes instructions to install and setup the necessary software for Windows, MacOSX, and GNU/Linux. Windows users will need Windows Subsystem for Linux (WSL) to follow the instructions below. Ask your TAs and mentors for advice and help if you get stuck.
|
|
||||||
- [development_environment](http://www.cs.rpi.edu/academics/courses/spring24/csci1200/development\_environment.php)
|
|
||||||
- [installation_test](http://www.cs.rpi.edu/academics/courses/spring24/csci1200/installation\_test.php)
|
|
||||||
- Create a directory (a.k.a. "folder") on your laptop to hold Data Structures files. Create a sub-directory to hold the labs. And finally, create a sub-directory named `lab1`. Please make sure to save your work frequently and periodically back-up all of your data.
|
|
||||||
- Using a web browser, copy the following files to your `lab1` directory:
|
|
||||||
- [quadratic.cpp](https://github.com/jidongxiao/CSCI1200-DataStructures/tree/master/labs/01_getting_started/quadratic.cpp)
|
|
||||||
- [README.txt](https://github.com/jidongxiao/CSCI1200-DataStructures/tree/master/labs/01_getting_started/README.txt)
|
|
||||||
- **Open a shell/terminal/command prompt window**. *Please ask for help if you have problems installing WSL or finding your `bash` shell.*
|
|
||||||
- Within the terminal, navigate to your Data Structures Lab 1 directory and inspect the contents of your file system as you go using the “ls”, “cd”, and “pwd” commands. In doing so, remember that directory names are separated by a forward slash “/” and when you have a space in the name of the directory, you precede the blank with a backslash “\”. Thus, you may type something like this:
|
|
||||||
|
|
||||||
```console
|
|
||||||
cd /Users/username/My\ Documents/Data\ Structures/labs/lab1
|
|
||||||
```
|
|
||||||
|
|
||||||
- Confirm that the files quadratic.cpp and README.txt are in the current directory (use ls).
|
|
||||||
|
|
||||||
- First, let’s confirm that gcc is installed on your machine and check the version by typing:
|
|
||||||
|
|
||||||
```console
|
|
||||||
g++ -v
|
|
||||||
```
|
|
||||||
|
|
||||||
If you are not using Ubuntu 18.04 and gcc/g++ 7.3, you may notice slight differences between your compiler and the version on the homework submission server when we get to advanced topics. But don’t worry if you have a different version! We will primarily be using parts of C++ that have been stable and unchanged for many years. You may also try to compile using clang++ instead of g++. The LLVM/clang++ compiler has earned much praise for having clear and concise compiler error messages that are especially helpful for new C++ programmers.
|
|
||||||
|
|
||||||
- Now you are ready to attempt to compile/build the program for this lab by typing:
|
|
||||||
|
|
||||||
```console
|
|
||||||
g++ quadratic.cpp -o quadratic.exe -Wall
|
|
||||||
```
|
|
||||||
|
|
||||||
We have intentionally left a number of errors in this program so that it will not compile correctly to produce an executable program. Don’t fix them yet!
|
|
||||||
|
|
||||||
### "Submit" the buggy version of the lab code to Submitty:
|
|
||||||
|
|
||||||
Upload the quadratic.cpp and README.txt files to the Lab 1 practice gradeable on Submitty. After submitting the buggy code you should receive confirmation of your submission and be notified of the compile-time errors in the program. Note that all homeworks will require submission of both your code and README.txt file to receive full credit.
|
|
||||||
|
|
||||||
The compiler errors we have introduced are pretty simple to fix. Please do so, and then re-compile the program. Once you have removed all of the errors, you are ready to execute the program by typing:
|
|
||||||
|
|
||||||
```console
|
|
||||||
./quadratic.exe
|
|
||||||
```
|
|
||||||
|
|
||||||
After testing the program on your own machine with a variety of inputs and convincing yourself that everything looks good, then you can “Re-submit” the fixed version of the lab code to the homework server: Assuming your fixes are cross-platform compatible, the re-submission should successfully compile and run without error. Note that Submitty allows you to review the autograding results of all prior submissions.
|
|
||||||
|
|
||||||
### To complete Checkpoint 1:
|
|
||||||
Show one of the TAs the compiler errors that you obtained in the g++/clang++ development environment on your machine and the response from the homework submission server indicating the same compiler errors. Also show the edits you made to the code to fix these problems both on your machine and on Submitty.
|
|
||||||
|
|
||||||
## Checkpoint 2:
|
|
||||||
*estimate: 30 minutes*
|
|
||||||
|
|
||||||
Now let's write a brand new C++ program to learn about command line
|
|
||||||
arguments. First open up a brand new file named `silly.cpp`.
|
|
||||||
Include <iostream> at the top of the file.
|
|
||||||
|
|
||||||
Read this [Programming Information](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/programming_information.php) explaining command line arguments in C++. You may also want to refer to the lecture notes for array syntax.
|
|
||||||
|
|
||||||
- To start, let's write a program that expects only integers on the
|
|
||||||
command line, and it will print the product (multiplication) of those
|
|
||||||
numbers to the console (`std::cout`).
|
|
||||||
|
|
||||||
Compile and test your program:
|
|
||||||
```console
|
|
||||||
g++ -Wall -g -o silly.out silly.cpp
|
|
||||||
```
|
|
||||||
|
|
||||||
If we run:
|
|
||||||
```console
|
|
||||||
./silly.out 2 3 4
|
|
||||||
```
|
|
||||||
|
|
||||||
Then program will print:
|
|
||||||
```console
|
|
||||||
product of integers: 24
|
|
||||||
```
|
|
||||||
|
|
||||||
And if we run:
|
|
||||||
```console
|
|
||||||
./silly.out 3 -1 2 20 5
|
|
||||||
```
|
|
||||||
|
|
||||||
Then program will print:
|
|
||||||
```console
|
|
||||||
product of integers: -600
|
|
||||||
```
|
|
||||||
|
|
||||||
*Hint: Read the section of the course webpage on converting strings to integers.*
|
|
||||||
|
|
||||||
### To complete Checkpoint 2:
|
|
||||||
Show a TA or mentor your program. Be ready to demonstrate that your program works with other input requested by the TA or mentor.
|
|
||||||
|
|
||||||
## Checkpoint 3: File IO
|
|
||||||
*estimate: 30 minutes*
|
|
||||||
|
|
||||||
In lecture we talked about how to use the STL file stream library fstream to read data from a file and/or write the output to a file. Let's do some exercises.
|
|
||||||
|
|
||||||
Write a C++ program which reads this [json file](users.json), and print all user names into an output file called output.txt. Your output file must be the same as this [sample output file](sample_output.txt).
|
|
||||||
|
|
||||||
### To complete Checkpoint 3:
|
|
||||||
Show a TA or mentor your program. Your program must produce the right output and you must be able to explain your program.
|
|
||||||
|
|
||||||
## SPECIAL NOTE FOR FIRST WEEK OF CLASSES
|
|
||||||
|
|
||||||
Normally, all lab checkpoints must be earned during your mandatory study group time block.
|
|
||||||
|
|
||||||
However, these lab exercises involved installing new software (which
|
|
||||||
can cause unexpected delays and problems) and some students may have encountered scheduling problems.
|
|
||||||
|
|
||||||
Therefore, for the first lab only, we will allow students to *makeup* the lab checkpoints during office hours. You may attend any office hour time block and be *checked off* by any TA or mentor.
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
LAB 1: GETTING STARTED
|
|
||||||
|
|
||||||
|
|
||||||
NAME: < insert name >
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
COLLABORATORS AND OTHER RESOURCES:
|
|
||||||
List the names of everyone you talked to in the first lecture & first
|
|
||||||
lab (classmates, graduate TAs, undergraduate programming mentors, ALAC
|
|
||||||
tutors, upperclassmen, students/instructor via LMS, etc.), and all of
|
|
||||||
the resources (books, online reference material, etc.) you consulted
|
|
||||||
in completing this assignment.
|
|
||||||
|
|
||||||
|
|
||||||
< insert collaborators / resources >
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NAMES OF YOUR TA & MENTORS
|
|
||||||
|
|
||||||
Who is your graduate lab TA?
|
|
||||||
|
|
||||||
<insert name>
|
|
||||||
|
|
||||||
Who are the undergraduate programming mentors assigned to your lab?
|
|
||||||
|
|
||||||
<insert names>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
#include <iostream> // library for reading & writing from the console/keyboard
|
|
||||||
#include <cmath> // library with the square root function & absolute value
|
|
||||||
#include <cstdlib> // library with the exit function
|
|
||||||
|
|
||||||
|
|
||||||
// Returns true if the candidate root is indeed a root of the polynomial a*x*x + b*x + c = 0
|
|
||||||
bool check_root(int a, int b, int c, float root) {
|
|
||||||
// plug the value into the formula
|
|
||||||
float check = a * root * root + b * root + c;
|
|
||||||
// see if the absolute value is zero (within a small tolerance)
|
|
||||||
if (fabs(check) > 0.0001) {
|
|
||||||
std::cerr << "ERROR: " << root << " is not a root of this formula." << std::endl;
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use the quadratic formula to find the two real roots of polynomial. Returns
|
|
||||||
true if the roots are real, returns false if the roots are imaginary. If the roots
|
|
||||||
are real, they are returned through the reference parameters root_pos and root_neg. */
|
|
||||||
bool find_roots(int a, int b, int c, float &root_pos, float &root_neg) {
|
|
||||||
// compute the quantity under the radical of the quadratic formula
|
|
||||||
int radical = b*b - 4*a*c;
|
|
||||||
// if the radical is negative, the roots are imaginary
|
|
||||||
if (radical < 0) {
|
|
||||||
std::cerr << "ERROR: Imaginary roots" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
float sqrt_radical = sqrt(radikal);
|
|
||||||
// compute the two roots
|
|
||||||
root_1 = (-b + sqrt_radical) / 2*a;
|
|
||||||
root_2 = (-b - sqrt_radical) / 2*a;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
// We will loop until we are given a polynomial with real roots
|
|
||||||
while (true) {
|
|
||||||
std::cout << "Enter 3 integer coefficients to a quadratic function: a*x*x + b*x + c = 0" << std::endl;
|
|
||||||
int my_a, my_b, my_c;
|
|
||||||
std::cin >> my_a >> my_b >> my_c;
|
|
||||||
// create a place to store the roots
|
|
||||||
float root_1, root_2;
|
|
||||||
bool success = find_roots(my_a,my_b,my_c, root_1,root_2);
|
|
||||||
// If the polynomial has imaginary roots, skip the rest of this loop and start over
|
|
||||||
if (!success) continue;
|
|
||||||
std::cout << "The roots are: " << root_1 << " and " << root_2 << std::endl;
|
|
||||||
// Check our work...
|
|
||||||
if (check_root(my_a,my_b,my_c, root_1) && check_root(my_a,my_b,my_c, root_2) {
|
|
||||||
// Verified roots, break out of the while loop
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
std::cerr << "ERROR: Unable to verify one or both roots." << std::endl;
|
|
||||||
// if the program has an error, we choose to exit with a
|
|
||||||
// non-zero error code
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// by convention, main should return zero when the program finishes normally
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
taylorswift
|
|
||||||
jenniferaniston
|
|
||||||
nbcsnl
|
|
||||||
easymoneysniper
|
|
||||||
agt
|
|
||||||
justinbieber
|
|
||||||
jaytatum0
|
|
||||||
andrewyang
|
|
||||||
nicolekidman
|
|
||||||
chelseafc
|
|
||||||
lakers
|
|
||||||
carrieunderwood
|
|
||||||
cnn
|
|
||||||
cmpulisic
|
|
||||||
andersoncooper
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{"id": "11830955", "username": "taylorswift", "url": "https://www.instagram.com/taylorswift", "fullName": "Taylor Swift", "biography": "I’m the problem, it’s me", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "21388754496", "username": "jenniferaniston", "url": "https://www.instagram.com/jenniferaniston", "fullName": "Jennifer Aniston", "biography": "My friends call me Jen.\nFounder, @lolavie.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "218738123", "username": "nbcsnl", "url": "https://www.instagram.com/nbcsnl", "fullName": "Saturday Night Live", "biography": "The official Instagram of Saturday Night Live.\nWatch on @nbc and @peacock. Streaming next day on Peacock.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "false", "messageRequests": "false"}]}
|
|
||||||
{"id": "13864937", "username": "easymoneysniper", "url": "https://www.instagram.com/easymoneysniper", "fullName": "", "biography": "", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "false", "comments": "false", "newFollowers": "false", "messageRequests": "false"}]}
|
|
||||||
{"id": "255788740", "username": "agt", "url": "https://www.instagram.com/agt", "fullName": "America's Got Talent - AGT", "biography": "Two minutes can change your life. #AGT: Fantasy League premieres Monday, January 1 on @nbc and streaming on @peacock.", "notifications": [{"pauseAll": "true", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "6860189", "username": "justinbieber", "url": "https://www.instagram.com/justinbieber", "fullName": "Justin Bieber", "biography": "JUSTICE the album out now\n@drewhouse", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "41157727", "username": "jaytatum0", "url": "https://www.instagram.com/jaytatum0", "fullName": "Jayson Tatum🙏🏀", "biography": "In Jesus Name I Play 🙏\nOh yeah I'm from the LOU\n@enjoysmallwins", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "false", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "3969496290", "username": "andrewyang", "url": "https://www.instagram.com/andrewyang", "fullName": "Andrew Yang", "biography": "Entrepreneur, Dad, Champion of a Human-Centered Economy, <202a>#YangGang<202c>, <202a>#Forwardist<202c>, UBI, Founder of Forward Party, NYT bestselling author", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "false"}]}
|
|
||||||
{"id": "1637269350", "username": "nicolekidman", "url": "https://www.instagram.com/nicolekidman", "fullName": "Nicole Kidman", "biography": "@BlossomFilms", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "false", "messageRequests": "false"}]}
|
|
||||||
{"id": "244309106", "username": "chelseafc", "url": "https://www.instagram.com/chelseafc", "fullName": "Chelsea FC", "biography": "", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "false"}]}
|
|
||||||
{"id": "16917874", "username": "lakers", "url": "https://www.instagram.com/lakers", "fullName": "Los Angeles Lakers", "biography": "Welcome to the #LakeShow\n🏆 17x Champions\nWant more? @LakersScene & @loslakers", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "false", "newFollowers": "false", "messageRequests": "true"}]}
|
|
||||||
{"id": "306227985", "username": "carrieunderwood", "url": "https://www.instagram.com/carrieunderwood", "fullName": "Carrie Underwood", "biography": "Official Carrie Underwood Instagram", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "false", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
{"id": "217723373", "username": "cnn", "url": "https://www.instagram.com/cnn", "fullName": "CNN", "biography": "Asking the hard questions and bringing unique perspective from across the globe. This is CNN.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "true", "newFollowers": "false", "messageRequests": "true"}]}
|
|
||||||
{"id": "292388190", "username": "cmpulisic", "url": "https://www.instagram.com/cmpulisic", "fullName": "Christian Pulisic", "biography": "USA & AC Milan 🇺 🇸 ⚽️", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "false", "newFollowers": "false", "messageRequests": "true"}]}
|
|
||||||
{"id": "3071167", "username": "andersoncooper", "url": "https://www.instagram.com/andersoncooper", "fullName": "Anderson Cooper", "biography": "Season 2 of ALL THERE IS, my podcast about grief and loss, starts November 29th.", "notifications": [{"pauseAll": "true", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}
|
|
||||||
Reference in New Issue
Block a user