Data Structures and Programming Spring 2014, Midterm Exam.
|
|
- Marcia Harper
- 5 years ago
- Views:
Transcription
1 Data Structures and Programming Spring 2014, Midterm Exam. 1. (10 pts) Order te following functions 2.2 n, log(n 10 ), , 25n log(n), 1.1 n, 2n 5.5, 4 log(n), 2 10, n 1.02, 5n 5, 76n, 8n 5 + 5n 2 by teir asymptotic growt rate, in non-decreasing order. Indicate by circling tose functions tat are big- Teta (i.e., Θ(..)) of eac oter = 2 10 < log(n 10 ) = 4 log(n) < 76n < 25n log(n) < n 1.02 < 5n 5 = 8n 5 + 5n 2 < 2n 5.5 < 1.1 n < 2.2 n 2. (8 pts) Give te best asymptotic ( big-o, i.e., O()) caracterization of te best and worst case time complexity of te algoritm Count(A, B, n). Explain in detail ow you computed te complexity. Note tat denotes te assignment statement. Algoritm Count(A, B, n) Input: Arrays A and B of size n. A, B store positive integers. i 0 sum 0 wile i < n do if A[i] < n ten for j 0 to A[i] do sum sum + B[j] i i + 1 return sum Best case: O(n) wen if A[i] < n always false; Worst case: O(n 2 ) wen wen if A[i] < n always true 3. (10 pts) Consider te use of te exclusive-or encoding metod to represent doubly linked lists as discussed in class. Given a node X, let Link(X) be te exclusive-or encoding kept in node X, i.e., Link(X) is te outcome of taking te exclusive-or of te addresses of X s predecessor and successor along te list. Consider a doubly linked list consisting of te following: X 1 X 2 X 3 X 4 X 5 X 6. Suppose pointers P and Q point to nodes X 3 and X 4, respectively. Explain te updates needed to delete X 3 and X 4, making te new list X 1 X 2 X 5 X 6. Note tat after te deletion, P and Q point to X 2 and X 5, respectively. Use additional temporary pointer(s), if needed. You may use te notation x y exp 1 exp 2 defined in class to describe your algoritm. Before Address Link( Link(P ) Q) Link(P ) Q P Q Link(Q) P Link(Link(Q) P ) P Q Node X 1 X 2 X 3 X 4 X 5 X 6 After Address P new Link(P ) Q Q new Link(Q) P Node X 1 X 2 X 5 X 6 Link (Link( Link(P ) Q) (Link(Link(Q) P )) P ) ( Link(Q) P ) Q) ( Link(P ) Q) Hence, te operations are P Q Link(Link(P) Q) Link(Link(Q) P ) Link(P) Q Link(Q) P (Link(Link(P) Q) P ) ( Link(Q) P ) (Link(Link(Q) P )) Q) ( Link(P ) Q) 1
2 4. (10 pts) Suppose tat we ave numbers between 1 and 1000 in a binary searc tree and want to searc for te number 363. For eac of te following sequences, can it be te sequence of nodes examined? Yes or No? No explanations are needed. (a) 2, 252, 401, 398, 330, 344, 397, 363 (b) 924, 220, 911, 244, 898, 258, 362, 363 (c) 925, 202, 911, 240, 912, 245, 363 (d) 2, 399, 387, 219, 266, 382, 381, 278, 363 (e) 935, 278, 347, 621, 299, 392, 358, 363 Solutions: (c) and (e): NO. 5. (12 pts) Consider te following AVL tree. Perform operation delete(1) and rebalance te tree if necessary. You ave to use exactly te same algoritm as in class. Sow all te intermediate trees. Solution Figure 1: An AVL tree 2
3 6. (10 pts) (a) (4 pts) Define treaded binary trees. A binary tree is treaded by making all rigt cild pointers tat would normally be null point to te inorder successor of te node, and all left cild pointers tat would normally be null point to te inorder predecessor of te node. (b) (6 pts) Design a non-recursive algoritm to do inorder traversal of a treaded binary tree. Explain your algoritm in Cinese or Englis. Also use an example to sow ow your algoritm works. 3
4 7. (10 pts) Draw te expression tree and write te prefix and postfix forms for te following expression. Solution (A + B) D + (E/(F + A D)) + C. + + C * / + D E + A B F * A D Prefix: + + * + A B D / E + F * A D C Postfix: A B + D * E F A D * + / + C + 8. (15 pts) (a) (10 pts) Draw te Splay tree tat results from inserting te keys 4, 9, 3, 7, 5, 6 in tat order into an initially empty Splay tree. Sow all te intermediate trees (i.e., draw te tree after eac insertion is carried out). Also find te potential for eac intermediate tree using te potential function discussed in class (i.e., potential of a tree T is node x in T log(size(x)), were size(x) is te number of nodes in te subtree rooted at x. Solution Potential of te final tree is log(size(x 3 )) + log(size(x 4 )) + log(size(x 5 )) + log(size(x 6 )) + log(size(x 7 )) + log(size(x 9 )) = = 5 (b) (5 pts) Suppose we want to insert 10 numbers ({1, 2, 10}) into an initially empty Splay tree. Wat will be te order of insertions wat will result in a splay tree of eigt 10 (i.e., becoming a list). Wy? Te keys of value 10, 9,.., 4, 3, 2, 1 are inserted in tis order in a splay tree. Te resulting tree is:
5 9. (10 pts) A red-black binary searc tree (BST) is called a left-leaning red-black BST if red links lean left (i.e., eac red node is te left cild of its parent). See Figure 2 for an example. Figure 3 summarizes te rebalancing rules for left-leaning red-black trees w.r.t. insertion. Suppose we insert key 99 into te tree in Figure 2. Sow ow to rebalance te tree. Sow your derivation in sufficient detail red link left rotate rigt rotate flip colors Figure 2: A left-leaning red-black BST Figure 3: Rebalancing rules To insert 99, we do two color flips, followed by one left rotation. Here is a drawing of te resulting red-black BST (5 pts) Let A be an array of N integers. Give an algoritm to output all te distinct numbers in A in ascending order. Your algoritm must finis in O(N log T ) time, were T is te number of distinct integers in A. For example, given A = {35, 10, 59, 17, 61, 17, 52, 10}, your algoritm sould output 10, 17, 35, 52, 59, 61. Describe your algoritm in Englis or Cinese, and explain wy your algoritm takes O(N logt ) time. Scan te array and maintain all te distinct numbers in a binary tree. After reading te next element, perform dictionary searc to ceck if it already exists in te tree, and output it if not (in wic case we insert te element in te tree). As te tree indexes at most T elements at any moment, te total cost is O(NlogT ). 5
CS 234. Module 6. October 16, CS 234 Module 6 ADT Dictionary 1 / 33
CS 234 Module 6 October 16, 2018 CS 234 Module 6 ADT Dictionary 1 / 33 Idea for an ADT Te ADT Dictionary stores pairs (key, element), were keys are distinct and elements can be any data. Notes: Tis is
More informationLecture 7. Binary Search Trees / AVL Trees
Lecture 7. Binary Searc Trees / AVL Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algoritms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Coo coo@skku.edu Copyrigt
More informationAVL Trees Outline and Required Reading: AVL Trees ( 11.2) CSE 2011, Winter 2017 Instructor: N. Vlajic
1 AVL Trees Outline and Required Reading: AVL Trees ( 11.2) CSE 2011, Winter 2017 Instructor: N. Vlajic AVL Trees 2 Binary Searc Trees better tan linear dictionaries; owever, te worst case performance
More informationCS 234. Module 6. October 25, CS 234 Module 6 ADT Dictionary 1 / 22
CS 234 Module 6 October 25, 2016 CS 234 Module 6 ADT Dictionary 1 / 22 Case study Problem: Find a way to store student records for a course, wit unique IDs for eac student, were records can be accessed,
More informationAnnouncements. Lilian s office hours rescheduled: Fri 2-4pm HW2 out tomorrow, due Thursday, 7/7. CSE373: Data Structures & Algorithms
Announcements Lilian s office ours resceduled: Fri 2-4pm HW2 out tomorrow, due Tursday, 7/7 CSE373: Data Structures & Algoritms Deletion in BST 2 5 5 2 9 20 7 0 7 30 Wy migt deletion be arder tan insertion?
More informationCSE 332: Data Structures & Parallelism Lecture 8: AVL Trees. Ruth Anderson Winter 2019
CSE 2: Data Structures & Parallelism Lecture 8: AVL Trees Rut Anderson Winter 29 Today Dictionaries AVL Trees /25/29 2 Te AVL Balance Condition: Left and rigt subtrees of every node ave eigts differing
More informationeach node in the tree, the difference in height of its two subtrees is at the most p. AVL tree is a BST that is height-balanced-1-tree.
Data Structures CSC212 1 AVL Trees A binary tree is a eigt-balanced-p-tree if for eac node in te tree, te difference in eigt of its two subtrees is at te most p. AVL tree is a BST tat is eigt-balanced-tree.
More informationBinary Search Tree - Best Time. AVL Trees. Binary Search Tree - Worst Time. Balanced and unbalanced BST
AL Trees CSE Data Structures Unit Reading: Section 4.4 Binary Searc Tree - Best Time All BST operations are O(d), were d is tree dept minimum d is d = log for a binary tree N wit N nodes at is te best
More informationCE 221 Data Structures and Algorithms
CE Data Structures and Algoritms Capter 4: Trees (AVL Trees) Text: Read Weiss, 4.4 Izmir University of Economics AVL Trees An AVL (Adelson-Velskii and Landis) tree is a binary searc tree wit a balance
More information1 Copyright 2012 by Pearson Education, Inc. All Rights Reserved.
CHAPTER 20 AVL Trees Objectives To know wat an AVL tree is ( 20.1). To understand ow to rebalance a tree using te LL rotation, LR rotation, RR rotation, and RL rotation ( 20.2). To know ow to design te
More informationWhen a BST becomes badly unbalanced, the search behavior can degenerate to that of a sorted linked list, O(N).
Balanced Binary Trees Binary searc trees provide O(log N) searc times provided tat te nodes are distributed in a reasonably balanced manner. Unfortunately, tat is not always te case and performing a sequence
More informationWrap up Amortized Analysis; AVL Trees. Riley Porter Winter CSE373: Data Structures & Algorithms
CSE 373: Data Structures & Wrap up Amortized Analysis; AVL Trees Riley Porter Course Logistics Symposium offered by CSE department today HW2 released, Big- O, Heaps (lecture slides ave pseudocode tat will
More informationAlgorithms. 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 informationAdvanced Tree. Structures. AVL Tree. Outline. AVL Tree Recall, Binary Search Tree (BST) is a special case of. Splay Tree (Ch 13.2.
ttp://1...0/csd/ Data tructure Capter 1 Advanced Tree tructures Dr. atrick Can cool of Computer cience and Engineering out Cina Universit of Tecnolog AVL Tree Recall, Binar earc Tree (BT) is a special
More information15-122: Principles of Imperative Computation, Summer 2011 Assignment 6: Trees and Secret Codes
15-122: Principles of Imperative Computation, Summer 2011 Assignment 6: Trees and Secret Codes William Lovas (wlovas@cs) Karl Naden Out: Tuesday, Friday, June 10, 2011 Due: Monday, June 13, 2011 (Written
More information4.1 Tangent Lines. y 2 y 1 = y 2 y 1
41 Tangent Lines Introduction Recall tat te slope of a line tells us ow fast te line rises or falls Given distinct points (x 1, y 1 ) and (x 2, y 2 ), te slope of te line troug tese two points is cange
More informationAVL Trees. CSE260, Computer Science B: Honors Stony Brook University
AVL Trees CSE260, Computer Science B: Honors Stony Brook University ttp://www.cs.stonybrook.edu/~cse260 1 Objectives To know wat an AVL tree is To understand ow to rebalance a tree using te LL rotation,
More informationTREES. General Binary Trees The Search Tree ADT Binary Search Trees AVL Trees Threaded trees Splay Trees B-Trees. UNIT -II
UNIT -II TREES General Binary Trees Te Searc Tree DT Binary Searc Trees VL Trees Treaded trees Splay Trees B-Trees. 2MRKS Q& 1. Define Tree tree is a data structure, wic represents ierarcical relationsip
More informationSorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min
Binary Search Trees FRIDAY ALGORITHMS Sorted Arrays Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min 6 10 11 17 2 0 6 Running Time O(1) O(lg n) O(1) O(1)
More informationDesign Patterns for Data Structures. Chapter 10. Balanced Trees
Capter 10 Balanced Trees Capter 10 Four eigt-balanced trees: Red-Black binary tree Faster tan AVL for insertion and removal Adelsen-Velskii Landis (AVL) binary tree Faster tan red-black for lookup B-tree
More informationSection 2.3: Calculating Limits using the Limit Laws
Section 2.3: Calculating Limits using te Limit Laws In previous sections, we used graps and numerics to approimate te value of a it if it eists. Te problem wit tis owever is tat it does not always give
More informationBinary Search Trees. Analysis of Algorithms
Binary Search Trees Analysis of Algorithms Binary Search Trees A BST is a binary tree in symmetric order 31 Each node has a key and every node s key is: 19 23 25 35 38 40 larger than all keys in its left
More informationCSE 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 informationDesign Patterns for Data Structures. Chapter 10. Balanced Trees
Capter 10 Balanced Trees Capter 10 Four eigt-balanced trees: Red-Black binary tree Faster tan AVL for insertion and removal Adelsen-Velskii Landis (AVL) binary tree Faster tan red-black for lookup B-tree
More informationCHAPTER 7: TRANSCENDENTAL FUNCTIONS
7.0 Introduction and One to one Functions Contemporary Calculus 1 CHAPTER 7: TRANSCENDENTAL FUNCTIONS Introduction In te previous capters we saw ow to calculate and use te derivatives and integrals of
More informationCSE373 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 informationCS211 Spring 2004 Lecture 06 Loops and their invariants. Software engineering reason for using loop invariants
CS211 Spring 2004 Lecture 06 Loops and teir invariants Reading material: Tese notes. Weiss: Noting on invariants. ProgramLive: Capter 7 and 8 O! Tou ast damnale iteration and art, indeed, ale to corrupt
More information1.4 RATIONAL EXPRESSIONS
6 CHAPTER Fundamentals.4 RATIONAL EXPRESSIONS Te Domain of an Algebraic Epression Simplifying Rational Epressions Multiplying and Dividing Rational Epressions Adding and Subtracting Rational Epressions
More informationCS 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 informationProblem Set 5 Due: Friday, November 2
CS231 Algorithms Handout # 19 Prof. Lyn Turbak October 26, 2001 Wellesley College Problem Set 5 Due: Friday, November 2 Important: On Friday, Nov. 2, you will receive a take-home midterm exam that is due
More information4.2 The Derivative. f(x + h) f(x) lim
4.2 Te Derivative Introduction In te previous section, it was sown tat if a function f as a nonvertical tangent line at a point (x, f(x)), ten its slope is given by te it f(x + ) f(x). (*) Tis is potentially
More informationTrees. (Trees) Data Structures and Programming Spring / 28
Trees (Trees) Data Structures and Programming Spring 2018 1 / 28 Trees A tree is a collection of nodes, which can be empty (recursive definition) If not empty, a tree consists of a distinguished node r
More informationCSE 373 Spring Midterm. Friday April 21st
CSE 373 Spring 2006 Data Structures and Algorithms Midterm Friday April 21st NAME : Do all your work on these pages. Do not add any pages. Use back pages if necessary. Show your work to get partial credit.
More informationSection 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents
Section 5.5 Binary Tree A binary tree is a rooted tree in which each vertex has at most two children and each child is designated as being a left child or a right child. Thus, in a binary tree, each vertex
More informationCSE 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 information2 The Derivative. 2.0 Introduction to Derivatives. Slopes of Tangent Lines: Graphically
2 Te Derivative Te two previous capters ave laid te foundation for te study of calculus. Tey provided a review of some material you will need and started to empasize te various ways we will view and use
More informationHash-Based Indexes. Chapter 11. Comp 521 Files and Databases Spring
Has-Based Indexes Capter 11 Comp 521 Files and Databases Spring 2010 1 Introduction As for any index, 3 alternatives for data entries k*: Data record wit key value k
More informationCS102 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 informationMLR Institute of Technology
MLR Institute of Technology Laxma Reddy Avenue, Dundigal, Quthbullapur (M), Hyderabad 500 043 Phone Nos: 08418 204066 / 204088, Fax : 08418 204088 TUTORIAL QUESTION BANK Course Name : DATA STRUCTURES Course
More informationTREES. Trees - Introduction
TREES Chapter 6 Trees - Introduction All previous data organizations we've studied are linear each element can have only one predecessor and successor Accessing all elements in a linear sequence is O(n)
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE
TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationHash-Based Indexes. Chapter 11. Comp 521 Files and Databases Fall
Has-Based Indexes Capter 11 Comp 521 Files and Databases Fall 2012 1 Introduction Hasing maps a searc key directly to te pid of te containing page/page-overflow cain Doesn t require intermediate page fetces
More informationAlgorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs
Algorithms in Systems Engineering ISE 172 Lecture 16 Dr. Ted Ralphs ISE 172 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms
More informationBinary Search Tree (2A) Young Won Lim 5/17/18
Binary Search Tree (2A) Copyright (c) 2015-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or
More informationAlgorithms. Deleting from Red-Black Trees B-Trees
Algorithms Deleting from Red-Black Trees B-Trees Recall the rules for BST deletion 1. If vertex to be deleted is a leaf, just delete it. 2. If vertex to be deleted has just one child, replace it with that
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014
University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014 Midterm Examination Instructor: Ladan Tahvildari, PhD, PEng, SMIEEE Date: Tuesday,
More informationAnalysis of Algorithms
Analysis of Algorithms Trees-I Prof. Muhammad Saeed Tree Representation.. Analysis Of Algorithms 2 .. Tree Representation Analysis Of Algorithms 3 Nomenclature Nodes (13) Size (13) Degree of a node Depth
More informationlogn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)
CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The
More information, 1 1, A complex fraction is a quotient of rational expressions (including their sums) that result
RT. Complex Fractions Wen working wit algebraic expressions, sometimes we come across needing to simplify expressions like tese: xx 9 xx +, xx + xx + xx, yy xx + xx + +, aa Simplifying Complex Fractions
More informationAreas of Triangles and Parallelograms. Bases of a parallelogram. Height of a parallelogram THEOREM 11.3: AREA OF A TRIANGLE. a and its corresponding.
11.1 Areas of Triangles and Parallelograms Goal p Find areas of triangles and parallelograms. Your Notes VOCABULARY Bases of a parallelogram Heigt of a parallelogram POSTULATE 4: AREA OF A SQUARE POSTULATE
More informationComputational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs
Computational Optimization ISE 407 Lecture 16 Dr. Ted Ralphs ISE 407 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms in
More informationMore on Functions and Their Graphs
More on Functions and Teir Graps Difference Quotient ( + ) ( ) f a f a is known as te difference quotient and is used exclusively wit functions. Te objective to keep in mind is to factor te appearing in
More informationName: UTLN: CS login: Comp 15 Data Structures Midterm 2018 Summer
[Closed book exam] There are 7 questions leading up to 100 points. Max alloted time: 1 hour Problem 1 (2x10=20 points). Fill in the blanks in terms of the big-theta (Θ) notation to show the asymptotic
More informationCSE 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 informationBounding Tree Cover Number and Positive Semidefinite Zero Forcing Number
Bounding Tree Cover Number and Positive Semidefinite Zero Forcing Number Sofia Burille Mentor: Micael Natanson September 15, 2014 Abstract Given a grap, G, wit a set of vertices, v, and edges, various
More informationFINALTERM 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
FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures
More informationCSE 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 informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 04 / 26 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? Balanced Binary Search trees AVL trees Michael Eckmann - Skidmore College - CS
More informationWe have the pointers reference the next node in an inorder traversal; called threads
Leaning Objective: In this Module you will be learning the following: Threaded Binary Tree Introduction: Threaded Binary Tree is also a binary tree in which all left child pointers that are NULL (in Linked
More informationData Structure and Algorithm Midterm Reference Solution TA
Data Structure and Algorithm Midterm Reference Solution TA email: dsa1@csie.ntu.edu.tw Problem 1. To prove log 2 n! = Θ(n log n), it suffices to show N N, c 1, c 2 > 0 such that c 1 n ln n ln n! c 2 n
More information19.2 Surface Area of Prisms and Cylinders
Name Class Date 19 Surface Area of Prisms and Cylinders Essential Question: How can you find te surface area of a prism or cylinder? Resource Locker Explore Developing a Surface Area Formula Surface area
More informationECE250: Algorithms and Data Structures Midterm Review
ECE250: Algorithms and Data Structures Midterm Review Ladan Tahvildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University of Waterloo
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 9 - Jan. 22, 2018 CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures
More informationCSE 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 informationCSCE476/876 Spring Homework 5
CSCE476/876 Spring 2016 Assigned on: Friday, Marc 11, 2016 Due: Monday, Marc 28, 2016 Homework 5 Programming assignment sould be submitted wit andin Te report can eiter be submitted wit andin as a PDF,
More informationWhen the dimensions of a solid increase by a factor of k, how does the surface area change? How does the volume change?
8.4 Surface Areas and Volumes of Similar Solids Wen te dimensions of a solid increase by a factor of k, ow does te surface area cange? How does te volume cange? 1 ACTIVITY: Comparing Surface Areas and
More informationAVL Trees. (AVL Trees) Data Structures and Programming Spring / 17
AVL Trees (AVL Trees) Data Structures and Programming Spring 2017 1 / 17 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
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 9 - Jan. 22, 2018 CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba 1 / 12 Binary Search Trees (review) Structure
More informationNumerical Derivatives
Lab 15 Numerical Derivatives Lab Objective: Understand and implement finite difference approximations of te derivative in single and multiple dimensions. Evaluate te accuracy of tese approximations. Ten
More informationCSE 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 informationBRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE
BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE CSI Section E01 AVL Trees AVL Property While BST structures have average performance of Θ(log(n))
More informationBRONX 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 informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationCS350: Data Structures Red-Black Trees
Red-Black Trees James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Red-Black Tree An alternative to AVL trees Insertion can be done in a bottom-up or
More informationData Structures in Java
Data Structures in Java Lecture 10: AVL Trees. 10/1/015 Daniel Bauer Balanced BSTs Balance condition: Guarantee that the BST is always close to a complete binary tree (every node has exactly two or zero
More informationCOSC 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 informationCMPS 2200 Fall 2017 Red-black trees Carola Wenk
CMPS 2200 Fall 2017 Red-black trees Carola Wenk Slides courtesy of Charles Leiserson with changes by Carola Wenk 9/13/17 CMPS 2200 Intro. to Algorithms 1 Dynamic Set A dynamic set, or dictionary, is a
More informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Binary Search Tree - Best Time All BST operations are O(d), where d is tree depth minimum d is d = ëlog for a binary tree
More informationMidterm solutions. n f 3 (n) = 3
Introduction to Computer Science 1, SE361 DGIST April 20, 2016 Professors Min-Soo Kim and Taesup Moon Midterm solutions Midterm solutions The midterm is a 1.5 hour exam (4:30pm 6:00pm). This is a closed
More informationAdvanced Java Concepts Unit 5: Trees. Notes and Exercises
Advanced Java Concepts Unit 5: Trees. Notes and Exercises A Tree is a data structure like the figure shown below. We don t usually care about unordered trees but that s where we ll start. Later we will
More informationSORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions:
Prelim 1 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Tonigt!!!! Two Sessions: You sould now y now wat room to tae te final. Jenna
More informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Balanced search trees Balanced search tree: A search-tree data structure for which a height of O(lg n) is guaranteed when
More information1. [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 2. O(n) 2. [1 pt] What is the solution to the recurrence T(n) = T(n/2) + n, T(1)
More informationMATH 5a Spring 2018 READING ASSIGNMENTS FOR CHAPTER 2
MATH 5a Spring 2018 READING ASSIGNMENTS FOR CHAPTER 2 Note: Tere will be a very sort online reading quiz (WebWork) on eac reading assignment due one our before class on its due date. Due dates can be found
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Binary Search Trees CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures
More informationSearch Trees. Undirected graph Directed graph Tree Binary search tree
Search Trees Undirected graph Directed graph Tree Binary search tree 1 Binary Search Tree Binary search key property: Let x be a node in a binary search tree. If y is a node in the left subtree of x, then
More informationINSTITUTE 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 informationAugmenting Data Structures
Augmenting Data Structures [Not in G &T Text. In CLRS chapter 14.] An AVL tree by itself is not very useful. To support more useful queries we need more structure. General Definition: An augmented data
More informationSplay Trees. (Splay Trees) Data Structures and Programming Spring / 27
Splay Trees (Splay Trees) Data Structures and Programming Spring 2017 1 / 27 Basic Idea Invented by Sleator and Tarjan (1985) Blind rebalancing no height info kept! Worst-case time per operation is O(n)
More informationCSSE 230 Fundamentals of Computing Final Exam
CSSE 230 Fundamentals of Computing Final Exam Winter term, 2011-2012 Your name: Instructions: This exam is open book and notes. In addition: All the work you turn in must be your own. You must not use
More informationSection 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 informationSample 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 informationSection 1.2 The Slope of a Tangent
Section 1.2 Te Slope of a Tangent You are familiar wit te concept of a tangent to a curve. Wat geometric interpretation can be given to a tangent to te grap of a function at a point? A tangent is te straigt
More informationCS-301 Data Structure. Tariq Hanif
1. The tree data structure is a Linear data structure Non-linear data structure Graphical data structure Data structure like queue FINALTERM EXAMINATION Spring 2012 CS301- Data Structure 25-07-2012 2.
More informationOperations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.
Priority Queue, Heap and Heap Sort In this time, we will study Priority queue, heap and heap sort. Heap is a data structure, which permits one to insert elements into a set and also to find the largest
More informationCSE 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 informationLecture 16 Notes AVL Trees
Lecture 16 Notes AVL Trees 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning 1 Introduction Binary search trees are an excellent data structure to implement associative arrays,
More information[ DATA STRUCTURES ] Fig. (1) : A Tree
[ DATA STRUCTURES ] Chapter - 07 : Trees A Tree is a non-linear data structure in which items are arranged in a sorted sequence. It is used to represent hierarchical relationship existing amongst several
More informationAssume 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