c17s99t2 - CSc 17 Test 2 Thursday 8 April 1999.>ANSWERS<...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 17 Test 2 Thursday 8 April 1999 ..... >>>>>>>>>>>>>>>>>>>>>>ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (10 pts) Assume the following data structure is used to create a linked list: class Link{public: int key,next; }; class LinkedList{ private: int head,count; Link data[10]; public: //other stufff } Further suppose that data have been loaded into the array as depicted in the first row of the table below but that the data are not yet linked together. Complete the first row by filling in the value for head. Also, fill out as many of the remaining rows as is necessary to show the state of the data structure after each of the entries Link[0], Link[1],..., Link[3] is added to the list. Note that a link is depicted as ------ | key | | next| ------- head count Link[0] Link[1] Link[2] Link[3] Link[4] Link[5] ....... ----------------------------------------------------------------------- | -1 | 4 | 5 | 6 | -3 | 10 | | | ....... -----------| | | | | | | ....... ----------------------------------------------------------------------- | 0 | 4 | 5 | 6 | -3 | 10 | | | ....... -----------| -1 | | | | | | ....... ----------------------------------------------------------------------- | 0 | 4 | 5 | 6 | -3 | 10 | | | ....... -----------| 1 | -1 | | | | | ....... ----------------------------------------------------------------------- | 2 | 4 | 5 | 6 | -3 | 10 | | | ....... -----------| 1 | -1 | 0 | | | | ....... ----------------------------------------------------------------------- | 2 | 4 | 5 | 6 | -3 | 10 | | | ....... -----------| 1 | 3 | 0 | -1 | | | ....... ----------------------------------------------------------------------- 2. (25 pts) An array x[0], x[1], ..... ,x[n] is "symmetric" if listing the data in the order x[0], x[1],..., x[n] produces the same list as that obtained by listing the data in the order x[n], x[n-1],...,x[0]. Thus, the array x[0]=1, x[1]=2, x[2]=3, x[3]=3, x[4]=2, x[5]=1 is symmetric.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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