3 Pages

mid1a

Course: ICS 261, Fall 2009
School: CSU Channel Islands
Rating:
 
 
 
 
 

Word Count: 992

Document Preview

261 ICS Fall 2002 Data Structures Midterm 1 Answers Comments on the grading are given in smaller type after the answers. Part I Version A: 1. C 2. C 3. B 4. B 5. B 6. E 7. C 8. C 9. B Version B: 1. B 2. C 3. B 4. D 5. D 6. E 7. C 8. A 9. B Part II. 10. (Here "3x" means 33 on Version A and 37 on Version B.) We add 3x as a right child of the node containing 30. Then the deepest imbalanced node is...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> CSU Channel Islands >> ICS 261

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.

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.
261 ICS Fall 2002 Data Structures Midterm 1 Answers Comments on the grading are given in smaller type after the answers. Part I Version A: 1. C 2. C 3. B 4. B 5. B 6. E 7. C 8. C 9. B Version B: 1. B 2. C 3. B 4. D 5. D 6. E 7. C 8. A 9. B Part II. 10. (Here "3x" means 33 on Version A and 37 on Version B.) We add 3x as a right child of the node containing 30. Then the deepest imbalanced node is 20, with a balance of +2, and its right child has balance -1. Therefore we do a double left rotation at that node, obtaining 60 30 20 10 3x 40 50 70 80 (On many of your answers you will see lines drawn enclosing nodes that are about to be involved in a rotation; I drew these to help me understand your answers.) Here are examples of credit for answers that were not completely correct. 10: The insertion was done correctly, and work was shown, but there was an error in an intermediate step. 8: The insertion was done correctly except that the 50 was omitted in the final answer, and work was shown. 6: The double rotation was done one level too high in the tree. This yields the following tree, which does turn out to be a valid AVL tree. 40 20 10 30 3x 50 70 60 80 7: As above, but the deepest imbalanced node was correctly identified as 20. 6: The insertion was done correctly except that 70 was omitted from the tree, and therefore another rotation had to be done to make the tree an AVL tree. 5: The insertion was done incorrectly by splicing in the 3x above the 30, but then the correct rotation was done given this starting point, and the final tree was an AVL tree. 4: Doing the insertion correctly and then doing an incorrect series of rotations that I could not follow, or doing a pseudosplay at 3x, but still winding up with an AVL tree. 2: Doing the binary search tree insertion correctly, but then thinking that the tree was balanced and not doing any rotations. ICS 261 Fall 2002 Midterm 1 Answers 1: Doing a sequence of rotations that I could not follow, and winding up with a tree that was not an AVL tree or binary search tree. 11. a) i. No ii. Yes iii. Yes, T4 could have a red root (since its original parent C was black), in which case in the new tree the root of T4 and its parent B would be two consecutive red nodes on a path from a leaf to the root. b) i. Yes ii. No be red. iii. Yes, A is a red node with a red parent. Also, B's parent could c) i. Yes ii. Yes iii. Yes, if B's parent was also red, B and its parent would be two consecutive red nodes on a path from a leaf to the root. For parts (i) and (ii) of each case, a simple yes or no sufficed. Each of these was worth 1 point, and I tended to give this point for the correct yes-no answer even if there was an explanation that didn't make much sense to me. For part (iii) of each case, required I that the specific problem be identified. This part was worth 2 points for each case. Examples of credit are: 0: Saying there is a problem, but giving an incorrect problem or just repeating a problem identified in part (i) or (ii). 1: Saying there is a problem and giving a partially correct explanation. Examples are saying "T1 , T2 , T3 , T4 could have red roots" for case (a), or saying "A should be black" in case (b). 2: Repeating one of the problems identified in part (i) or (ii), but also giving a new problem. 12. The key observation is that a tree on 2k keys will be an augmented perfect tree if and only if one of its subtrees is a perfect tree on 2k-1 - 1 nodes and the other subtree is an augmented perfect tree on 2k-1 nodes. This happens if and only if a) the first key inserted is 2k-1 , the left subtree is a perfect tree on 2k-1 - 1 nodes, and the right subtree is an augmented perfect tree on 2k-1 nodes, or b) the first key inserted is 2k-1 + 1, the left subtree is an augmented perfect tree on 2k-1 nodes, and the right subtree is a perfect tree on 2k-1 - 1 nodes. The probability that any particular key is the first to be inserted is 2-k . For each case above, if the given key is the first inserted, the left and right subtrees are independent so the probability that they both have the required shapes is qk-1 rk-1 . Thus the probability of each case is 2-k qk-1 rk-1 Adding the probability of the two cases gives qk = 2 2-k qk-1 rk-1 = qk-1 rk-1 . 2k-1 The final formula was worth 9 points, and the explanation was worth 3 points. Most of you will see a notation of the form a, b below your answer, where...

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:

