CSE 100 Practice Final Exam

Size: px
Start display at page:

Download "CSE 100 Practice Final Exam"

Transcription

1 CSE 100 Practice Final Exam Please note that this practice final only serves as a template and does not exhaustively cover all the topics that are on the actual final. The final exam will cover all the data-structures and algorithms that we have covered during the quarter, including all the readings, class discussions, and the assignments. Be sure that you understand each of the data structures and the algorithms and are able to run the algorithms by hand. 1. [ pts total] A little bit of everything a. [2 pts] Assume that H is the height of a completely full binary search tree that contains N nodes. Which of the following represents the worst case time to insert an element into this tree? Include all relevant bounds, not just the tightest bound. Circle all that apply: A. O(1) B. O(N) C. O(logN) D. O(H) E. O(logH) b. [2 pts] Assume that you have a class in C++ named MyClass. Which of the following statements are true about the following line of code (circle all that apply): MyClass mc; A. This line declares a variable of type MyClass. B. This line creates an object of type MyClass. C. You (the programmer) must call delete to destroy the object created by this line of code D. mc is a pointer type which stores or will store the address of a MyClass object c. [3 pts] Consider this AVL tree (balance factors not shown): For each of the following values, state whether they would cause a single rotation (S), a double rotation (D) or no rotation (N) when inserted into the AVL tree above. Assume that each value would be inserted into the tree above independent of the other values. Write the appropriate letter in the blank next to the value (S, D, or N). 1: 30: 45: 51: 60: 49 d. [2 pts] When is breadth first search guaranteed to find the shortest path through a graph (circle all that apply)? A. In any unweighted graph B. In any directed graph

2 C. In any graph with no cycles D. In any fully connected graph E. Never e. [5 pts] Consider the following treap, in which letters represent keys (using alphabetical ordering) and numbers represent priorities. We are midway through the insertion of the key F into this treap. G 50 C 35 B 24 F 45 A 21 E 33 What was the last (previous) action performed during the insert? A. A left rotation with E and F B. A right rotation with E and F C. A left rotation with F and C D. A right rotation with F and C E. F was inserted directly into its current location (no rotations performed yet) After the insert is complete, what will be the children of the following nodes? If a node has no child in that position, write NONE. Node G: left: right: Node C: left: right: Node F: left: right: Node B: left: right:

3 Name: PID: 2. More on Trees and treaps a. In the space below, draw a legal AVL tree with 4 nodes that is currently in balance but that will require a double rotation to insert at least one value that is NOT currently in the tree. You will be asked what this value is in part b, and you will be asked to do the double rotation in part c. However, you will get full credit in part a for drawing any legal AVL tree with 4 nodes. Be sure to clearly annotate each node with its balance factor. b. What value could you insert that would cause a double rotation? c. Insert this value and then draw the resulting tree below. d. Now, take your tree from part a (your original AVL tree, before you inserted the value from part b), and convert it into a treap with the same structure using the same values as keys, and any legal priority values that lead to the same structure. Draw the treap below. e. Finally, imagine that you will now insert the key from part b into this treap, using a priority that is greater than any other priority currently in the treap. Which of the following best describes why you do or do not need to perform a double rotation when you first insert this key, priority pair into the treap? A. You do need a double rotation, because if you use only single rotations the treap will become unbalanced. B. You do need a double rotation, because if you use only single rotations the treap will lose the BST property on the priorities. C. You do not need a double rotation, because a double rotation would violate the BST property on the keys.

4 D. You do not need a double rotation because single rotations are sufficient to get the node to bubble up to its proper location in the treap 3. Huffman coding and running time Consider the following symbols with the given frequency distribution: Symbol Frequency A 0.46 M 0.18 L 0.15 Y 0.05 P 0.16 a. [6 pts] Is the tree below a correct Huffman Code tree for these symbols with this distribution (circle one, below)? You should NOT consider it a problem that the frequencies are not explicitly marked. Assume they are present (calculated based on the table to the left), but not shown. Y 0 Yes No 1 1 Y 0 P Y 0 A M P L Y b. [3 pts] Regardless of whether or not the tree is correct, is there more than one correct tree for these symbols with this distribution? You should consider two trees different if they lead to different codes for the symbols. Yes No c. [20 pts, 4 pts each blank] In this part, you will analyze the running time for each stage of a naïve implementation of Dijkstra s algorithm on a graph G(V, E). If an edge exists between any two vertices, v, w, the weight of that edge is denoted by l vw 1. Initialize the distance of all nodes to Inf: L(u) =Inf, for all u in V 2. Set the distance of source, s to zero: L(s) =0 3. Initialize the set of vertices explored, X={s} 4. Iterate until X = V Among all crossing edges (v, w), with v in X and w in V-X, pick (v*, w*) such that (v*, w*) =arg min L(v) + l vw v,w Include w* in X: X= X U {w*}

