Sample Exam 1 Questions

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

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

Section 4 SOLUTION: AVL Trees & B-Trees

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

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

CSE 373 Spring Midterm. Friday April 21st

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

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

Trees. Eric McCreath

Analysis of Algorithms

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

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

Programming II (CS300)

Binary Trees

Trees. (Trees) Data Structures and Programming Spring / 28

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

A set of nodes (or vertices) with a single starting point

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

CS301 - Data Structures Glossary By

EE 368. Weeks 5 (Notes)

M-ary Search Tree. B-Trees. B-Trees. Solution: B-Trees. B-Tree: Example. B-Tree Properties. Maximum branching factor of M Complete tree has height =

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

Recall: Properties of B-Trees

Augmenting Data Structures

Binary Search Trees. Analysis of Algorithms

Binary Trees, Binary Search Trees

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2010

TREES. Trees - Introduction

M-ary Search Tree. B-Trees. Solution: B-Trees. B-Tree: Example. B-Tree Properties. B-Trees (4.7 in Weiss)

Trees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University

3137 Data Structures and Algorithms in C++

CS102 Binary Search Trees

AVL Trees (10.2) AVL Trees

Course Review. Cpt S 223 Fall 2009

CSE 326: Data Structures B-Trees and B+ Trees

Design and Analysis of Algorithms Lecture- 9: B- Trees

Computer Science Foundation Exam

Lec 17 April 8. Topics: binary Trees expression trees. (Chapter 5 of text)

Chapter 2: Basic Data Structures

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

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Final Examination CSE 100 UCSD (Practice)

Data Structures and Algorithms

An AVL tree with N nodes is an excellent data. The Big-Oh analysis shows that most operations finish within O(log N) time

Binary Heaps. COL 106 Shweta Agrawal and Amit Kumar

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

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

Announcements. Problem Set 2 is out today! Due Tuesday (Oct 13) More challenging so start early!

Design and Analysis of Algorithms Lecture- 9: Binary Search Trees

CSE2331/5331. Topic 6: Binary Search Tree. Data structure Operations CSE 2331/5331

Search Trees - 1 Venkatanatha Sarma Y

Algorithms. AVL Tree

Note that this is a rep invariant! The type system doesn t enforce this but you need it to be true. Should use repok to check in debug version.

Spring 2018 Mentoring 8: March 14, Binary Trees

CSCI2100B Data Structures Trees

Balanced Binary Search Trees. Victor Gao

CS 261 Data Structures. AVL Trees

INF2220: algorithms and data structures Series 1

Friday Four Square! 4:15PM, Outside Gates

Search Trees: BSTs and B-Trees

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Data Structures and Algorithms

Trees. Truong Tuan Anh CSE-HCMUT

Self-Balancing Search Trees. Chapter 11

Motivation for B-Trees

Data Structures Question Bank Multiple Choice

Search Trees. COMPSCI 355 Fall 2016

B-Trees. Version of October 2, B-Trees Version of October 2, / 22

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

CS350: Data Structures Red-Black Trees

CS350: Data Structures B-Trees

Name Section Number. CS210 Exam #3 *** PLEASE TURN OFF ALL CELL PHONES*** Practice

Trees. A tree is a directed graph with the property

Advanced Tree Data Structures

Priority Queues Heaps Heapsort

Dictionaries. Priority Queues

CSE373 Fall 2013, Midterm Examination October 18, 2013

CSE 230 Intermediate Programming in C and C++ Binary Tree

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

CSE373: Data Structures & Algorithms Lecture 6: Binary Search Trees. Linda Shapiro Spring 2016

Lecture Summary CSC 263H. August 5, 2016

Readings. Priority Queue ADT. FindMin Problem. Priority Queues & Binary Heaps. List implementation of a Priority Queue

Why Trees? Alternatives. Want: Ordered arrays. Linked lists. A data structure that has quick insertion/deletion, as well as fast search

Comp 335 File Structures. B - Trees

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

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

Q1 Q2 Q3 Q4 Q5 Q6 Total

ECE 242 Data Structures and Algorithms. Trees IV. Lecture 21. Prof.

