CP114_assignment 1 with solutions 2003 - CP114 Assignment 1 1 of 3 file/C/School/CP114/2002_2003Files/CP114 Assignment 1.htm Wilfrid Laurier University

CP114_assignment 1 with solutions 2003 - CP114 Assignment 1...

This preview shows page 1 - 3 out of 26 pages.

CP114 Assignment 1 1 of 3 24/08/2006 4:36 PM Wilfrid Laurier University Official Web Site Department of Physics & Computer Science Posted 2003/01/16 10:01 -0500 CP114 Assignment 1 Due 11:00 am, Friday, January 24, 2003 [25 Marks] Assignments generally ask you to Analyze, Design, Implement, and Test programs and functions. Analysis Refers to the documentation provided for an algorithm. This includes variable identification, comments, and preconditions and postconditions. Design Refers to a program or function's algorithm - i.e. the steps taken to solve a programming problem. Implementation Refers to the source code that implements a design. Testing Refers to the tests you run on a complied, running, program implementation. Programs that do not compile and run cannot have tests submitted for them. When writing C code include the following with each function and program you submit unless otherwise requested: Documentation Show your name, student ID, email address, and the date you completed the code. Header Show the program specifications and any formulae used in the program or function. Include preconditions and postconditions. Input Variables Section List and provide comments for any input variables used in the program or function. Output Variables Section List and provide comments for any output variables used in the program or function. Other Variables Section List and provide comments for any variables used in the program or function that are not already listed in the input and output variables section. Body Comments Give useful comments in the body of the program. Use these comments to make your design clear. Implementation Implement your design in C as a project in Dev C++ 4.0. Put all functions in separate files, one file for each function, unless otherwise noted. Testing : Show the output your program produces under a range of inputs. Put your testing in a text file separate from your C source code.
Image of page 1

Subscribe to view the full document.

CP114 Assignment 1 2 of 3 24/08/2006 4:36 PM Question 1 [5 marks] Suppose we have a linked list of BookNode structures. P points to the list as shown in the pointer diagram below: ************** *************** ************** ************* P -->*"Asimov"| x *--->*"Boissard"| x*--->*"Cruise"| x *--->*"Dante"| x *---> NULL ************** *************** ************** ************* Show, using pointer diagrams (use the same format as above), the resulting list and pointers after each of the following statements has been executed in turn (i.e. show 5 pointer diagrams). Assume the X symbols in the nodes have been defined as pointers to BookNode . For parts b), c), d), and e), show both the R and P pointers. [1 mark] P ---> Next ---> Next ---> Next ---> Name = "Jacob" a. [1 mark] R = P --> Next ---> Next ( R , like P , is defined as a pointer to BookNode ) b. [1 mark] P --> Next ---> Next = NULL c. [1 mark] R---> Next ---> Next = P d. [1 mark] R ---> Name = "Lovell" e. Question 2 [5 marks] Using the CityData_t structure given in the file cities.h implement a function Count_City_List() in C that counts the number of cities on a list given a pointer to the list. Be sure to account for the empty list.
Image of page 2
Image of page 3
  • Fall '13
  • sta

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes