Data Str & Algorithm HW Solutions 25

Data Str & Algorithm HW Solutions 25 - n =(20(8(4 8...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
25 // Move curr to prev position template <class Elem> void LList<Elem>::prev() { link* temp = curr; while (temp->next!=curr) temp=temp->next; curr = temp; } (b) The answer is rather similar to that of Part (a). 4.7 The space required by the array-based list implementation is fi xed. It must be at least n spaces to hold n elements, for a lower bound of Ω( n ) . However, the actual number of elements in the array ( n ) can be arbitrarily small compared to the size of the list array. 4.8 D is number of elements; E is in bytes; P is in bytes; and n is number of elements. Setting number of elements as e and number of bytes as b , the equation has form e > eb/ ( b + b ) = eb/b = e for a comparison of e > e which is correct. 4.9 (a) Since E = 8 , P = 4 , and D = 20 , the break-even point occurs when
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n = (20)(8) / (4 + 8) = 13 1 3 . So, the linked list is more ef f cient when 13 or fewer elements are stored. (b) Since E = 2 , P = 4 , and D = 30 , the break-even point occurs when n = (30)(2) / (2 + 4) = 10 . So, the linked list is more ef f cient when less than 10 elements are stored. (c) Since E = 1 , P = 4 , and D = 30 , the break-even point occurs when n = (30)(1) / (1 + 4) = 6 . So, the linked list is more ef f cient when less than 6 elements are stored. (d) Since E = 32 , P = 4 , and D = 40 , the break-even point occurs when n = (40)(32) / (32 + 4) = 35 . 5 . So, the linked list is more ef f cient when 35 or fewer elements are stored....
View Full 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