c109f02t2 - CSE 109 Test 2 20 November 2002 >SUGGESTED...

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

View Full Document Right Arrow Icon
CSE 109 Test 2 20 November 2002 >>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<< 1. Given the class A below, write the declaration and definition (code) for B, a subclass of A so that the code below the first dashed line produces all four characters of the output below the second dashed line. class A {public: A(int x=0); int get(); //returns the value of data private: int data; }; --------------------------------------------------- B a(20); a.display(); --------------------------------------------------- [20] ===================================================== class B : public A {public: B(int x=0); void display(); }; } B::B(int x):A(x){} void B::display(){cout<<'['<<get()<<']';} 2. Assume you have a class HashTable of fixed size 2003 (which is prime), implemented with the data member int table[2003]; The table is meant to store social security numbers and is initialized with 0's. Write the prototype and definition of the HashTable member function "location" which returns -1 if some entry is not in the table and returns the index of an entry if the entry is in the table. "location" should assume that the number itself is used for the hash number and that a quadratic probe is used to store entries. If ht is of type HashTable, the call to location() might be int x=ht.location(30204055); ===============================================
Image of page 1

Info iconThis 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