Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
For any help regarding C++ Homework Help
Visit :- https://www.cpphomeworkhelp.com/ ,
Email :- info@cpphomeworkhelp.com or
Call us at :- +1 678 648 4277
Problem 1: Linked List Library (list)
In this problem we will learn how to write code distributed over multiple files that is compiled
together and linked into one application. Download the zipped folder provided in the file list.zip
as a basis of your program and take a look at the existing code.
First notice the directory structure. The zipped folder contains an include/ directory, a Makefile
which is much larger than the one we’ve been using in the past, a GRADER_INFO.txt file, and a
src/ directory. In general, all of our header (.h) files will be found in include/ while all of our
source (.c) files will be in src/. This is visually represented in Figure 1 on the left. Now, let’s run
make (just the command make, with nothing following that one word).
Figure 1: Project directory structure before and after build
C++ Homework Help
Notice there have been three files created: for every .c file, there’s been a .o object file created.
These files are linked together into the list-text.x program, which you can run. Some important
points:
• All of the implementation code you will write should go in the list.c file.
• GRADER INFO.txt is a file for the grader (don’t edit!) containing the usual PROG: list,
LANG: C
• Important information for submitting your code: you should submit a zipped folder using
the same directory structure as the provided zip file. We’ve added a section in the Makefile
for your convenience: if you type make zip in the same folder as your project, a zip file
containing all of your code and the required headers will be constructed in the project
directory and you can upload that to the grader.
We are provided a header file describing the interface for the List data structure. Three
functions have already been defined for you in list.c: the code to create an empty list with
no items: List the code to destroy all the items in a list:
and some code to print out a representation of a provided list:
C++ Homework Help
Look in the file list.c to find the functionality required of the other functions, which you will write.
C++ Homework Help
Some questions to ask yourself for understanding:
• How do you read the arguments to list apply and list reduce? Re-read this article.
• How is this a valid header to include when we don’t ever define what the struct List node s
really is?
• Why do we sometimes pass a pointer to a List struct and other times pass by value? When
might we want to do it this way and when might we want to be more consistent?
C++ Homework Help
Input Format
Not applicable; your library will be compiled into a testing suite, your implemented functions
will be called by the program, and the behavior checked for correctness. For example, here is a
potential test:
Upon calling this function, the code outputs
{ 0 -> 1 -> 2 -> 3 -> 4 }
C++ Homework Help
You are strongly encouraged to write your own tests in test.cpp so that you can try out your
implementation code before submitting it to the online grader.
Output Format
Not applicable.
WARNING! FREE YOUR MEMORY!
This problem is only worth 300 points on the online submission system when you upload
it. This is because your code will be checked for memory leaks. No memory leaks (a clean
run in valgrind on our side) earns full points for a total of 400. Egregiously bad allocation,
incorrect memory accesses, and lack of cleanup can result in as low as 300 points out of
400 maximum, even if all test cases are passing.
C++ Homework Help
C++ Homework Help
C++ Homework Help
C++ Homework Help
C++ Homework Help
Below is the output using the test data:
C++ Homework Help
list:
1: OK [0.002 seconds] OK!
2: OK [0.004 seconds] OK!
3: OK [0.035 seconds] OK!
4: OK [2.175 seconds] OK!
5: OK [0.133 seconds] OK!
6: OK [0.305 seconds] OK!
7: OK [0.061 seconds] OK!
8: OK [0.213 seconds] OK!
9: OK [0.002 seconds] OK!
10: OK [1.054 seconds] OK!
C++ Homework Help

More Related Content

Online CPP Homework Help

  • 1. For any help regarding C++ Homework Help Visit :- https://www.cpphomeworkhelp.com/ , Email :- info@cpphomeworkhelp.com or Call us at :- +1 678 648 4277
  • 2. Problem 1: Linked List Library (list) In this problem we will learn how to write code distributed over multiple files that is compiled together and linked into one application. Download the zipped folder provided in the file list.zip as a basis of your program and take a look at the existing code. First notice the directory structure. The zipped folder contains an include/ directory, a Makefile which is much larger than the one we’ve been using in the past, a GRADER_INFO.txt file, and a src/ directory. In general, all of our header (.h) files will be found in include/ while all of our source (.c) files will be in src/. This is visually represented in Figure 1 on the left. Now, let’s run make (just the command make, with nothing following that one word). Figure 1: Project directory structure before and after build C++ Homework Help
  • 3. Notice there have been three files created: for every .c file, there’s been a .o object file created. These files are linked together into the list-text.x program, which you can run. Some important points: • All of the implementation code you will write should go in the list.c file. • GRADER INFO.txt is a file for the grader (don’t edit!) containing the usual PROG: list, LANG: C • Important information for submitting your code: you should submit a zipped folder using the same directory structure as the provided zip file. We’ve added a section in the Makefile for your convenience: if you type make zip in the same folder as your project, a zip file containing all of your code and the required headers will be constructed in the project directory and you can upload that to the grader. We are provided a header file describing the interface for the List data structure. Three functions have already been defined for you in list.c: the code to create an empty list with no items: List the code to destroy all the items in a list: and some code to print out a representation of a provided list: C++ Homework Help
  • 4. Look in the file list.c to find the functionality required of the other functions, which you will write. C++ Homework Help
  • 5. Some questions to ask yourself for understanding: • How do you read the arguments to list apply and list reduce? Re-read this article. • How is this a valid header to include when we don’t ever define what the struct List node s really is? • Why do we sometimes pass a pointer to a List struct and other times pass by value? When might we want to do it this way and when might we want to be more consistent? C++ Homework Help
  • 6. Input Format Not applicable; your library will be compiled into a testing suite, your implemented functions will be called by the program, and the behavior checked for correctness. For example, here is a potential test: Upon calling this function, the code outputs { 0 -> 1 -> 2 -> 3 -> 4 } C++ Homework Help
  • 7. You are strongly encouraged to write your own tests in test.cpp so that you can try out your implementation code before submitting it to the online grader. Output Format Not applicable. WARNING! FREE YOUR MEMORY! This problem is only worth 300 points on the online submission system when you upload it. This is because your code will be checked for memory leaks. No memory leaks (a clean run in valgrind on our side) earns full points for a total of 400. Egregiously bad allocation, incorrect memory accesses, and lack of cleanup can result in as low as 300 points out of 400 maximum, even if all test cases are passing. C++ Homework Help
  • 12. Below is the output using the test data: C++ Homework Help
  • 13. list: 1: OK [0.002 seconds] OK! 2: OK [0.004 seconds] OK! 3: OK [0.035 seconds] OK! 4: OK [2.175 seconds] OK! 5: OK [0.133 seconds] OK! 6: OK [0.305 seconds] OK! 7: OK [0.061 seconds] OK! 8: OK [0.213 seconds] OK! 9: OK [0.002 seconds] OK! 10: OK [1.054 seconds] OK! C++ Homework Help