5 Name: PID: What is the overall running time of the above algorithm 4. Graphs, C++ a. [13 pts] In this part, you will run Dijkstra s algorithm on graph shown below, with the source node V0. The data structure for each node is shown below. You will modify values in it. See below. V0: dist=0 prev= -1 done= f adj: (V1,1), (V2,6), (V3,3) V1: dist= prev= -1 done= f adj: (V2,4) V2: dist= prev= -1 done= f adj: V3: dist= prev= -1 done= f adj: (V2,1) The boxes below represent the priority queue which is used in the algorithm. Each set of boxes represents the priority queue after the first pair has been dequeued and its associated node has been fully expanded (i.e. its neighbors, along with their distances, have been added to the priority queue as appropriate). You will fill these in (see below for more instructions). V0 3 V3 6 1 V2 (V0, 0) (initial priority queue) 1 4 V1 (priority queue after expanding V0)

6 Simulate Dijkstra s algorithm by (1) modifying the values in the dist, prev, and done fields as the algorithm runs, and (2) showing the values stored in the priority queue after each new node is expanded. For the data structures at the top, you should cross off old values as you replace them. For the priority queue, you should show the contents of the whole queue in the next set of boxes after you have fully expanded/explored from the node that you just removed from the front of the queue in the previous step. The initial priority queue and initial values are already filled in for you. You may stop the process when each node has been marked as done. You may not need all of the queues. If you need more, just draw them in below the final array, to the side, or on the scratch paper. b. [13 pts] Consider the classes below which represent a graph node (vertex) and a graph. Complete the code to perform breadth first search on the graph from the source node with index source. After BFS is called on the graph, all of the Vertex objects pointed to by nodes should have their members set as follows: visited should be true if this node is reachable from the source node, false otherwise prev should store the integer index of the node (vertex) from which this node (vertex) was first reached Here are some helpful C++ commands and information of relevance here. You may not use all of these methods. You can access an element at position i in vector v using v[i] For an example of how to create and work with an iterator over a vector object, see the code provided to you at the start of BFS. Useful methods in class queue (Please do not use any other methods in the queue class. You do not need any others.): o q.front() accesses (returns) the next element in queue q (but not remove it) o q.pop()removes the next element (from the front) in queue q (but not return it) o q.push( d ) places the element d into the queue q (at the back). o q.empty() returns true if the queue q is empty, and false if there is at least one element in it #include <iostream> #include <queue> #include <vector> class Vertex { public: vector<int> adj; this vertex bool visited; int index; int prev; was found // Indexes of vertexes directly connected to // Has this vertex been visited? // The vertex s index // The index of the vertex from which this vertex Vertex(int ind, vector<int> alist ) :

