Data Str & Algorithm HW Solutions 25

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

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

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online