Final Examination CSE 100 UCSD (Practice)

Similar documents
CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

CS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: Instructions GOOD LUCK!

Course Review for Finals. Cpt S 223 Fall 2008

1. AVL Trees (10 Points)

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

CSE 100 Practice Final Exam

) $ f ( n) " %( g( n)

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

CSE 100 Advanced Data Structures

COMP 251 Winter 2017 Online quizzes with answers

CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed)

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid:

Balanced Binary Search Trees. Victor Gao

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%

( D. Θ n. ( ) f n ( ) D. Ο%

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

Solutions to Exam Data structures (X and NV)

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

CSE 373 Sample Midterm #2 (closed book, closed notes, calculators o.k.)

CS171 Final Practice Exam

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

CISC 320 Midterm Exam

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014

INSTITUTE OF AERONAUTICAL ENGINEERING

( ) n 3. n 2 ( ) D. Ο

CS102 Binary Search Trees

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

Second Examination Solution

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Computer Science E-22 Practice Final Exam

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

CS521 \ Notes for the Final Exam

Course Review. Cpt S 223 Fall 2009

CSE 373 Spring 2010: Midterm #2 (closed book, closed notes, NO calculators allowed)

Lecture Summary CSC 263H. August 5, 2016

CSE 100: UNION-FIND HASH

CS171 Final Practice Exam

Practice Midterm Exam Solutions

Data Structures and Algorithm Analysis in C++

R16 SET - 1 '' ''' '' ''' Code No: R

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

Midterm solutions. n f 3 (n) = 3

Section 4 SOLUTION: AVL Trees & B-Trees

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials)

Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

Test 1 - Closed Book Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

UNIT III BALANCED SEARCH TREES AND INDEXING

CLO Assessment CLO1 Q1(10) CLO2 Q2 (10) CLO3 Q4 (10) CLO4 Q3a (4)

Course Review. Cpt S 223 Fall 2010

Section 1: True / False (1 point each, 15 pts total)

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

CS302 Data Structures using C++

CSE 100: GRAPH ALGORITHMS

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

CS 245 Midterm Exam Winter 2014

Analysis of Algorithms

Chapter 1 Introduction

Selection, Bubble, Insertion, Merge, Heap, Quick Bucket, Radix

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Data Structures Question Bank Multiple Choice

Graphs & Digraphs Tuesday, November 06, 2007

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

CSE 100 Tutor Review Section. Anish, Daniel, Galen, Raymond

CSE 332 Autumn 2016 Final Exam (closed book, closed notes, no calculators)

CS-301 Data Structure. Tariq Hanif

Computer Science 302 Fall 2009 (Practice) Second Examination, October 15, 2009

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

Transcription:

Final Examination UCSD (Practice) RULES: 1. Don t start the exam until the instructor says to. 2. This is a closed-book, closed-notes, no-calculator exam. Don t refer to any materials other than the exam itself. 3. Write your name, and your login name, on each page of the exam when you get to it. 4. Do not look at anyone else s exam. Do not talk to anyone but an exam proctor during the exam. If you re wearing a billed cap, please turn it around or take it off. Turn off cell phones and pagers and MP3 players. 5. If you have a question, raise your hand and an exam proctor will come to you. 6. You have two hours and thirty minutes to finish the exam. When you are done, give your exam to a proctor. The proctor will check your picture ID and sign the ID check below. Be sure you turn in all the pages! (The last 2 pages are blank and can be used as scratch paper.) 7. Your exam and course grade will be emailed to your account early next week. Exams will be returned next quarter, in the CSE student affairs offices. # Type max pts actual pts 1. General TF 26 2. General matching 28 3. General numbers 27 4. Coding 18 5. Graphs 18 6. Treaps 10 7. Hashing 13 TOTAL 140 grader: PROCTOR ID CHECK: Page 0 of 8

1. [26 pts.] (1 point for each correct; -1 point for each incorrect; 0 points each left blank) True or False: a. Skip lists and hash tables have the same big-o worst-case time cost for insert operations. b. Red-black trees and B-trees have the same big-o worst-case time cost for delete operations. c. A binary search tree with 10,000 nodes is a sparse graph. d. In a nonempty Huffman code tree, there must be an odd number of nodes. e. Hashtables are good for efficiently iterating over keys in sorted order. f. A B-tree is a binary tree. g. Any AVL rotation in a BST preserves the BST ordering property. h. An undirected graph is connected if for every pair of distinct vertices V1, V2, there is a path from V1 to V2. i. In a red-black tree, if a red node has two child nodes, those child nodes must be the same color. j. In an AVL tree, the levels of any two leaves can differ by at most 1. k. In a binary heap, the levels of any two leaves can differ by at most 1. l. The weighted shortest-path problem is NP-complete. m. Every subtree of an AVL tree is itself an AVL tree. n. Every subtree of a BST is itself a BST. o. Every subtree of a treap is itself a treap. p. Every subtree of a spanning tree for a graph G is a spanning tree for G. q. In a Huffman code, the code for a symbol is never a prefix of the code for another symbol. r. In a randomized search tree, the values of the priorites associated with keys that have been inserted determine which key is in the root. s. A precondition of Kruskal s algorithm is that the input graph not have negative-weight edges. t. With double hashing, collisions never occur. u. Considered as an undirected graph, every tree with N nodes has the same number of edges. v. Closed hashing is also known as open addressing. w. Every minimum-cost spanning tree is a connected graph. x. Depth-first search is the best approach for finding shortest paths in unweighted graphs. y. Keys in a binary search tree must be comparable to each other. z. Randomized search trees are about as efficient in the average case as red-black trees, and are easier to implement. Page 1 of 8

