Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more.
Course Hero has millions of course specific materials providing students with the best way to expand
their education.
Below is a small sample set of documents:
University of Florida - CHEM - 2045
CHM 2045Exam 2(Form Code A)Spring 2009Instructions: On your scantron sheet enter and bubble in your name, UF ID number (start on theleftmost space and leave any extra spaces blank), and Form Code (see above). You may retain yourexam sheet (mark your
University of Florida - CHEM - 2045
@.@amPloRIhBCDIEAlCDB1~0000 l O 0 0 0 042 1 - 0 u@0008a@3000.040000.s0.0100uOOO0OnOOO008.0000em000a O@OO7@0#08 0@01@0 s O O O 0 Or sOOO0090*000w0000m !a00000ABCOEAICDL10 01. 00ABCDEn 00000~0000012000.0. n0@000sa000@0S O@ t
University of Florida - CHEM - 2045
CHM 2045Final ExamSpring 2009Form Code AInstructions: On your scantron enter and bubble in your name, UF ID number, and Form Code (seeabove). Careful! Bubbling errors will not be negotiated.1. A sample of zinc metal reacts completely with an excess
University of Florida - CHEM - 2045
Form LR1wWT NAME-IITEsTFolMllmDE:I n\MI1111'111'1'1~AECDE1 @'@.12 0@03000.0.@ABCDE41 @ @El4200000,ABCDE2000.0420000013OOOOO4@0@M0@0@3& @a@0C!l.@r O@C@ 4400000IABCDEI @ @ @ @ @ 41 @ @a@s Q@ 45@0@0 s 0 @ 0 @ @ 4 5 0 @ @ @ @60.
University of Florida - CHEM - 2045
CHM 2045 Exam 3 (Form Code A)Spring 2009Instructions: On your scantron sheet enter and bubble in your name, UF ID number (start on the leftmostspace and leave any extra spaces blank), and Form Code (see above). You may retain your exam sheet (markyour
Grantham - SCIENCE - GS104
Ethanol Trade-OffsRicardo C. EstradaG00036382GS104 2011The three advantages of using Ethanol are; reduced CO2 emissions (sugarcanebagasse), high net energy yield (bagasse and switchgrass), and potentially renewable.The world has seen a significant in
UNF - MAP - 2302
1Data Structures and AlgorithmsInstructors note: Unlike the other chapters, many of the questions in this chapterare not really suitable for graded work. The questions are mainly intended to getstudents thinking about data structures issues.1.1 This
UNF - MAP - 2302
2Chap. 1 Data Structures and Algorithms/ Concatenate two stringsString strcat(String s1, String s2);/ Return the length of a stringint length(String s1);/ Extract a substring, starting at start,/ and of length lengthString extract(String s1, int s
UNF - MAP - 2302
31.71.81.91.101.111.12One implementation for the sparse matrix is described in Section 12.3 Another implementation is a hash table whose search key is a concatenation of the matrix coordinates.Every problem certainly does not have an algorithm. As
UNF - MAP - 2302
4Chap. 1 Data Structures and Algorithms1.13 The rst part is easy with the hint, but the second part is rather difcult to do withouta stack.a) bool checkstring(string S) cfw_int count = 0;for (int i=0; i<length(S); i+)if (S[i] = () count+;if (S[i]
UNF - MAP - 2302
2Mathematical Preliminaries2.1(a) Not reexive if the set has any members. One could argue it is symmetric, antisymmetric, and transitive, since no element violate any ofthe rules.(b) Not reexive (for any female). Not symmetric (consider a brother and
UNF - MAP - 2302
6Chap. 2 Mathematical Preliminaries(d) This is not an equivalance relation since it is not symmetric. For example, a = 1 and b = 2.(e) This is an eqivalance relation that divides the rationals based on theirfractional values. It is reexive since for a
UNF - MAP - 2302
7bool isEmpty();/ Return the number of elements with a given valueintcountInBag(int);2.7 The list class ADT from Chapter 4 is a sequence.2.8 long ifact(int n) cfw_ / make n <= 12 so n! for long intlong fact = 1;Assert(n >= 0) & (n <= 12), "Input ou
UNF - MAP - 2302
8Chap. 2 Mathematical Preliminaries2.13 void allpermute(int array[], int n, int currpos) cfw_if (currpos = (n-1) cfw_printout(array);return;for (int i=currpos; i<n; i+) cfw_swap(array, currpos, i);allpermute(array, n, currpos+1);swap(array, curr
UNF - MAP - 2302
9p2q 2 = 4( )22p22q = 2( )2This implies that q 2 is also even. Thus, p and q are both even, which contradicts the requirement that p and q have no common factors. Thus, 2 mustbe irrational.2.17 The leftmost summation sums the integers from 1 to
UNF - MAP - 2302
10Chap. 2 Mathematical Preliminaries(c) Induction Step.ni=112in1=i=1= 111+ni2212n1+12n1.2nThus, the theorem is proved by mathematical induction.2.20 Proof:(a) Base case. For n = 0, 20 = 21 1 = 1. Thus, the formula is correctfor
UNF - MAP - 2302
112.22 Theorem 2.1ni=1 (2i)= n2 + n.(a) Proof: We know from Example 2.3 that the sum of the rst n oddnumbers is n2 . The ith even number is simply one greater than the ithodd number. Since we are adding n such numbers, the sum must be ngreater, or
UNF - MAP - 2302
12Chap. 2 Mathematical Preliminaries8 5 n2()3355< ( )2 ( )n2335n=.3=Thus, the theorem is proved by mathematical induction.2.24 Proof:22(a) Base case. For n = 1, 13 = 1 (1+1) = 1. Thus, the formula is correct4for the base case.(b) Induc
UNF - MAP - 2302
13iii. Induction Step. Consider the case where n + 1 pigeons are in nholes. Eliminate one hole at random. If it contains one pigeon,eliminate it as well, and by the induction hypothesis some otherhole must contain at least two pigeons. If it contains
UNF - MAP - 2302
14Chap. 2 Mathematical PreliminariesInduction hypothesis: T(n 1) = 2n1 1.Induction step:T(n) = 2T(n 1) + 1= 2(2n1 1) + 1= 2n 1.Thus, as proved by mathematical induction, this formula is indeed the correctclosed form solution for the recurrence.2.
UNF - MAP - 2302
152.32 (I saw this problem in John Bentleys Programming Pearls.) Approach 1:The model is Depth X Width X Flow where Depth and Width are in milesand Flow is in miles/day. The Mississippi river at its mouth is about 1/4 milewide and 100 feet (1/50 mile)
UNF - MAP - 2302
16Chap. 2 Mathematical Preliminaries2.37 An hour has 3600 seconds, so one million seconds is a bit less than 300 hours.A good estimater will notice that 3600 is about 10% greater than 3333, so theactual number of hours is about 10% less than 300, or c
UNF - MAP - 2302
3Algorithm Analysis3.1 Note that n is a positive integer.5n log n is most efcient for n = 1.2n is most efcient when 2 n 4.10n is most efcient for all n > 5. 20n and 2n are never moreefcient than the other choices.3.2Both log3 n and log2 n will hav
UNF - MAP - 2302
18Chap. 3 Algorithm Analysis3.8 Other values for n0 and c are possible than what is given here.(a) The upper bound is O(n) for n0 > 0 and c = c1 . The lower bound is(n) for n0 > 0 and c = c1 .(b) The upper bound is O(n3 ) for n0 > c3 and c = c2 + 1.
UNF - MAP - 2302
193.11(a)nnn! = n (n 1) ( 1) 2 122nnn 1 1 1222n n/2=()2Thereforenlg n! lg2(b) This part is easy, since clearlyn21 (n lg n n).21 2 3 n < n n n n,so n! < nn yielding log n! < n log n.3.12 Clearly this recurrence is in O(log n n)
UNF - MAP - 2302
20Chap. 3 Algorithm Analysis3.15 Yes. When we specify an upper or lower bound, that merely states our knowledge of the situation. If they do not meet, that merely means that we dontKNOW more about the problem. When we understand the problem completely,
UNF - MAP - 2302
21binary search of the subarray will nd the position n in an additional log nsearches at most, for a total cost in O(log n) searches.3.19 Here is a description for a simple (n2 ) algorithm.boolean Corner(int n, int m, Piece P1, Piece* array) cfw_for
UNF - MAP - 2302
22Chap. 3 Algorithm AnalysisSWAP(array[i][j], array[tempr][tempc]);Finding the corner takes O(n2 m2 ) time, which is the square of the number ofpieces. Filling in the rest of the pieces also takes O(n2 m2 ) time, the numberof pieces squared. Thus,
UNF - MAP - 2302
4Lists, Stacks, and Queues4.1 Call the list in question L1.L1.setStart();L1.next();L1.next();val = L1.remove();4.2(a) | 10, 20, 15 .(b) 39 | 12, 10, 20, 15 .4.3 list L1(20);L1.append(2);L1.append(23);L1.append(15);L1.append(5);L1.append(9);
UNF - MAP - 2302
24Chap. 4 Lists, Stacks, and Queueslink<Elem>* temp1 = head->next;link<Elem>* temp2 = temp1->next;while (temp2 != NULL) cfw_link<Elem>* temp3 = temp2->next;temp2->next = temp1;temp1 = temp2;temp2 = temp3;head->next = temp1;4.6(a) The followin
UNF - MAP - 2302
25/ Move curr to prev positiontemplate <class Elem>void LList<Elem>:prev() cfw_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 l
UNF - MAP - 2302
26Chap. 4 Lists, Stacks, and Queues4.10 I assume an int requires 4 bytes, a double requires 8 bytes, and a pointerrequires 4 bytes.(a) Since E = 4 and P = 4, the break-even point occurs when1n = 4D/8 = D.2Thus, the linked list is more space efcien
UNF - MAP - 2302
27AStack2() cfw_ delete [] listArray; / Destructorvoid clear(int st) cfw_if (st = 1) top1 = 0;else top2 = size - 1;bool push(int st, const Elem& item) cfw_if (top1+1 >= top2) return false; / Stack is fullif (st = 1) listarray[top1+] = item;else l
UNF - MAP - 2302
28Chap. 4 Lists, Stacks, and QueueslistArray = new Elem[size];isEmpty = true;AQueue() cfw_ delete [] listArray; / Destructorvoid clear() cfw_ front = rear; isEmpty = true; bool enqueue(const Elem& it) cfw_if (isEmpty != true) &(rear+1) % size) =
UC Irvine - BME - 110A
(I) Short problems, warm up1. Consider the following four matrices:1123411 21 32 642 = ; = 7 8 9 ; = 0 5 6 7 ; = 80 45 36 77 ;3809084 6 96 304Calculate the following:i) inner product between a and Aii) inner product
UC Irvine - ECON - 20B
Econ 20B- Additional Problem Set I. MULTIPLE CHOICES. Choose the one alternative that best completes the statement to answer the question. 1According to the theory of liquidity preference, the money supply a. and money demand are positively related to the
UNF - MAP - 2302
294.15 FIBobj stores a value and an operand type. If the operand is IN, then thevalue is a parameter to the Fibonacci function. If the operand is OUT, thenthe value is an intermediate result. When we pop of an IN value, it mustbe evaluated. When we h
UC Irvine - PHYSICS - 7C
Name (print clearly!):Signature:ID Number:Discussion TA:Discussion Day:Hour:Date:Midterm 1Physics 7C Tait (version 1)Closed book; you may use a calculator, but no other electronic devices,including cell phones, iPods, etc. For full credit, you m
UNF - MAP - 2302
30Chap. 4 Lists, Stacks, and Queuesf.val += val;s.push(f);else cfw_ / switch order to evaluate 2nd operandFIBobj temp;temp.val = val; temp.op = OUT;S.push (f);S.push (temp);return val; / Correct result should be in val now4.16 The stack-bas
UNF - MAP - 2302
314.19 Some additional access capability must be added. One approach is to addmore pointers to the linked list structure. By granting direct access half wayin, from there to the quarter lists, etc., it is possible to gain O(log n) insertand search t
UNF - MAP - 2302
5Binary Trees5.1 Consider a non-full binary tree. By denition, this tree must have some internal node X with only one non-empty child. If we modify the tree to removeX , replacing it with its child, the modied tree will have a higher fraction ofnon-em
UNF - MAP - 2302
335.3 Base Case: For the tree of one leaf node, I = 0, E = 0, n = 0, so thetheorem holds.Induction Hypothesis: The theorem holds for the full binary tree containingn internal nodes.Induction Step: Take an arbitrary tree (call it T) of n internal node
UNF - MAP - 2302
34Chap. 5 Binary Trees5.6 The key is to use a queue to store subtrees to be processed.template <class Elem>void level(BinNode<Elem>* subroot) cfw_AQueue<BinNode<Elem>*> Q;Q.enqueue(subroot);while(!Q.isEmpty() cfw_BinNode<Elem>* temp;Q.dequeue(tem
UNF - MAP - 2302
35x leaf nodes:4x= 4/8 = 50%.4x + 4x5.10 If equal valued nodes were allowed to appear in either subtree, then during asearch for all nodes of a given value, whenever we encounter a node of thatvalue the search would be required to search in both di
UNF - MAP - 2302
365.18Chap. 5 Binary Trees(a) The array will take on the following order:653421The value 7 will be at the end of the array.(b) The array will take on the following order:746321The value 5 will be at the end of the array.5.19 / Min-heap
UNF - MAP - 2302
37swap(Heap, pos, j);pos = j;/ Move downtemplate <class Elem, class Comp>bool minheap<Elem, Comp>:insert(const Elem& val) cfw_if (n >= size) return false; / Heap is fullint curr = n+;Heap[curr] = val;/ Start at end of heap/ Now sift up until c
UNF - MAP - 2302
38Chap. 5 Binary Trees/ Remove value at specified positiontemplate <class Elem, class Comp>bool minheap<Elem, Comp>:remove(int pos, Elem& it) cfw_if (pos < 0) | (pos >= n) return false; / Bad posswap(Heap, pos, -n);/ Swap with last valuewhile (pos
UNF - MAP - 2302
39The average code length is 3.234455.22 The set of sixteen characters with equal weight will create a Huffman codingtree that is complete with 16 leaf nodes all at depth 4. Thus, the average codelength will be 4 bits. This is identical to the xed len
UNF - MAP - 2302
6General Trees6.1 The following algorithm is linear on the size of the two trees./ Return TRUE iff t1 and t2 are roots of identical/ general treestemplate <class Elem>bool Compare(GTNode<Elem>* t1, GTNode<Elem>* t2) cfw_GTNode<Elem> *c1, *c2;if (t
UNF - MAP - 2302
41if (t1->val() != t2->val() return false;if (Compare2(t1->leftchild(), t2->leftchild()if (Compare2(t1->rightchild(), t2->rightchild()return true;if (Compare2(t1->leftchild(), t2->rightchild()if (Compare2(t1->rightchild(), t2->leftchild)return true
UNF - MAP - 2302
42Chap. 6 General TreesNode0Parent 41424344 -1546470809 10 11 12 13 14 154 9 9 9 12 9 -16.8 For eight nodes labeled 0 through 7, use the following series of equivalences:(0, 1) (2, 3) (4, 5) (6, 7) (4 6) (0, 2) (4 0)This requires ch
UNF - MAP - 2302
43GTNode<Elem>* gtemp = genroot->leftmost_child();btemp = new BinNode(genroot->val(), convert(gtemp),convert(genroot->right_sibling();6.116.12(a)Parent(r) = (r 1)/k if 0 < r < n.Ith child(r) = kr + I if kr + I < n.Left sibling(r) = r 1 if r mod
UNF - MAP - 2302
446.16Chap. 6 General Trees(a) / Use a helper function with a pass-by-reference/ variable to indicate current position in the/ node list.template <class Elem>BinNode<Elem>* convert(char* inlist) cfw_int curr = 0;return converthelp(inlist, curr);
UNF - MAP - 2302
45curr+ / Eat the internal node mark.temp->left = converthelp(inlist, curr);temp->right = converthelp(inlist, curr);return temp;(c) / Use a helper function with a pass-by-reference/ variable to indicate current position in the/ node list.template
UNF - MAP - 2302
7Internal Sorting7.1 Base Case: For the list of one element, the double loop is not executed andthe list is not processed. Thus, the list of one element remains unaltered andis sorted.Induction Hypothesis: Assume that the list of n elements is sorted
UNF - MAP - 2302
477.3 The revised algorithm will work correctly, and its asymptotic complexity willremain (n2 ). However, it will do about twice as many comparisons, since itwill compare adjacent elements within the portion of the list already knownto be sorted. Thes
UNF - MAP - 2302
48Chap. 7 Internal Sorting Conceptually (in particular, the linked list version) Mergesort is stable.The array implementations are NOT stable, since, given that the sublistsare stable, the merge operation will pick the element from the lower listbefo
UNF - MAP - 2302
49264013577.9(a) Each call to qsort costs (i log i). Thus, the total cost isni log i = (n2 log n).i=17.107.117.127.13(b) Each call to qsort costs (n log n) for length(L) = n, so the totalcost is (n2 log n).All that we need to do is redene the
UNF - MAP - 2302
50Chap. 7 Internal SortingN7 N8 N9B10B11Again, at each line, there is no information available about the relationshipsof those objects.To merge two such lists, we can do a normal merge, until we reach the pointwere we either compare an element (sa
UNF - MAP - 2302
51Best case: 2 compares.Avg case: 16/6 = 2 2/3 compares.Worst case: 3 compares.(b) Doing a similar approach of building a decision tree for 5 numbersis somewhat overwhelming since there are 120 permutations. A prettygood algorithm can be had be buil
UNF - MAP - 2302
52Chap. 7 Internal SortingSort. Thus, the calls to Insertion Sort are equivalent to the leaf nodes of a fullbinary tree. We know from the Full Binary Tree Theorem that the number ofleaf nodes in a full binary tree of n nodes is n/2 . Thus, if there ar