7 Name: PID: }; index(ind), adj(alist), prev(-1), visited(false) {} class Graph { public: vector<vertex*> nodes; // Pointers to vertexes in the graph. You can access a pointer to Vertex at index i using nodes[i]. Graph( vector<vertex*> thenodes ) : nodes(thenodes) {} // Continued on next page, where you will add your code

8 void BFS( int source ) { vector<vertex*>::iterator it = nodes.begin(); for ( ; it!= nodes.end(); ++it ) { // initialize the graph (*it)->visited = false; (*it)->prev = -1; } queue<vertex*> toexplore; // Your code here (see previous page) } };

9 Name: PID:

10

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS 2 Graphs: Example A directed graph V5 V = { V = E = { E Path: 3 Graphs: Definitions A directed graph V5 V6 A graph G = (V,E) consists of a set of vertices V and a set of edges

More information

CSE 100: GRAPH SEARCH

CSE 100: GRAPH SEARCH CSE 100: GRAPH SEARCH Announcements PA3 released Checkpoint due Tuesday, May 5 @10:00pm Final submission due Thursday, May 14 @10:00PM Start early! Start early! Start early! Start early! Start early! I

More information

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

CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, 2015 Problem Topic Points Possible Points Earned Grader 1 The Basics 40 2 Application and Comparison 20 3 Run Time Analysis 20 4 C++ and Programming

More information

Final Examination CSE 100 UCSD (Practice)

Final Examination CSE 100 UCSD (Practice) 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

More information

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

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CSE 100 Minimum Spanning Trees Prim s and Kruskal CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:

More information

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination University of Illinois at Urbana-Champaign Department of Computer Science Second Examination CS 225 Data Structures and Software Principles Spring 2014 7-10p, Tuesday, April 8 Name: NetID: Lab Section

More information

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

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination University of Illinois at Urbana-Champaign Department of Computer Science Second Examination CS 225 Data Structures and Software Principles Fall 2011 9a-11a, Wednesday, November 2 Name: NetID: Lab Section

More information

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

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CSE373 Fall 2013, Midterm Examination October 18, 2013

CSE373 Fall 2013, Midterm Examination October 18, 2013 CSE373 Fall 2013, Midterm Examination October 18, 2013 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note, closed calculator, closed electronics. Please stop

More information

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

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Spring 2010 7-10p, Wednesday, May 12 Name: NetID: Lab Section

More information

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

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

Section 4 SOLUTION: AVL Trees & B-Trees

Section 4 SOLUTION: AVL Trees & B-Trees Section 4 SOLUTION: AVL Trees & B-Trees 1. What 3 properties must an AVL tree have? a. Be a binary tree b. Have Binary Search Tree ordering property (left children < parent, right children > parent) c.

More information

Insert the value 42 into the following BTree.

Insert the value 42 into the following BTree. Final Review Announcements PA4 is due tonight at 11pm PA3 re- grade requests due by Monday Study guide and pracace final posted on course website (website was upgraded to be mobile friendly). Review session

More information

Draw the resulting binary search tree. Be sure to show intermediate steps for partial credit (in case your final tree is incorrect).

Draw the resulting binary search tree. Be sure to show intermediate steps for partial credit (in case your final tree is incorrect). Problem 1. Binary Search Trees (36 points) a) (12 points) Assume that the following numbers are inserted into an (initially empty) binary search tree in the order shown below (from left to right): 42 36

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Topics: Wednesday: Binary Search Tree (BST) Starting with a dream: binary search in a linked list? How our dream provided the inspiration for the BST Note:

More information

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt):

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): CS 170 Second Midterm ANSWERS 7 April 2010 NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt): Instructions: This is a closed book, closed calculator,

More information

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

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

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

CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed) Name: Sample Solution Email address: CSE 373 Autumn 0: Midterm # (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may

More information

INFO1x05 Tutorial 09

INFO1x05 Tutorial 09 INFO1x05 Tutorial 09 (2,3) Trees, (2,4) Trees and Hash Tables Exercise 1: (INFO1105 and INFO1905) Is the search tree shown below a (2,4) tree? Why or why not? 22 5 10 25 3 4 6 8 14 23 24 27 11 13 17 Figure

More information

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS Dijkstra s Algorithm: Questions Initialize the graph: Give all vertices a dist of INFINITY, set all done flags to false Start at s; give s dist = 0 and set prev field to -1 Enqueue

More information

CS 106X Sample Final Exam #2

CS 106X Sample Final Exam #2 CS 106X Sample Final Exam #2 This sample exam is intended to demonstrate an example of some of the kinds of problems that will be asked on the actual final exam. We do not guarantee that the number of

More information

Midterm II Exam Principles of Imperative Computation Frank Pfenning. March 31, 2011

Midterm II Exam Principles of Imperative Computation Frank Pfenning. March 31, 2011 Midterm II Exam 15-122 Principles of Imperative Computation Frank Pfenning March 31, 2011 Name: Sample Solution Andrew ID: fp Section: Instructions This exam is closed-book with one sheet of notes permitted.

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech

More information

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

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs Lecture 5 Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs Reading: Randomized Search Trees by Aragon & Seidel, Algorithmica 1996, http://sims.berkeley.edu/~aragon/pubs/rst96.pdf;

More information

Algorithms. AVL Tree

Algorithms. AVL Tree Algorithms AVL Tree Balanced binary tree The disadvantage of a binary search tree is that its height can be as large as N-1 This means that the time needed to perform insertion and deletion and many other

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination University of Illinois at Urbana-Champaign Department of Computer Science Second Examination CS 225 Data Structures and Software Principles Spring 2012 7p-9p, Tuesday, April 3 Name: NetID: Lab Section