2. [28 pts.] (2 pts ea) Fill in the blank with the number of the best answer from this list. Some may be used more than once and some may not be used at all. 1. Simple path 2. Priority 3. Heap 4. DAG 5. Binary trie 6. Amortized analysis 7. std::string 8. Adaptor 9. Buffer 10. Linear congruence 11. Skip list 12. Spanning tree 13. Iterator 14. Adjacency list 15. B tree 16. Queue 17. Parent pointers 18. Union by height 19. Adjacency matrix 20. Hash table 21. Disjoint subset 22. std::map 23. Stack 24. AVL tree 25. NP complete 26. Path compression 27. 2-3 tree a. Has the biggest difference between average-case and worst-case find operations. b. A Huffman code tree is one of these. c. Acts like a pointer in C++. d. Such problems are intractable. e. Store nodes here to do depth-first search. f. Usually has a fixed MAXLEVEL. g. Makes find operations almost constant time. h. Every tree is one of these. i. Simulates randomness. j. Space efficient for dense graphs. k. Red-black trees are used for this. l. Shows whether self-adjusting finds are worth it. m. Used in high-performance disk filesystems. n. Randomized search trees randomize this. Page 2 of 8

3. [27 pts] (3 pts each) Write down the correct (exact) number in the space provided. a. The average-case number of key comparisons for an unsuccessful find in a completely filled binary search tree with 7 nodes. b. The average-case number of key comparisons for a successful find in a linked list with 7 nodes. c. The worst-case number of key comparisons for a successful find in an AVL tree with 4 nodes. d. The worst-case number of key comparisons for an unsuccessful find in a randomized search tree with 7 nodes. e. The best-case number of key comparisons for a successful find in a red-black tree with 7 nodes. f. The minimum number of edges in a spanning tree for a connected undirected graph with 10 vertices. g. The average-case number of key comparisons for a successful find in a binary search tree with 3 nodes (assuming all key insert orders are equally likely, and all keys are equally likely to be searched for). h. The probability of a collision when inserting two keys in an initially empty hash table of length 10 using random hashing. i. The number of bytes in a Huffman code for a message consisting of 8 distinct symbols of equal probability. Page 3 of 8

4. [18 pts total] You are given a representation of a Huffman code tree as an adjacency matrix M. In this representation, if a node has two children, the child with the smaller index is the 0 child of its parent. The dictionary D associates each leaf node index with the alphabet symbol in that leaf node. M: 0 1 2 3 4 5 6 7 8 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 1 0 0 0 3 1 0 0 0 0 0 0 0 0 4 0 0 1 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 6 1 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 1 8 0 0 1 0 0 0 0 0 0 D: 4 6 7 1 3 E P R L S a. [6 pts] In the space above, draw the Huffman code tree. Label all internal nodes with their index. Label leaves with the letter in that leaf node. Label links as 0 or 1 as appropriate. b. [2 pts] According to this code, what are the two least common symbols?, c. [4 pts] According to this code, write down the left-to-right sequence of bits that codes this message: SPELLER (The bits may not completely fill the 3 bytes shown.) d. [6 pts] Write down the message coded by this sequence of bits: 0 1 1 1 1 1 0 0 0 1 0 1 1 0 1 1 0 Page 4 of 8

5. [18 pts total] Consider the following adjacency list for an unweighted directed graph G: 1 2 3 4 5 6 2 4 3 5 5 3 1 a. [6 pts]a depth-first search starting from vertex 6 will visit vertices in G in some sequence. In fact, three distinct sequences are possible in this case. Show all of them:,,,,,,,,,,,,,,, b. [12 pts] Show the result of running Dijktsra s algorithm on G, with start vertex 6. Assume all edges have cost (i.e. distance) 1. For each entry in the table, give the index of the previous vertex on the shortest path (or -1 if none), and the distance to the start vertex along that path. vertex 1 2 3 4 5 6 previous distance Page 5 of 8

6. [10 pts] Show the treap resulting from inserting the following (key,priority) pairs, in order shown, into an initially empty treap. (Keys here are characters, with alphabetic ordering; priorities are integers, with larger integers representing higher priority.) Label each node clearly with the (key,priority) pair in it. (W,30), (P,0), (L,5), (K,70), (Z,60), (A,20) 7. [13 pts total] This hashtable is the result of a sequence of 5 insert operations. Linear probing (index increment) was used for collision resolution, with hash function H(K) = K mod 5. 27 3 22 13 7 0 1 2 3 4 a. [10 pts] Write down, in order of first insertion to last, the 5 keys that were inserted. (There may be more than one solution to this.) Inserted keys:,,,, b. [3 pts] Suppose all keys are equally likely. In this table, what is the exact average number of probes (comparisons) for a successful search? (Please show your work.) Page 6 of 8

(blank paper 1) Page 7 of 8

(blank paper 2) Page 8 of 8