Multiway Search Trees. Multiway-Search Trees (cont d)

AVL Trees Goodrich, Tamassia, Goldwasser AVL Trees 1

Course Review. Cpt S 223 Fall 2010

Transform & Conquer. Presorting

CSE 326: Data Structures Splay Trees. James Fogarty Autumn 2007 Lecture 10

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

Binary Trees. Recursive definition. Is this a binary tree?

Data Structures. Trees. By Dr. Mohammad Ali H. Eljinini. M.A. Eljinini, PhD

Transcription:

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. 1

Problem 1 (8 points) For questions (1) to (4), choose the answer from this set of 10 choices and write the Big Oh form in the answer space. O (1) O (log N) O ( N) O(N) O( N log log N) 2 3 O ( N log N) O ( N ) O ( N ) O( 2 N ) (1) The best case runtime for insertion sorting an array of N items. (2) The (average case) runtime for quick sorting an array of N items, averaged over all possible permutations of the data. (3) The worst case runtime for building a BST for an input array of N items. (4) Runtime of the code section below. Ans = 1; while ( N > 0 ) { Ans = Ans*2; N = N/2 ; } Problem 2 (12 points) Assume that the inputs to the following pseudo code programs are arrays A and B of size n and m. Give the running time of each statement using big-oh notation. (5) for i = 1 to n A[i] = i + 1 for j = 1 to m B[j] = A[i] 1 for k = 1 to n sum = sum + B[j] Problem 3 (10 pts) (a) Give the formal definition for a function f(n) to be O(g(n)). (b) Then, formally show that 2n+1/n is O(n) 2

Problem 4 (7 points) For the binary tree shown to the right answer the following questions: a. What is the height of tree A? B A C b. What is the depth of node L? D E F c. What is the Parent node of node I? G H I J d. List the siblings of node F. K L M e. List the ancestors of node E. f. What is the postorder traversal of the subtree D? N O g. If the tree is modified to be as small as possible, what is its new height? Problem 5 (15 pts) This problem begins with the following BST. 63 / \ 45 82 \ \ 56 87 (a) Give an input sequence that would result in the above tree using the simple insert routine without balancing. 3

(b) Show the tree resulting by inserting 65 and 48 into the above tree. (c) If the BST is now unbalanced: show how to do a rotation to balance it. (d) Show how to delete 63 from the BST and state what operations you do. Problem 6 (5 pts) Answer the following short answer questions in the space provided. A. What is the height of an AVL tree that contains 35 nodes? 4

B. If h is the height of a binary search tree and there are 100 nodes in the tree. What is the range of possible h? h Problem 7 (15 points) (Heap will not be tested in the first exam) Below is a list of data structures and three applications. Select two data structures that you think would be the most useful for the particular application. Of the two data structures that you selected, pick the better of the two and explain why it is better for that particular application. State all relevant assumptions. Data Structures: Simple Array Single Linked list Binary Tree Binary Search Tree AVL Tree Heap B-Tree 5

Large Movie Database: You need a way to find, insert and delete data within a large movie database that will not fit entirely in main memory. Because this doesn t fit into main memory, you need to conserve the number of disk accesses. Dictionary: You need a way to search a dictionary quickly to see if a word is spelled correctly. The access times need to be as quick as possible. You can assume that the entire dictionary can be loaded into memory and doesn t change. Robot Requests: You have a robot that receives job requests from the Internet. These requests need to be processed based on their priority. The most urgent job needs to be executed first and then deleted. Choose a data structure to organize these jobs, support job insertion, the most urgent job extraction and deletion. 6

Problem 8 A scientist is studying the overweighting problem in children. He has a database containing the information such as the age, diet, weight, height etc. for each child in his study. He wants to organize this database such that he can extract the names of children for a given weight very quickly. Using a BST to organize the following data entries. Note that you only need to show the key for each node in the tree. Name weight(lb) height age gender Alex 90 5 15 M Mary 75 4 5 14 F Luci 80 4 3 14 F Dan 76 5 14 M Nora 100 4 2 13 F Duncan 120 5 2 14 M Ian 94 4 4 13 M 7