More information

CS61BL: Data Structures & Programming Methodology Summer 2014

CS61BL: Data Structures & Programming Methodology Summer 2014 CS61BL: Data Structures & Programming Methodology Summer 2014 Instructor: Edwin Liao Final Exam August 13, 2014 Name: Student ID Number: Section Time: TA: Course Login: cs61bl-?? Person on Left: Possibly

More information

Prelim 2 Solution. CS 2110, April 26, 2016, 7:30 PM

Prelim 2 Solution. CS 2110, April 26, 2016, 7:30 PM Prelim Solution CS 110, April 6, 016, 7:0 PM 1 5 Total Question True/False Complexity Heaps Trees Graphs Max 10 0 0 0 0 100 Score Grader The exam is closed book and closed notes. Do not begin until instructed.

More information

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

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials) CSE100 Advanced Data Structures Lecture 8 (Based on Paul Kube course materials) CSE 100 Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

More information

CS/ENGRD2110: Final Exam

CS/ENGRD2110: Final Exam CS/ENGRD2110: Final Exam 11th of May, 2012 NAME : NETID: The exam is closed book and closed notes. Do not begin until instructed. You have 150 minutes. Start by writing your name and Cornell netid on top!

More information

Data Structures Brett Bernstein

Data Structures Brett Bernstein Data Structures Brett Bernstein Final Review 1. Consider a binary tree of height k. (a) What is the maximum number of nodes? (b) What is the maximum number of leaves? (c) What is the minimum number of

More information

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

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer Prelim 2 CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed

More information

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

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY CS 251, LE 2 Fall 2016 MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY W1.) (i) Show one possible valid 2-3 tree containing the nine elements: 1 3 4 5 6 8 9 10 12. (ii) Draw the final binary search

More information

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

CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid: CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid: CS 2150 Final Exam Name You MUST write your e-mail ID on EACH page and put your name on the top of this page, too. If you are still writing when

More information

CS 315 Data Structures mid-term 2

CS 315 Data Structures mid-term 2 CS 315 Data Structures mid-term 2 1) Shown below is an AVL tree T. Nov 14, 2012 Solutions to OPEN BOOK section. (a) Suggest a key whose insertion does not require any rotation. 18 (b) Suggest a key, if

More information

Practice Problems for the Final

Practice Problems for the Final ECE-250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each

More information

Second Examination Solution

Second Examination Solution University of Illinois at Urbana-Champaign Department of Computer Science Second Examination Solution CS 225 Data Structures and Software Principles Fall 2007 7p-9p, Thursday, November 8 Name: NetID: Lab

More information

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

Section 1: True / False (1 point each, 15 pts total) Section : True / False ( point each, pts total) Circle the word TRUE or the word FALSE. If neither is circled, both are circled, or it impossible to tell which is circled, your answer will be considered

More information

CSE 373: Practice Final

CSE 373: Practice Final CSE 373: Practice Final 1 Short Answer a) Provide two orderings [0,1,2,3,4,5,6,7] that are worst-case for quick sort. Assume that you select the first element as the pivot. Explain why this is the worst-case.

More information

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity. 1. T F: Consider a directed graph G = (V, E) and a vertex s V. Suppose that for all v V, there exists a directed path in G from s to v. Suppose that a DFS is run on G, starting from s. Then, true or false:

More information

A Previous CS 310 Final Exam

A Previous CS 310 Final Exam A Previous CS 310 Final Exam July 20, 2004 Print Your Name: Read the following now. You have 100 minutes to work on 9 questions, totaling 200 points. To ensure partial credit, show all your work! Write

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Fall 2009 7-10p, Tuesday, December 15 Name: NetID: Lab Section

More information

Prelim 2. CS 2110, April 26, 2016, 5:30 PM Total Question True/False Complexity Heaps Trees Graphs Max Score Grader

Prelim 2. CS 2110, April 26, 2016, 5:30 PM Total Question True/False Complexity Heaps Trees Graphs Max Score Grader Prelim CS 110, April 6, 016, 5:0 PM 1 5 Total Question True/False Complexity Heaps Trees Graphs Max 10 0 0 0 0 100 Score Grader The exam is closed book and closed notes. Do not begin until instructed.