CSU Channel Islands - ICS - 161
CS 161-Spring 2007 Design and Analysis of Algorithms Homework 1 Answers 1. By the definition of g(n) f (n) , we have to produce a constant c and an integer n0 such that n n0 , g(n) cf (n). In our case, g(n) = 3n2 - 7n and f (n) = n2 , so we want
CSU Channel Islands - ICS - 161
CS 161 Spring 2007 Design and Analysis of Algorithms Midterm 2-Version A May 31, 2007 This is a closed-book test. You may not use calculators, books, or notes during the exam. Please write all of your answers on the answer sheet, and write your name
CSU Channel Islands - ICS - 161
CS 161-Spring 2007 Design and Analysis of Algorithms Homework 5 Answers 1. We have f0 (X) = 0 - if X 0 if X < 0The recurrence for fk [X] is very similar to that used for the Zero-One Knapsack problem discussed in class, except we have to add a cas
CSU Channel Islands - ICS - 161
ICS 161-Spring 2007 Design and Analysis of Algorithms Notation for growth rates In both ICS 23 and 161, a major goal is the design and analysis of efficient solutions to problems. At first it might appear that it would be hard to make precise stateme
CSU Channel Islands - ICS - 260
ICS 260-Winter 2009 Fundamentals of the Design and Analysis of Algorithms Homework 3 Due date: February 17 in class Feel free to discuss these exercises with other students as you work on them, but what you turn in should be something you have writte
CSU Channel Islands - ICS - 261
ICS 261 Fall 2001 Data Structures Midterm 1 AnswersComments on the grading are given in smaller type after the answers.Part I Version A: 1. A 2. D 3. B 4. C 5. B 6. B 7. A 8. B 9. E 10. C Version B: 1. A 2. E 3. B 4. C 5. B 6. C 7. A 8. B 9. E 10.
CSU Channel Islands - ICS - 261
ICS 261 Spring 1998 Data Structures Midterm 1 Answers and Comments on the Grading Here are the answers for the first midterm. Also, in a smaller font, are some comments on the grading. 1. [6] Leftist heaps and binomial heaps, unlike d-heaps, allow on
CSU Channel Islands - ICS - 261
ICS 261-Fall 2002 Fundamental Data Structures Course Outline Readings relevant to topics are given in square brackets after that topic. Numbers are chapters in the text by Cormen, Leiserson, Rivest, and Stein (Introduction to Algorithms, Second Editi
CSU Channel Islands - ICS - 261
ICS 261 Fall 2000 Data Structures Revised Midterm 2 Answers The maximum possible score was 100.Comments on the grading are given in smaller type after the answers.Part I 1. Version A: a) Three trees, of sizes 32, 8, and 1 b) 5 + 3 + 0 = 8 Version
CSU Channel Islands - ICS - 261
ICS 261 Spring 1998 Data Structures Midterm 2-June 4, 1998 Version AThis is a closed-book test. No notes, books, or calculators may be used. Please write all of your answers on the answer sheet, and write your name and ID number, as well as the tes
CSU Channel Islands - ICS - 261
ICS 261 Fall 2000 Data Structures Midterm 2-Version A November 21, 2000This is a closed-book test. You may not use calculators, books, or notes during the exam. Please write all of your answers on the answer sheet, and write your name and ID number
CSU Channel Islands - ICS - 261
ICS 261 Fall 2001 Data Structures Midterm 2-Version A October 20, 2001 This is a closed-book test. You may not use calculators, books, or notes during the exam. Please write all of your answers on the answer sheet, and write your name and ID number,
CSU Channel Islands - ICS - 261
ICS 261 Fall 1999 Data Structures Midterm 1 AnswersPart I. 1. Version A: 20 34 46 60 Version B: 20 32 46 60Partial credit was given as follows: 8 points for what seemed likely to be a clerical error (having two 15's in the tree but no 44). 6 point
CSU Channel Islands - CS - 151
Student ID: _ICS 151Quiz 1Name : _ , _ (Last Name) (First Name) : _ : _Student ID SignatureInstructions:1. Please verify that your paper contains 4 pages including this cover. 2. Write down your Student-Id on the top of each page of this qui
CSU Channel Islands - LCHENG - 61
PERCEPTUAL QUALITY FEEDBACK BASED PROGRESSIVE FRAME-LEVEL REFRESHING FOR ROBUST VIDEO COMMUNICATION Liang Cheng, Magda El Zarki School of ICS, University of California, Irvine Email: lcheng61@ics.uci.edu, elzarki@uci.eduABSTRACT In this paper, we pr
CSU Channel Islands - ICS - 1
ICS 151Homework 11. Number Conversion (2.5) Give the binary equivalents of the following hexadecimal numbers: Just replace each hexadecimal number by its equivalent 4 bit binary number a. 123.4516 516 416 316 216 116 01012 01002 00112 00102
CSU Channel Islands - ICS - 151
ICS 151Homework 11. Number Conversion (2.5) Give the binary equivalents of the following hexadecimal numbers: Just replace each hexadecimal number by its equivalent 4 bit binary number a. 123.4516 516 416 316 216 116 01012 01002 00112 00102
CSU Channel Islands - ICS - 151
SolutionsFinal ExamFall 20031. Part I 1. Select the canonical sum-of-products representation of the following function: f(x,y,z) = xy' + y(x+z) (c) f(x,y,z) = xy'z + xy'z' + xyz + x'yz + xyz' 2. Select the definition of an essential prime implic
CSU Channel Islands - ICS - 151
SolutionsQuiz 4Given on 11/26/031. FSM Synthesis What you were expected to know to solve this problem: What an FSM is. How to read a state diagram. How the states, state transitions, and outputs are represented in a truth table. Section 6.7 - 6.
CSU Channel Islands - ICS - 151
yz wxyz2eliminateUNIVERSAL GATES: - NAND - NOR2.81.82.81.81.41.4FOR m-INPUT GATES111011
CSU Channel Islands - ICS - 151
SUM OF MINTERMSPRODUCT OF MAXTERMSSUM-OF_MINTERMSPRODUCT-OF-MAXTERMS22n
CSU Channel Islands - ICS - 151
ITERATIONM=0 LOGIC FUNCTION M=1 ARITHMETIC FUNCTION444=
CSU Channel Islands - ICS - 151
- Clock process describes normal clock operationInput: Pulse Outputs: S Display, M Display, H Display- Setup process allows clock and alarm to be programmed Inputs: S1 (time set), S2 (alarm set), S3 (minute+) S4 (hour+)- Alarm process causes th
CSU Channel Islands - ICS - 151
HOMEWORK 4 SolutionICS 151 Digital Logic DesignSpring 2004 1. Decoder/Multiplexer combining a. Construct a 5-to-32 decoder using only 2-to-4 decoders and 3-to-8 decoders (with enable). b. Design a 32-to-1 multiplexer using only 8-to-1 multiplexer.
CSU Channel Islands - ICS - 151
HOMEWORK 2 SolutionICS 151 Digital Logic DesignSpring 20041. Canonical SOP (25 points) If f (w,x,y,z) = m (1, 2, 4, 7, 8, 11, 13, 14) prove that f=wxyz (15 points)We can write f as: f = m1 + m2 + m4 + m7 + m8 + m11 + m13 + m14 = w'x'y'z + w
CSU Channel Islands - ICS - 151
HOMEWORK 5ICS 151 Digital Logic DesignSpring 2004 Due 4:00 p.m., June 9, 2004 at the Distribution Center NAME:_ 1. Sequential Circuit Analysis [T Flip-Flop] ID #:_ [25 points]Derive the state table and state diagram of the sequential circuit sho
CSU Channel Islands - CH - 151
2.30.c. F(a,b,c) = abc + ab + a + b + c2.31 F = (ab' + b)'2.34.c Inputs Outputs abcF 0001 0010 0101 0110 1001 1011 1101 11112.36 F = a'b'c + a'bc' + a'bc + ab'c + abc' + abc 2.37 F = a'b'c + a'bc' + a'bc + ab'c + abc' + abc F = a'(b'c + bc' + b
CSU Channel Islands - CH - 2
2.30.c. F(a,b,c) = abc + ab + a + b + c2.31 F = (ab' + b)'2.34.c Inputs Outputs abcF 0001 0010 0101 0110 1001 1011 1101 11112.36 F = a'b'c + a'bc' + a'bc + ab'c + abc' + abc 2.37 F = a'b'c + a'bc' + a'bc + ab'c + abc' + abc F = a'(b'c + bc' + b
CSU Channel Islands - ICS - 151
Student ID: _ICS 151Quiz 2Name : _ , _ (Last Name) (First Name) : _ : _Student ID SignatureInstructions:1. Please verify that your paper contains 6 pages including this cover. 2. Write down your Student-Id on the top of each page of this qui
CSU Channel Islands - ICS - 151
Student ID: _ICS 151Quiz 1Name : _ , _ (Last Name) (First Name) : _ : _Student ID SignatureInstructions:1. Please verify that your paper contains 4 pages including this cover. 2. Write down your Student-Id on the top of each page of this qui
CSU Channel Islands - ICS - 06