Analysis of Algorithms I: Optimal Binary Search Trees


 Katrina Riley
 5 years ago
 Views:
Transcription
1 Analysis of Algorithms I: Optimal Binary Search Trees Xi Chen Columbia University
2 Given a set of n keys K = {k 1,..., k n } in sorted order: k 1 < k 2 < < k n we wish to build an optimal binary search tree with keys from K to minimize the expected number of comparisons needed for each search operation. We consider the following setting slightly simpler than the one discussed in Section 15.5 of the textbook. Assume we know in advance that for each search operation in the future, the key k to search for always comes from K and satisfies k = k i with probability p i, for each i = 1, 2,..., n;
3 This implies that n p i = 1 i=1 Let T be a binary search tree with keys k 1,..., k n. So T has n nodes and each node is labelled with a key k i. We use depth T (k i ) to denote the depth of the node labelled with k i plus one (so if k r is the key at the root, then we set depth T (k r ) = 1 instead of 0). It is clear that if the key we search for is k = k i, then the number of comparisons needed is exactly depth T (k i ).
4 Thus, the expected number of comparisons is n p i depth T (k i ) i=1 and we will refer to it as cost(t ), the cost of tree T. The goal is then to find an optimal binary search tree T for K = {k 1,..., k n } with the minimum cost. As usual, we start by describing a dynamic programming algorithm that computes the minimum cost. It can be then used to construct an optimal BST.
5 Note the difference between this problem and Huffman trees. In the latter we only need to build a tree (instead of a binary search tree) in which each leaf is labelled with a character. Also in Huffman trees, the cost of a tree is the expected depth of leaves. Here the cost is the expected depth over all nodes.
6 Again, we use dynamic programming. To this end, we first need to figure out the optimal substructure of the problem, which will then lead us to a recursive formula that reduces the problem to smaller subproblems. Here the first choice to make, when constructing a binary search tree for K, is which key to put at the root of the tree.
7 Assume the key at the root is k r. Denote the tree by T, its left subtree by T L, and its right subtree by T R. We know T L has keys k 1,..., k r 1 and T R has keys k r+1,..., k n. Then for any k i, i < r: For any k j, j > r, we have: depth T (k i ) = depth TL (k i ) + 1 depth T (k j ) = depth TR (k j ) + 1
8 As a result, we have cost(t ) n = p i depth T (k i ) i=1 = 1 p r + p i (depth TL (k i ) + 1 ) + p j (depth TR (k j ) + 1 ) i<r j>r n = cost(t L ) + cost(t R ) + p i = 1 + cost(t L ) + cost(t R ) i=1
9 This equation implies the following: Denote by c r 1 the cost of an optimal BST with keys k 1,..., k r 1, and by c r+1 the cost of an optimal BST with keys k r+1,..., k n. Then the minimum cost of a binary search tree for K, that has k r as its root, is exactly 1 + c r 1 + c r+1 This gives us the following recursive algorithm.
10 Naive Optimal Binary Search Tree: 1 For r = 1 to n do 2 make a recursive call to compute the cost of an optimal BST for {k 1,..., k r 1 }; store it in C[r 1] Note when r = 1, the cost of an empty BST is 0 3 make a recursive call to compute the cost of an optimal BST for {k r+1,..., k n }; store it in C [r + 1] Note when r = n, the cost of an empty BST is 0 4 output [ ] 1 + min C[r 1] + C [r + 1] r=1,...,n
11 However, the worstcase running time of this naive recursive algorithm is exponential. Note that there are only about Θ(n 2 ) subproblems we make recursive calls to solve in its recursion tree. The reason why its recursion tree is huge is because we solve the same subproblem over and over.
12 Again, we use dynamic programming to give a more efficient algorithm: maintain a table to store solutions to subproblems already solved; and solve all the subproblems one by one, using the recursive formula we found earlier, in an appropriate order.
13 For this purpose, we introduce the following notation. We let p i,j = p k, for any 1 i j n i k j Given p 1,..., p n, we can compute all p i,j s in Θ(n 2 ) time (how?).
14 Given i, j : 1 i j n, we use c i,j to denote the minimum cost of an optimal binary search tree with keys k i, k i 1,..., k j. For any i [n], we also set c i,i 1 = 0 for convenience (meaning that an empty binary search tree has cost 0). Then to obtain c i,j, we have:
15 1 If the root is k i, then the minimum cost is 0 + p i + (c i+1,j + p i+1,j ) = c i,i 1 + c i+1,j + p i,j as c i,i 1 = 0 2 If the root is k j, then the minimum cost is (c i,j 1 + p i,j 1 ) + p j + 0 = c i,j 1 + c j+1,j + p i,j as c j+1,j = 0 3 If the root is k r, where r : i < r < j, the minimum cost is (c i,r 1 + p i,r 1 ) + p r + (c r+1,j + p r+1,j ) = c i,r 1 + c r+1,j + p i,j To summarize, we get the following recursive formula: [ ] c i,j = p i,j + min ci,r 1 + c r+1,j i r j
16 This gives us the following algorithm: 1 compute p[i, j] for all i, j : 1 i j n 2 create a table c[i, j], where i, j : 1 i j + 1 n 3 set c[i, i 1] = 0 and c[i, i] = p i for all i [n] 4 for k from 1 to n 1 do 5 for i from 1 to n k do 6 set j = i + k and set [ ] c[i, j] = p[i, j] + min c[i, r 1] + c[r + 1, j] i r j 7 output c[1, n]
17 Here we fill up the table in the following order. At the beginning, all entries with j i = 1 (empty tree) and j i = 0 (tree with one single node) are ready. Then we work on entries with j i = 1, j i = 2,..., j i = n 1. Every time we work on an entry c[i, j] with j i = k, we know that all the entries c[i, j ] with j i < k have already been computed. Note that the recursive formula we use to compute c[i, j] only involves entries c[i, j ] with j i < k. So they are all ready, and we can compute c[i, j] in time O(j i). It is easy to check that the total running time is Θ(n 3 ).
Analysis of Algorithms I: Binary Search Trees
Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary
More informationData Structures and Algorithms
Data Structures and Algorithms CS2452016S06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 060: Ordered List ADT Operations: Insert an element in the list
More informationOPTIMAL BINARY SEARCH TREES
OPTIMAL BINARY SEARCH TREES 1. PREPARATION BEFORE LAB DATA STRUCTURES An optimal binary search tree is a binary search tree for which the nodes are arranged on levels such that the tree cost is minimum.
More informationBinary Search Trees (BST)
Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search
More informationOrdered Lists and Binary Trees
Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 60:
More informationSolutions to Homework 6
Solutions to Homework 6 Debasish Das EECS Department, Northwestern University ddas@northwestern.edu 1 Problem 5.24 We want to find light spanning trees with certain special properties. Given is one example
More informationCS104: Data Structures and ObjectOriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and ObjectOriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
More informationOutput: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;
50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)
More informationOn the kpath cover problem for cacti
On the kpath cover problem for cacti Zemin Jin and Xueliang Li Center for Combinatorics and LPMC Nankai University Tianjin 300071, P.R. China zeminjin@eyou.com, x.li@eyou.com Abstract In this paper we
More informationOutline BST Operations Worst case Average case Balancing AVL Redblack Btrees. Binary Search Trees. Lecturer: Georgy Gimel farb
Binary Search Trees Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 27 1 Properties of Binary Search Trees 2 Basic BST operations The worstcase time complexity of BST operations
More informationroot node level: internal node edge leaf node CS@VT Data Structures & Algorithms 20002009 McQuain
inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each
More informationLecture 6: Binary Search Trees CSCI 700  Algorithms I. Andrew Rosenberg
Lecture 6: Binary Search Trees CSCI 700  Algorithms I Andrew Rosenberg Last Time Linear Time Sorting Counting Sort Radix Sort Bucket Sort Today Binary Search Trees Data Structures Data structure is a
More informationBinary Heaps. CSE 373 Data Structures
Binary Heaps CSE Data Structures Readings Chapter Section. Binary Heaps BST implementation of a Priority Queue Worst case (degenerate tree) FindMin, DeleteMin and Insert (k) are all O(n) Best case (completely
More informationOptimal Binary Search Trees Meet Object Oriented Programming
Optimal Binary Search Trees Meet Object Oriented Programming Stuart Hansen and Lester I. McCann Computer Science Department University of Wisconsin Parkside Kenosha, WI 53141 {hansen,mccann}@cs.uwp.edu
More informationSample Questions Csci 1112 A. Bellaachia
Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k
More informationBinary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *
Binary Heaps A binary heap is another data structure. It implements a priority queue. Priority Queue has the following operations: isempty add (with priority) remove (highest priority) peek (at highest
More informationLecture 10: Regression Trees
Lecture 10: Regression Trees 36350: Data Mining October 11, 2006 Reading: Textbook, sections 5.2 and 10.5. The next three lectures are going to be about a particular kind of nonlinear predictive model,
More informationBinary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( BST) are of the form. P parent. Key. Satellite data L R
Binary Search Trees A Generic Tree Nodes in a binary search tree ( BST) are of the form P parent Key A Satellite data L R B C D E F G H I J The BST has a root node which is the only node whose parent
More informationBinary Trees and Huffman Encoding Binary Search Trees
Binary Trees and Huffman Encoding Binary Search Trees Computer Science E119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Motivation: Maintaining a Sorted Collection of Data A data dictionary
More informationA binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:
Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)
More informationFull and Complete Binary Trees
Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full
More informationBinary Search Trees CMPSC 122
Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than
More informationFrom Last Time: Remove (Delete) Operation
CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From
More informationGenerating Elementary Combinatorial Objects
Fall 2009 Combinatorial Generation Combinatorial Generation: an old subject Excerpt from: D. Knuth, History of Combinatorial Generation, in prefascicle 4B, The Art of Computer Programming Vol 4. Combinatorial
More informationThe Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n1)!
The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >
More informationBinary Heap Algorithms
CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell
More informationConverting a Number from Decimal to Binary
Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive
More informationS.Hrushikesava Raju, Associate Professor, SIETK, NarayanaVanam Road, Puttur,A.P. hkesavaraju@gmail.com. Dr. T.Swarna Latha
Efficient construction of Optimal Binary Search Trees using Data Preprocessing to improve Quality and Attribute Post computing to save Space and time through modified Dynamic Programming Technique S.Hrushikesava
More informationLinear Equations and Inequalities
Linear Equations and Inequalities Section 1.1 Prof. Wodarz Math 109  Fall 2008 Contents 1 Linear Equations 2 1.1 Standard Form of a Linear Equation................ 2 1.2 Solving Linear Equations......................
More informationUNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions.
UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING Answer THREE Questions. The Use of Electronic Calculators: is NOT Permitted. 1 Answer Question
More information24. The Branch and Bound Method
24. The Branch and Bound Method It has serious practical consequences if it is known that a combinatorial problem is NPcomplete. Then one can conclude according to the present state of science that no
More informationInformation Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay
Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture  17 ShannonFanoElias Coding and Introduction to Arithmetic Coding
More informationS. Muthusundari. Research Scholar, Dept of CSE, Sathyabama University Chennai, India email: nellailath@yahoo.co.in. Dr. R. M.
A Sorting based Algorithm for the Construction of Balanced Search Tree Automatically for smaller elements and with minimum of one Rotation for Greater Elements from BST S. Muthusundari Research Scholar,
More informationWhy? A central concept in Computer Science. Algorithms are ubiquitous.
Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online
More informationA binary search tree is a binary tree with a special property called the BSTproperty, which is given as follows:
Chapter 12: Binary Search Trees A binary search tree is a binary tree with a special property called the BSTproperty, which is given as follows: For all nodes x and y, if y belongs to the left subtree
More informationPrevious Lectures. BTrees. External storage. Two types of memory. Btrees. Main principles
BTrees Algorithms and data structures for external memory as opposed to the main memory BTrees Previous Lectures Height balanced binary search trees: AVL trees, redblack trees. Multiway search trees:
More informationRecursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1
Recursion Slides by Christopher M Bourke Instructor: Berthe Y Choueiry Fall 007 Computer Science & Engineering 35 Introduction to Discrete Mathematics Sections 717 of Rosen cse35@cseunledu Recursive Algorithms
More informationInfluences in lowdegree polynomials
Influences in lowdegree polynomials Artūrs Bačkurs December 12, 2012 1 Introduction In 3] it is conjectured that every bounded real polynomial has a highly influential variable The conjecture is known
More informationCS473  Algorithms I
CS473  Algorithms I Lecture 4 The DivideandConquer Design Paradigm View in slideshow mode 1 Reminder: Merge Sort Input array A sort this half sort this half Divide Conquer merge two sorted halves Combine
More informationChapter 14 The Binary Search Tree
Chapter 14 The Binary Search Tree In Chapter 5 we discussed the binary search algorithm, which depends on a sorted vector. Although the binary search, being in O(lg(n)), is very efficient, inserting a
More informationMatrixChain Multiplication
MatrixChain Multiplication Let A be an n by m matrix, let B be an m by p matrix, then C = AB is an n by p matrix. C = AB can be computed in O(nmp) time, using traditional matrix multiplication. Suppose
More informationChapter 13: Query Processing. Basic Steps in Query Processing
Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing
More informationLearning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees
Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture
More informationLecture 4 Online and streaming algorithms for clustering
CSE 291: Geometric algorithms Spring 2013 Lecture 4 Online and streaming algorithms for clustering 4.1 Online kclustering To the extent that clustering takes place in the brain, it happens in an online
More informationNear Optimal Solutions
Near Optimal Solutions Many important optimization problems are lacking efficient solutions. NPComplete problems unlikely to have polynomial time solutions. Good heuristics important for such problems.
More informationRotation Operation for Binary Search Trees Idea:
Rotation Operation for Binary Search Trees Idea: Change a few pointers at a particular place in the tree so that one subtree becomes less deep in exchange for another one becoming deeper. A sequence of
More informationAlgorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. RalfPeter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
More informationData Caching in Networks with Reading, Writing and Storage Costs
Data Caching in Networks with Reading, 1 Writing and Storage Costs Himanshu Gupta Computer Science Department Stony Brook University Stony Brook, NY 11790 Email: hgupta@cs.sunysb.edu Bin Tang Computer
More informationBTrees. Algorithms and data structures for external memory as opposed to the main memory BTrees. B trees
BTrees Algorithms and data structures for external memory as opposed to the main memory BTrees Previous Lectures Height balanced binary search trees: AVL trees, redblack trees. Multiway search trees:
More informationBinary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child
Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 116 Arbitrary binary tree FIGURE 117 Binary search tree Data Structures Using
More informationCSE 326: Data Structures BTrees and B+ Trees
Announcements (4//08) CSE 26: Data Structures BTrees and B+ Trees Brian Curless Spring 2008 Midterm on Friday Special office hour: 4:5: Thursday in Jaech Gallery (6 th floor of CSE building) This is
More informationCSCE 310J Data Structures & Algorithms. Dynamic programming 01 Knapsack problem. Dynamic programming. Dynamic Programming. Knapsack problem (Review)
CSCE J Data Structures & Algorithms Dynamic programming  Knapsac problem Dr. Steve Goddard goddard@cse.unl.edu CSCE J Data Structures & Algorithms Giving credit where credit is due:» Most of slides for
More informationSatisfiability Checking
Satisfiability Checking SATSolving Prof. Dr. Erika Ábrahám Theory of Hybrid Systems Informatik 2 WS 10/11 Prof. Dr. Erika Ábrahám  Satisfiability Checking 1 / 40 A basic SAT algorithm Assume the CNF
More informationLecture Notes on Binary Search Trees
Lecture Notes on Binary Search Trees 15122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure
More informationDNS LOOKUP SYSTEM DATA STRUCTURES AND ALGORITHMS PROJECT REPORT
DNS LOOKUP SYSTEM DATA STRUCTURES AND ALGORITHMS PROJECT REPORT By GROUP Avadhut Gurjar Mohsin Patel Shraddha Pandhe Page 1 Contents 1. Introduction... 3 2. DNS Recursive Query Mechanism:...5 2.1. Client
More informationDATA STRUCTURES USING C
DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give
More informationLecture 1: Course overview, circuits, and formulas
Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik
More informationIntroduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.
Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Quiz 1 Quiz 1 Do not open this quiz booklet until you are directed
More informationBig Data and Scripting. Part 4: Memory Hierarchies
1, Big Data and Scripting Part 4: Memory Hierarchies 2, Model and Definitions memory size: M machine words total storage (on disk) of N elements (N is very large) disk size unlimited (for our considerations)
More informationIntroduction to Scheduling Theory
Introduction to Scheduling Theory Arnaud Legrand Laboratoire Informatique et Distribution IMAG CNRS, France arnaud.legrand@imag.fr November 8, 2004 1/ 26 Outline 1 Task graphs from outer space 2 Scheduling
More informationLecture 18: Applications of Dynamic Programming Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY 11794 4400
Lecture 18: Applications of Dynamic Programming Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Problem of the Day
More informationInternational Journal of Advanced Research in Computer Science and Software Engineering
Volume 3, Issue 7, July 23 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Greedy Algorithm:
More informationIntroduction to Data Structures and Algorithms
Introduction to Data Structures and Algorithms Chapter: Binary Search Trees Lehrstuhl Informatik 7 (Prof. Dr.Ing. Reinhard German) Martensstraße 3, 91058 Erlangen Search Trees Search trees can be used
More informationGENERATING THE FIBONACCI CHAIN IN O(log n) SPACE AND O(n) TIME J. Patera
ˆ ˆŠ Œ ˆ ˆ Œ ƒ Ÿ 2002.. 33.. 7 Š 539.12.01 GENERATING THE FIBONACCI CHAIN IN O(log n) SPACE AND O(n) TIME J. Patera Department of Mathematics, Faculty of Nuclear Science and Physical Engineering, Czech
More informationSorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)
Sorting revisited How did we use a binary search tree to sort an array of elements? Tree Sort Algorithm Given: An array of elements to sort 1. Build a binary search tree out of the elements 2. Traverse
More informationGraphs without proper subgraphs of minimum degree 3 and short cycles
Graphs without proper subgraphs of minimum degree 3 and short cycles Lothar Narins, Alexey Pokrovskiy, Tibor Szabó Department of Mathematics, Freie Universität, Berlin, Germany. August 22, 2014 Abstract
More informationLecture 6 Online and streaming algorithms for clustering
CSE 291: Unsupervised learning Spring 2008 Lecture 6 Online and streaming algorithms for clustering 6.1 Online kclustering To the extent that clustering takes place in the brain, it happens in an online
More informationAlgorithms Chapter 12 Binary Search Trees
Algorithms Chapter 1 Binary Search Trees Outline Assistant Professor: Ching Chi Lin 林 清 池 助 理 教 授 chingchi.lin@gmail.com Department of Computer Science and Engineering National Taiwan Ocean University
More informationAlgorithm Analysis [2]: ifelse statements, recursive algorithms. COSC 2011, Winter 2004, Section N Instructor: N. Vlajic
1 Algorithm Analysis []: ifelse statements, recursive algorithms COSC 011, Winter 004, Section N Instructor: N. Vlajic Algorithm Analysis forloop Running Time The running time of a simple loop for (int
More informationER E P M A S S I CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A19985
S I N S UN I ER E P S I T VER M A TA S CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A19985 UNIVERSITY OF TAMPERE DEPARTMENT OF
More informationReinforcement Learning
Reinforcement Learning LU 2  Markov Decision Problems and Dynamic Programming Dr. Martin Lauer AG Maschinelles Lernen und Natürlichsprachliche Systeme AlbertLudwigsUniversität Freiburg martin.lauer@kit.edu
More informationScheduling Single Machine Scheduling. Tim Nieberg
Scheduling Single Machine Scheduling Tim Nieberg Single machine models Observation: for nonpreemptive problems and regular objectives, a sequence in which the jobs are processed is sufficient to describe
More informationCpt S 223. School of EECS, WSU
Priority Queues (Heaps) 1 Motivation Queues are a standard mechanism for ordering tasks on a firstcome, firstserved basis However, some tasks may be more important or timely than others (higher priority)
More informationCSC148 Lecture 8. Algorithm Analysis Binary Search Sorting
CSC148 Lecture 8 Algorithm Analysis Binary Search Sorting Algorithm Analysis Recall definition of Big Oh: We say a function f(n) is O(g(n)) if there exists positive constants c,b such that f(n)
More informationTREE BASIC TERMINOLOGIES
TREE Trees are very flexible, versatile and powerful nonliner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and
More informationThe Goldberg Rao Algorithm for the Maximum Flow Problem
The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }
More informationBinary Coded Web Access Pattern Tree in Education Domain
Binary Coded Web Access Pattern Tree in Education Domain C. Gomathi P.G. Department of Computer Science Kongu Arts and Science College Erode638107, Tamil Nadu, India Email: kc.gomathi@gmail.com M. Moorthi
More informationAlgorithms and Data Structures
Algorithms and Data Structures CMPSC 465 LECTURES 2021 Priority Queues and Binary Heaps Adam Smith S. Raskhodnikova and A. Smith. Based on slides by C. Leiserson and E. Demaine. 1 Trees Rooted Tree: collection
More informationA Note on Maximum Independent Sets in Rectangle Intersection Graphs
A Note on Maximum Independent Sets in Rectangle Intersection Graphs Timothy M. Chan School of Computer Science University of Waterloo Waterloo, Ontario N2L 3G1, Canada tmchan@uwaterloo.ca September 12,
More informationCS473  Algorithms I
CS473  Algorithms I Lecture 9 Sorting in Linear Time View in slideshow mode 1 How Fast Can We Sort? The algorithms we have seen so far: Based on comparison of elements We only care about the relative
More informationClassifying Large Data Sets Using SVMs with Hierarchical Clusters. Presented by :Limou Wang
Classifying Large Data Sets Using SVMs with Hierarchical Clusters Presented by :Limou Wang Overview SVM Overview Motivation Hierarchical microclustering algorithm ClusteringBased SVM (CBSVM) Experimental
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationLess naive Bayes spam detection
Less naive Bayes spam detection Hongming Yang Eindhoven University of Technology Dept. EE, Rm PT 3.27, P.O.Box 53, 5600MB Eindhoven The Netherlands. Email:h.m.yang@tue.nl also CoSiNe Connectivity Systems
More informationEuclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014
Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li Advised by: Dave Mount May 22, 2014 1 INTRODUCTION In this report we consider the implementation of an efficient
More informationQuestions 1 through 25 are worth 2 points each. Choose one best answer for each.
Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in
More informationKrishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA213 : DATA STRUCTURES USING C
Tutorial#1 Q 1: Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2: What is a Data Type? Differentiate
More informationRandomization Approaches for Network Revenue Management with Customer Choice Behavior
Randomization Approaches for Network Revenue Management with Customer Choice Behavior Sumit Kunnumkal Indian School of Business, Gachibowli, Hyderabad, 500032, India sumit kunnumkal@isb.edu March 9, 2011
More informationReinforcement Learning
Reinforcement Learning LU 2  Markov Decision Problems and Dynamic Programming Dr. Joschka Bödecker AG Maschinelles Lernen und Natürlichsprachliche Systeme AlbertLudwigsUniversität Freiburg jboedeck@informatik.unifreiburg.de
More informationEfficient Algorithms to Globally Balance a Binary Search Tree
RESEARCH CONTRIBUTIONS Programming Techniques and Data Structures Ellis Horowitz Editor Efficient Algorithms to Globally Balance a Binary Search Tree HSl CHANG and S. SlTHARAMA IYENGAR ABSTRACT: A binary
More informationClassification/Decision Trees (II)
Classification/Decision Trees (II) Department of Statistics The Pennsylvania State University Email: jiali@stat.psu.edu Right Sized Trees Let the expected misclassification rate of a tree T be R (T ).
More informationFrsq: A Binary Image Coding Method
Frsq: A Binary Image Coding Method Peter L. Stanchev, William I. Grosky, John G. Geske Kettering University, Flint, MI 4854, {pstanche, jgeske}@kettering.edu University of MichiganDearborn, Dearborn,
More informationDynamic programming. Doctoral course Optimization on graphs  Lecture 4.1. Giovanni Righini. January 17 th, 2013
Dynamic programming Doctoral course Optimization on graphs  Lecture.1 Giovanni Righini January 1 th, 201 Implicit enumeration Combinatorial optimization problems are in general NPhard and we usually
More informationSection IV.1: Recursive Algorithms and Recursion Trees
Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller
More informationDetection of changes in variance using binary segmentation and optimal partitioning
Detection of changes in variance using binary segmentation and optimal partitioning Christian Rohrbeck Abstract This work explores the performance of binary segmentation and optimal partitioning in the
More informationTables so far. set() get() delete() BST Average O(lg n) O(lg n) O(lg n) Worst O(n) O(n) O(n) RB Tree Average O(lg n) O(lg n) O(lg n)
Hash Tables Tables so far set() get() delete() BST Average O(lg n) O(lg n) O(lg n) Worst O(n) O(n) O(n) RB Tree Average O(lg n) O(lg n) O(lg n) Worst O(lg n) O(lg n) O(lg n) Table naïve array implementation
More informationGenerating models of a matched formula with a polynomial delay
Generating models of a matched formula with a polynomial delay Petr Savicky Institute of Computer Science, Academy of Sciences of Czech Republic, Pod Vodárenskou Věží 2, 182 07 Praha 8, Czech Republic
More informationTesting LTL Formula Translation into Büchi Automata
Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN02015 HUT, Finland
More informationDiscrete Optimization
Discrete Optimization [Chen, Batson, Dang: Applied integer Programming] Chapter 3 and 4.14.3 by Johan Högdahl and Victoria Svedberg Seminar 2, 20150331 Todays presentation Chapter 3 Transforms using
More informationFinal Report. to the. Center for Multimodal Solutions for Congestion Mitigation (CMS) CMS Project Number: 2010018
Final Report to the Center for Multimodal Solutions for Congestion Mitigation (CMS) CMS Project Number: 2010018 CMS Project Title: Impacts of Efficient Transportation Capacity Utilization via MultiProduct
More informationHome Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit
Data Structures Page 1 of 24 A.1. Arrays (Vectors) nelement vector start address + ielementsize 0 +1 +2 +3 +4... +n1 start address continuous memory block static, if size is known at compile time dynamic,
More information