More information

Balanced Binary Search Trees. Victor Gao

Balanced Binary Search Trees. Victor Gao Balanced Binary Search Trees Victor Gao OUTLINE Binary Heap Revisited BST Revisited Balanced Binary Search Trees Rotation Treap Splay Tree BINARY HEAP: REVIEW A binary heap is a complete binary tree such

More information

CS102 Binary Search Trees

CS102 Binary Search Trees CS102 Binary Search Trees Prof Tejada 1 To speed up insertion, removal and search, modify the idea of a Binary Tree to create a Binary Search Tree (BST) Binary Search Trees Binary Search Trees have one

More information

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

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014 CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up Nicki Dell Spring 2014 Final Exam As also indicated on the web page: Next Tuesday, 2:30-4:20 in this room Cumulative but

More information

: Fundamental Data Structures and Algorithms. June 06, 2011 SOLUTIONS

: Fundamental Data Structures and Algorithms. June 06, 2011 SOLUTIONS 15-211 Midterm Exam Summer 2011 Page 1 of 10 15-211 : Fundamental Data Structures and Algorithms June 06, 2011 SOLUIONS 15-211 Midterm Exam Summer 2011 Page 2 of 10 (10) 1. rue/false questions. Clearly

More information

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

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) _ UWNetID: Lecture Section: A CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will give

More information

Priority Queues. 04/10/03 Lecture 22 1

Priority Queues. 04/10/03 Lecture 22 1 Priority Queues It is a variant of queues Each item has an associated priority value. When inserting an item in the queue, the priority value is also provided for it. The data structure provides a method

More information

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

CSE 100 Tutor Review Section. Anish, Daniel, Galen, Raymond CSE 100 Tutor Review Section Anish, Daniel, Galen, Raymond THIS MAY NOT COVER EVERYTHING... Such as C++ / code implementation, and everything else in the lecture slides that s not in here. - Go over lecture

More information

CS 315 Data Structures Spring 2012 Final examination Total Points: 80

CS 315 Data Structures Spring 2012 Final examination Total Points: 80 CS 315 Data Structures Spring 2012 Final examination Total Points: 80 Name This is an open-book/open-notes exam. Write the answers in the space provided. Answer for a total of 80 points, including at least

More information

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

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40% CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40% Name ID Directions: There are 9 questions in this exam. To earn a possible full score, you must solve all questions. Time allowed: 180 minutes Closed

More information

EECS 311 Data Structures Midterm Exam Don t Panic!

EECS 311 Data Structures Midterm Exam Don t Panic! April 5, 7 EECS Data Structures Midterm Exam Don t Panic!. ( pts) In each box below, show the AVL trees that result from the successive addition of the given elements. Show the nodes, links and balance

More information

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

CSE 332 Winter 2015: Final Exam (closed book, closed notes, no calculators) Email address (UWNetID): CSE 332 Winter 2015: Final Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

Sample Exam 1 Questions

Sample Exam 1 Questions CSE 331 Sample Exam 1 Questions Name DO NOT START THE EXAM UNTIL BEING TOLD TO DO SO. If you need more space for some problem, you can link to extra space somewhere else on this exam including right here.

More information

Computer Science E-22 Practice Final Exam

Computer Science E-22 Practice Final Exam name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and

More information

CS302 Data Structures using C++

CS302 Data Structures using C++ CS302 Data Structures using C++ Study Guide for the Final Exam Fall 2018 Revision 1.1 This document serves to help you prepare towards the final exam for the Fall 2018 semester. 1. What topics are to be

More information

1. AVL Trees (10 Points)

1. AVL Trees (10 Points) CSE 373 Spring 2012 Final Exam Solution 1. AVL Trees (10 Points) Given the following AVL Tree: (a) Draw the resulting BST after 5 is removed, but before any rebalancing takes place. Label each node in

More information

15 210: Parallel and Sequential Data Structures and Algorithms

15 210: Parallel and Sequential Data Structures and Algorithms Full Name: Andrew ID: Section: 15 210: Parallel and Sequential Data Structures and Algorithms Exam II 7 April 2017 Verify There are 17 pages in this examination, comprising 7 questions worth a total of

More information

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F].

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F]. Question Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F]. a) Draw the linked node structure of L, including

More information

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance Course goals exposure to another language C++ Object-oriented principles knowledge of specific data structures lists, stacks & queues, priority queues, dynamic dictionaries, graphs impact of DS design

More information

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL MINUTIAE Feedback for P1p1 should have gone out before class Grades on canvas tonight Emails went to the student who submitted the assignment If you did not receive

More information

(the bubble footer is automatically inserted into this space)

(the bubble footer is automatically inserted into this space) CS 2150 Final Exam, spring 2016 Page 1 of 10 UVa userid: CS 2150 Final Exam, spring 2016 Name You MUST write your e-mail ID on EACH page and bubble in your userid at the bottom of this first page. And

More information

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

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: This exam is CLOSED book and notes. Instructions The exam consists of six questions on 11 pages. Please answer all questions on

More information

Midterm 2 Exam Principles of Imperative Computation. Tuesday 31 st March, This exam is closed-book with one sheet of notes permitted.

Midterm 2 Exam Principles of Imperative Computation. Tuesday 31 st March, This exam is closed-book with one sheet of notes permitted. Midterm 2 Exam 15-122 Principles of Imperative Computation Tuesday 31 st March, 2015 Name: Andrew ID: Recitation Section: Instructions This exam is closed-book with one sheet of notes permitted. You have

More information

CS61BL. Lecture 5: Graphs Sorting

CS61BL. Lecture 5: Graphs Sorting CS61BL Lecture 5: Graphs Sorting Graphs Graphs Edge Vertex Graphs (Undirected) Graphs (Directed) Graphs (Multigraph) Graphs (Acyclic) Graphs (Cyclic) Graphs (Connected) Graphs (Disconnected) Graphs (Unweighted)

More information

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

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution

More information

CSE332 Summer 2010: Midterm Exam Sample Solutions

CSE332 Summer 2010: Midterm Exam Sample Solutions CSE332 Summer 2010: Midterm Exam Sample Solutions Closed notes, closed book; calculator ok. Read the instructions for each problem carefully before answering. Problems vary in point-values, difficulty

More information

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE 332, Spring 2010, Midterm Examination 30 April 2010 CSE 332, Spring 2010, Midterm Examination 30 April 2010 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note. You may use a calculator for basic arithmetic only.

More information

CS 104 (Spring 2014) Final Exam 05/09/2014

CS 104 (Spring 2014) Final Exam 05/09/2014 CS 104 (Spring 2014) Final Exam 05/09/2014 G o o d L u c k Your Name, USC username, and Student ID: This exam has 8 pages and 8 questions. If yours does not, please contact us immediately. Please read

More information

This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have

This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have encountered on homeworks, the midterm, and on this practice

More information

Prelim 2 Solution. CS 2110, April 26, 2016, 5:30 PM

Prelim 2 Solution. CS 2110, April 26, 2016, 5:30 PM Prelim Solution CS 110, April 6, 016, 5:0 PM 1 5 Total Question True/False Complexity Heaps Trees Graphs Max 10 0 0 0 0 100 Score Grader The exam is closed book and closed notes. Do not begin until instructed.

More information

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 6: BFS and Dijkstra s

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 6: BFS and Dijkstra s CSE 101 Algorithm Design and Analysis Miles Jones mej016@eng.ucsd.edu Office 4208 CSE Building Lecture 6: BFS and Dijkstra s BREADTH FIRST SEARCH (BFS) Given a graph G and a starting vertex s, BFS computes

More information

CISC 320 Midterm Exam

CISC 320 Midterm Exam Name: CISC 320 Midterm Exam Wednesday, Mar 25, 2015 There are 19 questions. The first 15 questions count 4 points each. For the others, points are individually shown. The total is 100 points. Multiple

More information

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Algorithms (VII) Yijia Chen Shanghai Jiaotong University Algorithms (VII) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Depth-first search in undirected graphs Exploring graphs explore(g, v) Input: G = (V, E) is a graph; v V Output:

More information

CPSC W1: Midterm 1 Sample Solution

CPSC W1: Midterm 1 Sample Solution CPSC 320 2017W1: Midterm 1 Sample Solution January 26, 2018 Problem reminders: EMERGENCY DISTRIBUTION PROBLEM (EDP) EDP's input is an undirected, unweighted graph G = (V, E) plus a set of distribution

More information

The Shortest Path Problem

The Shortest Path Problem The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring

More information

Course Review for Finals. Cpt S 223 Fall 2008

Course Review for Finals. Cpt S 223 Fall 2008 Course Review for Finals Cpt S 223 Fall 2008 1 Course Overview Introduction to advanced data structures Algorithmic asymptotic analysis Programming data structures Program design based on performance i.e.,

More information

Test #2. Login: 2 PROBLEM 1 : (Balance (6points)) Insert the following elements into an AVL tree. Make sure you show the tree before and after each ro

Test #2. Login: 2 PROBLEM 1 : (Balance (6points)) Insert the following elements into an AVL tree. Make sure you show the tree before and after each ro DUKE UNIVERSITY Department of Computer Science CPS 100 Fall 2003 J. Forbes Test #2 Name: Login: Honor code acknowledgment (signature) Name Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem

More information

Section 1: True / False (2 points each, 30 pts total)

Section 1: True / False (2 points each, 30 pts total) Section 1: True / False (2 points each, 30 pts total) Circle the word TRUE or the word FALSE. If neither is circled, both are circled, or it impossible to tell which is circled, your answer will be considered

More information

Lecture Summary CSC 263H. August 5, 2016

Lecture Summary CSC 263H. August 5, 2016 Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.

More information

CSE332 Summer 2010: Final Exam

CSE332 Summer 2010: Final Exam CSE332 Summer 2010: Final Exam Closed notes, closed book; calculator ok. Read the instructions for each problem carefully before answering. Problems vary in point-values, difficulty and length, so you

More information

DIT960 Datastrukturer

DIT960 Datastrukturer DIT90 Datastrukturer suggested solutions for exam 07-0-0. The following code takes as input two arrays with elements of the same type. The arrays are called a and b. The code returns a dynamic array which

More information

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

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D. CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to convert an array, with priorities stored at subscripts through n,

More information

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

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination ECE 25 Data Structures and Algorithms University of Waterloo Department of Electrical and Computer Engineering ECE 25 Data Structures and Algorithms Instructor: Douglas Wilhelm Harder Time: 2.5 hours Aides:

More information

Balanced Search Trees. CS 3110 Fall 2010

Balanced Search Trees. CS 3110 Fall 2010 Balanced Search Trees CS 3110 Fall 2010 Some Search Structures Sorted Arrays Advantages Search in O(log n) time (binary search) Disadvantages Need to know size in advance Insertion, deletion O(n) need

More information

Recitation 9. Prelim Review

Recitation 9. Prelim Review Recitation 9 Prelim Review 1 Heaps 2 Review: Binary heap min heap 1 2 99 4 3 PriorityQueue Maintains max or min of collection (no duplicates) Follows heap order invariant at every level Always balanced!

More information

Computer Science 302 Fall 2018 (Practice for) Third Examination, November 14, 2018

Computer Science 302 Fall 2018 (Practice for) Third Examination, November 14, 2018 Computer Science 302 Fall 208 (Practice for) Third Examination, November 4, 208 Name: The entire practice examination is 400 points.. True or False. [5 points each] (a) (b) A good programmer should never

More information

CSE030 Fall 2012 Final Exam Friday, December 14, PM

CSE030 Fall 2012 Final Exam Friday, December 14, PM CSE030 Fall 2012 Final Exam Friday, December 14, 2012 3-6PM Write your name here and at the top of each page! Name: Select your lab session: Tuesdays Thursdays Paper. If you have any questions or need

More information

n 2 ( ) ( ) + n is in Θ n logn

n 2 ( ) ( ) + n is in Θ n logn CSE Test Spring Name Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply an m n matrix and a n p matrix is in: A. Θ( n) B. Θ( max(

More information

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE CSI33 Sample Final Exam NAME Directions: Solve problems 1 through 5 of Part I and choose 5 of the

More information

Analysis of Algorithms

Analysis of Algorithms Analysis of Algorithms Concept Exam Code: 16 All questions are weighted equally. Assume worst case behavior and sufficiently large input sizes unless otherwise specified. Strong induction Consider this

More information

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

Prelim 2 Solutions. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer Prelim 2 Solutions CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam

More information

CSCE 2014 Final Exam Spring Version A

CSCE 2014 Final Exam Spring Version A CSCE 2014 Final Exam Spring 2017 Version A Student Name: Student UAID: Instructions: This is a two-hour exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers

More information

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

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Name: The entire practice examination is 1005 points. 1. True or False. [5 points each] The time to heapsort an array of

More information