Quick Decoding and Encoding of Prüfer Strings: Exercises in Data Structures

Size: px
Start display at page:

Download "Quick Decoding and Encoding of Prüfer Strings: Exercises in Data Structures"

Transcription

1 Quick Decoding and Encoding of Prüfer Strings: Exercises in Data Structures Bryant A. Julstrom Department of Computer Science St. Cloud State University St. Cloud, MN Abstract Cayley's Formula tells us that a complete undirected graph on n vertices has n n-2 distinct spanning trees. Prüfer's proof of this result establishes a one-to-one correspondence between the spanning trees on n vertices and the strings of length (n - 2) over an alphabet of n symbols. The proof describes two algorithms. One identifies the edges in the spanning tree corresponding to a string, and the other builds the string corresponding to a list of edges in a spanning tree. Naive implementations of these algorithms have times that are quadratic in the number n of vertices. Elaborating the data structures they use reduces both times to O(n log n). This paper describes these faster implementations. The data structures they use are familiar to any student who has completed CS2. They include priority queues implemented with heaps and adjacency lists implemented with trees.

2 1. Introduction A spanning tree of a connected, undirected graph G is a subgraph of G that connects all of G 's vertices and contains no cycles, as Figure 1 illustrates. Clearly the number of edges in a spanning tree must be one less than the number of vertices it connects. A complete graph on n vertices has all n(n-1)/2 possible edges. When a graph is complete, Cayley's Formula tells us that it has n n-2 distinct spanning trees [Cayley, 1889; Even, 1973, pp ]. Figure 1: A graph on a collection of vertices (a) and a spanning tree for that graph (b). Computer Science students generally encounter graphs, and write programs that represent and operate on them, in CS2, Data Structures. They will already have seen various structures based on and related to trees, such as binary search trees and priority queues implemented with heaps. The need to perform quickly operations that find, insert, and remove items motivates the introduction of these structures. In programs that operate on graphs, the graphs themselves can be represented in several ways. These include adjacency matrices, in which entry (i,j) indicates the presence or absence of the edge connecting vertices v i and v j, adjacency lists, in which there is, for each vertex, a list of the other vertices with which it forms edges, and simple lists of edges, which can be implemented as linked structures or in arrays. A constructive proof of Cayley's Formula, due to Prüfer [1918; Even, 1973, pp ], provides another representation for graphs that are spanning trees. Prüfer's proof establishes a one-to-one correspondence between spanning trees on n vertices and strings of length (n - 2) over an alphabet of n symbols; note that there are n n-2 such strings. The proof describes two algorithms. The first identifies the edges in a spanning tree from a string, and the second builds the string from the edges in the spanning tree. Thus these strings encode spanning trees. Prüfer strings have been used to represent spanning trees, for example, in genetic algorithms for computationally difficult problems that search spaces of spanning trees. These have included the rectilinear Steiner problem [Julstrom, 1993], the probabilistic minimum spanning tree problem [Abuali, Schoenefeld, and Wainwright, 1994], the degree-bounded minimum spanning tree problem

3 [Zhou and Gen, 1997], the time-dependent minimum spanning tree problem [Gargano, Edelson, and Koval, 1998], and a network design problem [Kim and Gen, 1999]. Such applications must identify the spanning trees Prüfer strings represent and encode spanning trees as Prüfer strings. Straightforward implementations of the two algorithms in Prüfer's proof have times that are O(n 2 ). Elaborating the data structures the algorithms use can reduce both times to O(n log n). This paper describes these faster implementations. The data structures they use include arrays, priority queues implemented with heaps, and adjacency lists implemented with trees. These structures are familiar to any student of CS2, and the resulting algorithms make interesting examples of their application. The following sections of this paper describe the Prüfer coding of spanning trees and the basic conversion algorithms; an efficient algorithm for building a list of edges from a Prüfer string, and an efficient algorithm for building a Prüfer string from a list of spanning tree edges. 2. The Prüfer coding of spanning trees Cayley's Formula establishes that a complete graph on n vertices has n n -2 distinct spanning trees. Prüfer's proof achieves this result constructively by describing a one-to-one correspondence between the spanning trees on n vertices and strings of length (n - 2) over an alphabet of n symbols. The symbols must be ordered, and one labels each vertex. Consider identifying the spanning tree (that is, the list of edges) that a Prüfer string represents. In particular, let s = a 1 a 2... a n-2 be a Prüfer string. The degree of a vertex in a graph is the number of edges in which the vertex participates. In the spanning tree corresponding to a Prüfer string, each vertex's degree is one plus the number of times its symbol appears in the string. The following algorithm identifies the tree's edges. scan the Prüfer string to initialize the vertices' degrees; for i from 1 to n-2 loop v <- the vertex with the smallest label whose degree is 1; (v,a i ) is a spanning tree edge; decrement the degrees of v and a i ; end loop; two vertices have degree 1; they form the last edge; For example, let the letters a through g label seven vertices, and consider the spanning tree on them represented by the Prüfer string bebbg. Counting the occurrences in the string of the vertices' labels and adding 1 to each count, the degrees of the vertices are:

4 The smallest-named vertex with degree 1 is a, and b is the string's first symbol, so (a,b) is an edge in the spanning tree. The degrees of both a and b are decremented to obtain Now the smallest-named vertex with degree 1 is c, so (c,e) is a spanning tree edge and the degrees of c and e are decremented. The process continues through three more iterations, identifying the edges (d,b), (e,b), and (b,g). At this point, the vertices' degrees are all zero except for f and g, which form the spanning tree's last edge. Figure 2 shows the resulting spanning tree. Figure 2: The spanning tree corresponding to the Prüfer string bebbg. A simple implementation of this algorithm holds the vertices' degrees in an array and scans that array (n - 2) times. On each iteration, it finds the smallest-named vertex with current degree 1. The array contains n entries, of course, so the implementation's time is O(n 2 ). Conversely, consider building a Prüfer string from a list of edges that form a spanning tree. Again, the vertices' degrees are crucial, and the algorithm's first step is to find them. scan the list of edges to initialize the vertices' degrees; for i from 1 to n-2 loop u <- the vertex of degree 1 with the smallest label; v <- the other vertex in u's edge; the i th Prüfer symbol is v; remove (u,v) from the list of edges; decrement the degrees of u and v; end loop; For example, we know that the edges (a,b), (b,e), (d,b), (e,c), (b,g), and (g,f) form a spanning tree on seven vertices labeled a through g. The vertex of degree 1 with the smallest label in this list is a, found in the edge (a,b); the edge's other vertex b is the first symbol in the tree's Prüfer string. After removing (a,b) from the list of edges, the smallest-labeled vertex of degree 1 is c; the other vertex of its edge, e, joins the Prüfer string, the edge leaves the list, and so on. The resulting string is, of course, bebbg.

5 Again, a simple implementation of this algorithm maintains an array of the vertices' degrees and a list of the spanning tree edges. Each of its (n - 2) iterations scans the array and the list, so the implementation's time is O(n 2 ). The following two sections describe how more sophisticated data structures---in particular, priority queues implemented with heaps and lists of vertices implemented with trees---can be used in implementations of these two algorithms whose times are O(n log n). 3. Efficiently decoding Prüfer strings In the algorithm that extracts the edges in a spanning tree from its Prüfer string, one vertex of each edge has in turn the smallest label among the vertices with current degree 1. If the algorithm identifies this vertex by scanning an array of the vertices' degrees, its time is O(n 2 ). The number of edges in a spanning tree on n vertices is always (n - 1) and each must be listed, so a faster version of this algorithm must more quickly identify the vertex of current degree 1 with the smallest label. To do this, the algorithm cannot scan the array of vertices' degrees and must maintain another data structure. That structure is a priority queue that holds the vertices whose current degrees are 1, and in which vertices with smaller labels have higher priority. In general, a priority queue holds a collection of items, each with an associated priority. When an item is removed from the queue (dequeued), it is always the item with the highest priority. When the queue is implemented in a binary heap, and the heap in turn is implemented in an array, the operations of dequeueing the highest-priority item and restoring the heap and of enqueueing a new item can each be carried out in time that is O(log n), where n is the number of items in the queue [Williams, 1964; Aho, Hopcroft, and Ullman, 1983, pp ; Manber, 1989, pp.68-70]. We elaborate the algorithm to include a priority queue of the vertices with current degree 1. Each vertex is enqueued when its degree falls to 1, and the next vertex dequeued always has the smallest label among the vertices with degree 1. In the following sketch of the algorithm, the Prüfer string is p[], and an array maintains the degrees of the vertices. scan p[] to initialize the vertices' degrees; enqueue the vertices with degree 1; for i from 1 to n-1 loop dequeue, and assign the dequeued vertex to v; (v,p[i]) is a spanning tree edge; decrement the degrees of v and p[i]; if the degree of p[i] is 1 then enqueue p[i]; end loop; dequeue twice to identify the vertices of the last edge;

6 Figure 3 shows this algorithm's two data structures---the array of the vertices' degrees and the priority queue, implemented in a heap, of the vertices with degree 1---after they have been initialized and before the first loop iteration as the algorithm decodes the Prüfer string bebbg. Figure 3: The array of vertices' degrees and the priority queue of vertices of degree 1, implemented with a heap, as the extended algorithm begins to decode the Prüfer string bebbg. In general, as the algorithm identifies the (n - 1) edges in the spanning tree a string of (n - 2) symbols represents, it enqueues and later dequeues each of the n vertices exactly once. Thus the priority queue never holds more than n items, the time for each enqueue and dequeue operation is O( log n), and the time of the entire algorithm is O(n log n). Indeed, the initial priority queue can be built in time that is O(n) [Wood, 1993, pp ], but this does not change the time of the loop. The Appendix gives C++ code for the algorithm. This algorithm can be used to generate random spanning trees efficiently. It is difficult to generate random spanning trees directly, but easy to generate random Prüfer strings. The decoding algorithm then makes explicit the edges in the corresponding spanning trees. 4. Efficiently encoding Prüfer strings The algorithm that writes a Prüfer string from a list of spanning tree edges also accumulates the degrees of the vertices and decrements them as the algorithm proceeds. It repeatedly identifies the vertex with the smallest label among those with degree 1, then appends to the string the other vertex of its edge and removes the edge from consideration. If simple linear searches identify each vertex and edge, the algorithm's time is O(n 2 ). To accelerate the algorithm, we again use a priority queue. This time, its elements are the remaining edges with one vertex of current degree 1. That vertex determines its edge's priority; smaller labels have higher priority. Now the algorithm can quickly identify the next edge to process and the next Prüfer symbol. However, after the algorithm dequeues an edge and identifies the next symbol for the Prüfer string, it decrements the degree of that symbol's vertex. When the vertex's degree falls to 1, the algorithm must enqueue the one remaining edge to which it belongs, but who is at its other end? Searching the list of edges takes too long; the algorithm must

7 keep track of the vertices with which each vertex shares an unprocessed edge, and it must update that information in logarithmic time. Thus we extend the algorithm with another data structure, an array of adjacency lists. For each vertex, there is a list of the vertices with which it shares edges, and the lists are implemented with trees. Initially, these lists represent the entire spanning tree. After the algorithm processes each edge, it removes from the array of lists the two entries that represent the edge. When a vertex's degree falls to 1, the one vertex remaining in its list (tree) is at the other end of its one remaining edge; it can be retrieved in constant time. The following sketch summarizes the resulting algorithm. initialize the vertices' degrees; build the adjacency lists; enqueue the edges one of whose vertices has degree 1; for i from 1 to n-2 loop dequeue the highest-priority edge (u,v); // u has degree 1. the i th Prüfer symbol is v; decrement the degrees of u and v; remove the vertices from each other's trees; if the degree of v is 1 then enqueue the edge formed of v and the one vertex remaining in its tree; end loop; No tree that implements an adjacency list can contain more than (n - 1) vertices. If the trees are binary search trees, the average-case times for insertions and deletions on them are O( log (n-1)); that is, O( log n) [Knuth, 1973, pp ; Aho, Hopcroft, and Ullman, 1983, pp ; Manber, 1989, pp.73-74]. In the worst case, all a tree's interior nodes have just one child, so that the tree is in fact a simple linked list and operations on it require linear time. Though such degenerate trees are rare [Knuth, 1973, p.427], we can ensure that operations' times are logarithmic by implementing the adjacency lists with trees whose shape properties are guaranteed. These include AVL trees [Adelson-Velskii and Landis, 1962; Knuth, 1973, pp ; Horowitz and Sahni, 1977, pp ], 2-3 trees [Horowitz and Sahni, 1977, pp ; Aho, Hopcroft, and Ullman, 1983, pp ; Wood, 1993, pp ], trees [Sedgewick, 1998, pp ], and red-black trees [Guibas and Sedgewick, 1978; Wood, 1993, pp ; Sedgewick, 1998, pp ]. Thus the algorithm uses three data structures: an array of the vertices' degrees, a priority queue of edges with one vertex of degree 1, and a set of adjacency lists. Figure 4 shows the structures just before the algorithm enters its main loop as it builds the Prüfer string corresponding to the spanning tree edges (a,b), (b,e), (d,b), (e,c), (b,g), and (g,f). The priority queue is implemented with a heap, and the adjacency lists are implemented with binary trees.

8 Figure 4: The three data structures in the extended algorithm that builds the Prüfer string from a list of spanning tree edges. The algorithm is about to enter its loop for the first time as it writes the Prüfer string corresponding to the edges (a,b), (b,e), (d,b), (e,c), (b,g), and (g,f). In the priority queue of edges, the first vertex listed in each edge has degree 1. The priority queue is implemented with a heap, and the adjacency lists are implemented with binary search trees. Does this proliferation of data structures result in a faster algorithm? Scanning the list of edges to build the array of degrees is O(n), since there are (n - 1) edges. Building the adjacency lists requires inserting 2(n - 1) vertices into them; each insertion is O( log n), so this step's time is O(n log n), and initializing the priority queue can be O(n), as observed above. The algorithm's main loop is executed (n - 2) times. Within it, an edge is dequeued, two vertices are removed from adjacency lists, and an edge may be enqueued. Each of these operations is O( log n), so the time of the loop and of the entire algorithm is reduced to O(n log n). Again, the Appendix contains C++ code for this version of the algorithm. 5. Conclusion Prüfer's proof of Cayley's Formula establishes a one-to-one correspondence between the spanning trees on n vertices and the strings of length (n - 2) over an alphabet of n ordered symbols associated with the vertices. It describes algorithms that identify the string corresponding to a given tree and the tree corresponding to a given string. Naive versions of these algorithms have times that are O(n 2 ), where n is the number of vertices the spanning tree connects. By elaborating the data structures the algorithms use, we have constructed versions whose times are O(n log n). Both algorithms depend on priority queues implemented with heaps, where removal of the highest-priority item and insertion of an arbitrary item can be carried out in time that is O( log n). The algorithm that builds a Prüfer string from a list of spanning tree edges also uses adjacency lists implemented with trees. Because these data structures typically appear in CS2, the algorithms make interesting examples in that course. More generally,

9 the algorithms illustrate the usefulness of priority queues in algorithms with greedy steps, like identifying the smallest-labeled vertex of degree 1. These algorithms' times do depend on the representation of the spanning tree. If it is maintained as an adjacency matrix, that matrix must be scanned in each algorithm, rendering the times for both O(n 2 ), regardless of efficiencies elsewhere. Appendix: Code This appendix presents C++ functions that implement the two algorithms developed above. In them, the integers from 0 to (n-1) label vertices, and a Prüfer string is an array of such integers. All arrays are indexed from zero. An edge is represented by a record containing two vertices' integers, and an array of these records holds a list of spanning tree edges. The following declarations apply: struct edge int v1; int v2; }; typedef edge edge_list[n-1]; typedef int prufer_string[n-2]; The following function identifies the edges in the spanning tree that a Prüfer string represents. In it, pqueue is a priority queue of integers. void p2list ( prufer_string p, edge_list edges ) pqueue q; // Priority queue of vertices of current degree 1 int degree[n]; // Array of vertices' current degrees int v; // A vertex // Find the initial degrees of the vertices: for (v=0; v < n; ++v) degree[v] = 1; for (int i=0; i<n-2; ++i) degree[p[i]] += 1; // Initialize the priority queue of vertices of degree 1: for (v=0; v < n; ++v) if ( degree[v] == 1 ) q.enqueue(v); // Identify the spanning tree edges: for (int i=0; i<n-2; ++i) q.dequeue(v); // The vertex of degree 1 with lowest number edges[i].v1 = v; edges[i].v2 = p[i];

10 } degree[v] = 0; degree[p[i]] -= 1; if ( degree[p[i]] == 1 ) q.enqueue(p[i]); } // Identify the last edge: q.dequeue(v); edges[n-2].v1 = v; q.dequeue(v); edges[n-2].v2 = v; The following function builds the Prüfer string that corresponds to a spanning tree. In it, edge_pq is a priority queue of edges, as Section 4 described, and bst is a binary search tree class, instantiated here with integers as elements, representing vertices. Then t[] is a collection of adjacency lists: an array of n of these trees. The bst function top() returns the value in the invoking tree's root node. void list2p ( edge_list edges, prufer_string p ) edge_pq q; // Priority queue of candidate edges bst<int> t[max]; // Array of BSTs of integers int degree[max]; // Array of vertices' degrees edge e; // An edge int u, v; // The dequeued edge's vertices // Initialize the array of degrees and the adjacency lists. for (int i=0; i<n; ++i) degree[i] = 0; for (int i=0; i<n-1; ++i) degree[edges[i].v1] += 1; // Find degrees of all vertices. degree[edges[i].v2] += 1; t[edges[i].v1].insert(edges[i].v2); // Vertices into BSTs. t[edges[i].v2].insert(edges[i].v1); } // Build heap of all edges that contain a vertex of degree 1. for (int i=0; i<n-1; ++i) if ( degree[edges[i].v1] == 1 ) q.enqueue(edges[i]); else if ( degree[edges[i].v2] == 1 ) swap(edges[i].v1, edges[i].v2); // Exchange the vertices q.enqueue(edges[i]); } // Build the Prüfer string. for (int i=0; i<n-2; ++i) q.dequeue(e); // Dequeue the front edge.

11 } } u = e.v1; v = e.v2; p[i] = v; degree[u] -= 1; degree[v] -= 1; t[u].remove(v); t[v].remove(u); if ( degree[v] == 1 ) e.v1 = v; e.v2 = t[v].top(); q.enqueue(e); } // "Inner" vertex joins p[]. // Decrement both degrees. // Remove v from u's BST. // Remove u from v's BST. // Enqueue any new candidate edge. // The last vertex in v s tree

12 References Abuali, F.N., Schoenefeld, D.A., & Wainwright, R.L. (1994). Designing telecommunications networks using genetic algorithms and probabilistic minimum spanning trees. In E. Deaton, D. Oppenheim, J. Urban, & H. Berghel (Eds.), Proceedings of the 1994 ACM Symposium on Applied Computing. New York: ACM Press, pp Adelson-Velskii, G.M., & Landis, E.M. (1962). An algorithm for the organization of information. Soviet Mathematics, 3, Aho, A.V., Hopcroft, J.E., & Ullman, J.D. (1983). Data Structures and Algorithms. Reading, MA: Addison-Wesley. Cayley, A. (1889). A theorem on trees. Quarterly Journal of Mathematics, 23, Even, S. (1973). Algorithmic Combinatorics. New York: The Macmillan Company. Gargano, M.L., Edelson, W., & Koval, O. (1998). A genetic algorithm with feasible search space for minimal spanning trees with time-dependent edge costs. In J. Koza, W. Banzhaf, K. Chellapilla, K. Deb, M. Dorigo, D.B. Fogel, M.H. Garzon, D.E. Goldberg, H. Iba, & R.L. Riolo (Eds.), Genetic Programming 1998: Proceedings of the Third Annual Conference. San Francisco, CA: Morgan Kaufmann, p.495. Guibas, L., & Sedgewick, R. (1978). A dichromatic framework for balanced trees. In Proceedings of the 19th IEEE Symposium on the Foundations of Computer Science, pp Horowitz, E., & Sahni, S. (1977). Fundamentals of Data Structures. Potomac, MD: Computer Science Press. Julstrom, B.A. (1993). A genetic algorithm for the rectilinear Steiner problem. In Stephanie Forrest (Ed.), Proceedings of the Fifth International Conference on Genetic Algorithms. San Mateo, CA: Morgan Kaufmann, pp Kim, J.R., & Gen, M. (1999). Genetic algorithm for solving bicriteria network topology design problem. In Proceedings of the 1999 IEEE Congress on Evolutionary Computation: Vol. 3. New York: IEEE Press, pp Knuth, D.E. (1973). The Art of Computer Programming. Volume 3: Sorting and Searching. Reading, MA: Addison-Wesley. Manber, U. (1989). Introduction to Algorithms: A Creative Approach. Reading, MA: Addison-Wesley.

13 Prüfer, H. (1918). Neuer beweis eines satzes ueber permutationen. Arch. Math. Phys., 27, Sedgewick R. (1998). Algorithms in C++ (3rd ed.). Reading, MA: Addison-Wesley. Williams, J.W.J. (1964). Algorithm 232: Heapsort. Communications of the ACM, 7(6), Wood, D. (1993). Data Structures, Algorithms, and Performance. Reading, MA: Addison-Wesley. Zhou, G., & Gen, M. (1997). Approach to degree-constrained spanning tree problem using genetic algorithm. Engineering Design and Automation, 3(2),

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

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chapter 9 Greedy Technique Copyright 2007 Pearson Addison-Wesley. All rights reserved. Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that

More information

A note on Prüfer-like coding and counting forests of uniform hypertrees

A note on Prüfer-like coding and counting forests of uniform hypertrees A note on Prüfer-like coding and counting forests of uniform hypertrees Christian Lavault Abstract The present note is designing encoding and decoding algorithms for a forest of rooted uniform hypertrees

More information

An Efficient Evolutionary Algorithm for the Degree-Constrained Minimum Spanning Tree Problem

An Efficient Evolutionary Algorithm for the Degree-Constrained Minimum Spanning Tree Problem An Efficient Evolutionary Algorithm for the Degree-Constrained Minimum Spanning Tree Problem Günther R. Raidl Institute of Computer Graphics Vienna University of Technology Favoritenstraße 9 /11, 40 Vienna,

More information

arxiv: v3 [cs.ds] 18 Apr 2011

arxiv: v3 [cs.ds] 18 Apr 2011 A tight bound on the worst-case number of comparisons for Floyd s heap construction algorithm Ioannis K. Paparrizos School of Computer and Communication Sciences Ècole Polytechnique Fèdèrale de Lausanne

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Prerequisites A seven credit unit course Replaced OHJ-2156 Analysis of Algorithms We take things a bit further than

More information

Data Structures and Algorithms Lecture 7 DCI FEEI TUKE. Balanced Trees

Data Structures and Algorithms Lecture 7 DCI FEEI TUKE. Balanced Trees Balanced Trees AVL trees reconstruction of perfect balance can be quite expensive operation less rigid criteria of balance (e.g. AVL) [2] inorder, self-balancing binary search tree (BST) Definition: AVL

More information

Lecture 25 Spanning Trees

Lecture 25 Spanning Trees Lecture 25 Spanning Trees 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, Iliano Cervesato The following is a simple example of a connected, undirected graph with 5 vertices (A,

More information

A Web-Based Evolutionary Algorithm Demonstration using the Traveling Salesman Problem

A Web-Based Evolutionary Algorithm Demonstration using the Traveling Salesman Problem A Web-Based Evolutionary Algorithm Demonstration using the Traveling Salesman Problem Richard E. Mowe Department of Statistics St. Cloud State University mowe@stcloudstate.edu Bryant A. Julstrom Department

More information

Analysis of Time complexity in Binary Search Tree

Analysis of Time complexity in Binary Search Tree Computing For Nation Development, February 2 26, 2010 Bharati Vidyapeeth s Institute of Computer Applications and Management, New Delhi Analysis of Time complexity in Binary Search Tree Pawan Jindal 1,

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

More information

ADAPTIVE SORTING WITH AVL TREES

ADAPTIVE SORTING WITH AVL TREES ADAPTIVE SORTING WITH AVL TREES Amr Elmasry Computer Science Department Alexandria University Alexandria, Egypt elmasry@alexeng.edu.eg Abstract A new adaptive sorting algorithm is introduced. The new implementation

More information

A Distribution-Sensitive Dictionary with Low Space Overhead

A Distribution-Sensitive Dictionary with Low Space Overhead A Distribution-Sensitive Dictionary with Low Space Overhead Prosenjit Bose, John Howat, and Pat Morin School of Computer Science, Carleton University 1125 Colonel By Dr., Ottawa, Ontario, CANADA, K1S 5B6

More information

CPS 616 TRANSFORM-AND-CONQUER 7-1

CPS 616 TRANSFORM-AND-CONQUER 7-1 CPS 616 TRANSFORM-AND-CONQUER 7-1 TRANSFORM AND CONQUER Group of techniques to solve a problem by first transforming the problem into one of: 1. a simpler/more convenient instance of the same problem (instance

More information

MINIMAL EDGE-ORDERED SPANNING TREES USING A SELF-ADAPTING GENETIC ALGORITHM WITH MULTIPLE GENOMIC REPRESENTATIONS

MINIMAL EDGE-ORDERED SPANNING TREES USING A SELF-ADAPTING GENETIC ALGORITHM WITH MULTIPLE GENOMIC REPRESENTATIONS Proceedings of Student/Faculty Research Day, CSIS, Pace University, May 5 th, 2006 MINIMAL EDGE-ORDERED SPANNING TREES USING A SELF-ADAPTING GENETIC ALGORITHM WITH MULTIPLE GENOMIC REPRESENTATIONS Richard

More information

6.7 b. Show that a heap of eight elements can be constructed in eight comparisons between heap elements. Tournament of pairwise comparisons

6.7 b. Show that a heap of eight elements can be constructed in eight comparisons between heap elements. Tournament of pairwise comparisons Homework 4 and 5 6.7 b. Show that a heap of eight elements can be constructed in eight comparisons between heap elements. Tournament of pairwise comparisons 6.8 Show the following regarding the maximum

More information

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

Lecture Notes on Priority Queues

Lecture Notes on Priority Queues Lecture Notes on Priority Queues 15-122: Principles of Imperative Computation Frank Pfenning Lecture 16 October 18, 2012 1 Introduction In this lecture we will look at priority queues as an abstract type

More information

Lecture 7. Transform-and-Conquer

Lecture 7. Transform-and-Conquer Lecture 7 Transform-and-Conquer 6-1 Transform and Conquer This group of techniques solves a problem by a transformation to a simpler/more convenient instance of the same problem (instance simplification)

More information

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if

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

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the Heap-on-Top Priority Queues Boris V. Cherkassky Central Economics and Mathematics Institute Krasikova St. 32 117418, Moscow, Russia cher@cemi.msk.su Andrew V. Goldberg NEC Research Institute 4 Independence

More information

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm Spanning Trees 1 Spanning Trees the minimum spanning tree problem three greedy algorithms analysis of the algorithms 2 The Union-Find Data Structure managing an evolving set of connected components implementing

More information

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207. MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/ Graphs and Trees http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/l2-graphsandtrees.pdf

More information

Bottleneck Steiner Tree with Bounded Number of Steiner Vertices

Bottleneck Steiner Tree with Bounded Number of Steiner Vertices Bottleneck Steiner Tree with Bounded Number of Steiner Vertices A. Karim Abu-Affash Paz Carmi Matthew J. Katz June 18, 2011 Abstract Given a complete graph G = (V, E), where each vertex is labeled either

More information

Mathematics Masters Examination

Mathematics Masters Examination Mathematics Masters Examination OPTION 4 March 30, 2004 COMPUTER SCIENCE 2 5 PM NOTE: Any student whose answers require clarification may be required to submit to an oral examination. Each of the fourteen

More information

CS 261 Data Structures. AVL Trees

CS 261 Data Structures. AVL Trees CS 261 Data Structures AVL Trees 1 Binary Search Tree Complexity of BST operations: proportional to the length of the path from a node to the root Unbalanced tree: operations may be O(n) E.g.: adding elements

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

Graphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V)

Graphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V) Graph Algorithms Graphs Graph G = (V, E) V = set of vertices E = set of edges (V V) Types of graphs Undirected: edge (u, v) = (v, u); for all v, (v, v) E (No self loops.) Directed: (u, v) is edge from

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Dr. Malek Mouhoub Department of Computer Science University of Regina Fall 2002 Malek Mouhoub, CS3620 Fall 2002 1 6. Priority Queues 6. Priority Queues ffl ADT Stack : LIFO.

More information

Week 11: Minimum Spanning trees

Week 11: Minimum Spanning trees Week 11: Minimum Spanning trees Agenda: Minimum Spanning Trees Prim s Algorithm Reading: Textbook : 61-7 1 Week 11: Minimum Spanning trees Minimum spanning tree (MST) problem: Input: edge-weighted (simple,

More information

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs Representations of Weighted Graphs (as Matrices) A B Algorithms and Data Structures: Minimum Spanning Trees 9.0 F 1.0 6.0 5.0 6.0 G 5.0 I H 3.0 1.0 C 5.0 E 1.0 D 28th Oct, 1st & 4th Nov, 2011 ADS: lects

More information

Solutions. Suppose we insert all elements of U into the table, and let n(b) be the number of elements of U that hash to bucket b. Then.

Solutions. Suppose we insert all elements of U into the table, and let n(b) be the number of elements of U that hash to bucket b. Then. Assignment 3 1. Exercise [11.2-3 on p. 229] Modify hashing by chaining (i.e., bucketvector with BucketType = List) so that BucketType = OrderedList. How is the runtime of search, insert, and remove affected?

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a

More information

Abstract Relaxed balancing of search trees was introduced with the aim of speeding up the updates and allowing a high degree of concurrency. In a rela

Abstract Relaxed balancing of search trees was introduced with the aim of speeding up the updates and allowing a high degree of concurrency. In a rela Chromatic Search Trees Revisited Institut fur Informatik Report 9 Sabine Hanke Institut fur Informatik, Universitat Freiburg Am Flughafen 7, 79 Freiburg, Germany Email: hanke@informatik.uni-freiburg.de.

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

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of California, San Diego CA 92093{0114, USA Abstract. We

More information

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn) CSE 0 Name Test Fall 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to find the maximum of the n elements of an integer array is in: A.

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

Discrete mathematics , Fall Instructor: prof. János Pach

Discrete mathematics , Fall Instructor: prof. János Pach Discrete mathematics 2016-2017, Fall Instructor: prof. János Pach - covered material - Lecture 1. Counting problems To read: [Lov]: 1.2. Sets, 1.3. Number of subsets, 1.5. Sequences, 1.6. Permutations,

More information

HEAPS ON HEAPS* Downloaded 02/04/13 to Redistribution subject to SIAM license or copyright; see

HEAPS ON HEAPS* Downloaded 02/04/13 to Redistribution subject to SIAM license or copyright; see SIAM J. COMPUT. Vol. 15, No. 4, November 1986 (C) 1986 Society for Industrial and Applied Mathematics OO6 HEAPS ON HEAPS* GASTON H. GONNET" AND J. IAN MUNRO," Abstract. As part of a study of the general

More information

3. Priority Queues. ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority.

3. Priority Queues. ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority. 3. Priority Queues 3. Priority Queues ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority. Malek Mouhoub, CS340 Winter 2007 1 3. Priority Queues

More information

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret Greedy Algorithms (continued) The best known application where the greedy algorithm is optimal is surely

More information

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

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap DATA STRUCTURES AND ALGORITHMS Hierarchical data structures: AVL tree, Bayer tree, Heap Summary of the previous lecture TREE is hierarchical (non linear) data structure Binary trees Definitions Full tree,

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

9. Heap : Priority Queue

9. Heap : Priority Queue 9. Heap : Priority Queue Where We Are? Array Linked list Stack Queue Tree Binary Tree Heap Binary Search Tree Priority Queue Queue Queue operation is based on the order of arrivals of elements FIFO(First-In

More information

Data Structures Lesson 9

Data Structures Lesson 9 Data Structures Lesson 9 BSc in Computer Science University of New York, Tirana Assoc. Prof. Marenglen Biba 1-1 Chapter 21 A Priority Queue: The Binary Heap Priority Queue The priority queue is a fundamental

More information

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

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Final Examination (17 pages) Instructor: Douglas Harder April 14, 2004 9:00-12:00 Name (last,

More information

Smart Sort and its Analysis

Smart Sort and its Analysis Smart Sort and its Analysis Varun Jain and Suneeta Agarwal Department of Computer Science and Engineering, Motilal Nehru National Institute of Technology, Allahabad-211004, Uttar Pradesh, India. varun_jain22@yahoo.com,

More information

Minimum Spanning Trees My T. UF

Minimum Spanning Trees My T. UF Introduction to Algorithms Minimum Spanning Trees @ UF Problem Find a low cost network connecting a set of locations Any pair of locations are connected There is no cycle Some applications: Communication

More information

VISUALIZING NP-COMPLETENESS THROUGH CIRCUIT-BASED WIDGETS

VISUALIZING NP-COMPLETENESS THROUGH CIRCUIT-BASED WIDGETS University of Portland Pilot Scholars Engineering Faculty Publications and Presentations Shiley School of Engineering 2016 VISUALIZING NP-COMPLETENESS THROUGH CIRCUIT-BASED WIDGETS Steven R. Vegdahl University

More information

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conquer Algorithm Design Technique Decrease-and-Conquer This algorithm design technique is based on exploiting a relationship between

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

Priority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof.

Priority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof. Priority Queues 1 Introduction Many applications require a special type of queuing in which items are pushed onto the queue by order of arrival, but removed from the queue based on some other priority

More information

Priority Queues Heaps Heapsort

Priority Queues Heaps Heapsort Priority Queues Heaps Heapsort After this lesson, you should be able to apply the binary heap insertion and deletion algorithms by hand implement the binary heap insertion and deletion algorithms explain

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

COMP171. AVL-Trees (Part 1)

COMP171. AVL-Trees (Part 1) COMP11 AVL-Trees (Part 1) AVL Trees / Slide 2 Data, a set of elements Data structure, a structured set of elements, linear, tree, graph, Linear: a sequence of elements, array, linked lists Tree: nested

More information

Name: After line 1: After line 3: After line 5: After line 8: After line 11:

Name: After line 1: After line 3: After line 5: After line 8: After line 11: 1. (5 points) Determine the stack contents at the points indicated below during the following operations on the stack ADT. Write down the stack contents after the operation on the given line is executed.

More information

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

CSE100. Advanced Data Structures. Lecture 12. (Based on Paul Kube course materials) CSE100 Advanced Data Structures Lecture 12 (Based on Paul Kube course materials) CSE 100 Coding and decoding with a Huffman coding tree Huffman coding tree implementation issues Priority queues and priority

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms About the course (objectives, outline, recommended reading) Problem solving Notions of Algorithmics (growth of functions, efficiency, programming model, example analysis)

More information

Announcements. Midterm exam 2, Thursday, May 18. Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps. Break around 11:45am

Announcements. Midterm exam 2, Thursday, May 18. Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps. Break around 11:45am Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 018 D/Q Greed SP s DP LP, Flow B&B, Backtrack Metaheuristics P, NP Design and Analysis of Algorithms Lecture 8: Greed Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Optimization

More information

CS 310: Priority Queues and Binary Heaps

CS 310: Priority Queues and Binary Heaps CS 310: Priority Queues and Binary Heaps Chris Kauffman Week 14-2 Priority Queues Queue What operations does a queue support? Priority: Number representing importance Convention lower is better priority

More information

The Matrix-Tree Theorem and Its Applications to Complete and Complete Bipartite Graphs

The Matrix-Tree Theorem and Its Applications to Complete and Complete Bipartite Graphs The Matrix-Tree Theorem and Its Applications to Complete and Complete Bipartite Graphs Frankie Smith Nebraska Wesleyan University fsmith@nebrwesleyan.edu May 11, 2015 Abstract We will look at how to represent

More information

Data Structure. IBPS SO (IT- Officer) Exam 2017

Data Structure. IBPS SO (IT- Officer) Exam 2017 Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data

More information

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs Graphs and Network Flows ISE 411 Lecture 7 Dr. Ted Ralphs ISE 411 Lecture 7 1 References for Today s Lecture Required reading Chapter 20 References AMO Chapter 13 CLRS Chapter 23 ISE 411 Lecture 7 2 Minimum

More information

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices. Trees Trees form the most widely used subclasses of graphs. In CS, we make extensive use of trees. Trees are useful in organizing and relating data in databases, file systems and other applications. Formal

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 3 Data Structures Graphs Traversals Strongly connected components Sofya Raskhodnikova L3.1 Measuring Running Time Focus on scalability: parameterize the running time

More information

CS350: Data Structures Heaps and Priority Queues

CS350: Data Structures Heaps and Priority Queues Heaps and Priority Queues James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Priority Queue An abstract data type of a queue that associates a priority

More information

arxiv: v3 [cs.ds] 3 Apr 2018

arxiv: v3 [cs.ds] 3 Apr 2018 arxiv:1711.07746v3 [cs.ds] 3 Apr 2018 The Hidden Binary Search Tree: A Balanced Rotation-Free Search Tree in the AVL RAM Model Saulo Queiroz Email: sauloqueiroz@utfpr.edu.br Academic Department of Informatics

More information

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, ) Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 1. if >. 2. error new key is greater than current key 3.. 4.. 5. if NIL and.

More information

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Floyd-Warshall algorithm in O(n 3 ) time. Neither of

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.5 Minimum Spanning Tree Minimum Spanning Tree Minimum spanning tree. Given a connected

More information

COT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748

COT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748 COT 5407: Introduction to Algorithms Giri Narasimhan ECS 254A; Phone: x3748 giri@cis.fiu.edu http://www.cis.fiu.edu/~giri/teach/5407s17.html https://moodle.cis.fiu.edu/v3.1/course/view.php?id=1494 8/28/07

More information

Analysis of Algorithms

Analysis of Algorithms Algorithm An algorithm is a procedure or formula for solving a problem, based on conducting a sequence of specified actions. A computer program can be viewed as an elaborate algorithm. In mathematics and

More information

Hierarchical data structures. Announcements. Motivation for trees. Tree overview

Hierarchical data structures. Announcements. Motivation for trees. Tree overview Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

REDUCING GRAPH COLORING TO CLIQUE SEARCH

REDUCING GRAPH COLORING TO CLIQUE SEARCH Asia Pacific Journal of Mathematics, Vol. 3, No. 1 (2016), 64-85 ISSN 2357-2205 REDUCING GRAPH COLORING TO CLIQUE SEARCH SÁNDOR SZABÓ AND BOGDÁN ZAVÁLNIJ Institute of Mathematics and Informatics, University

More information

ISA[k] Trees: a Class of Binary Search Trees with Minimal or Near Minimal Internal Path Length

ISA[k] Trees: a Class of Binary Search Trees with Minimal or Near Minimal Internal Path Length SOFTWARE PRACTICE AND EXPERIENCE, VOL. 23(11), 1267 1283 (NOVEMBER 1993) ISA[k] Trees: a Class of Binary Search Trees with Minimal or Near Minimal Internal Path Length faris n. abuali and roger l. wainwright

More information

Algorithm Analysis and Design

Algorithm Analysis and Design Algorithm Analysis and Design Dr. Truong Tuan Anh Faculty of Computer Science and Engineering Ho Chi Minh City University of Technology VNU- Ho Chi Minh City 1 References [1] Cormen, T. H., Leiserson,

More information

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305 Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n

More information

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem Minimum Spanning Trees (Forests) Given an undirected graph G=(V,E) with each edge e having a weight w(e) : Find a subgraph T of G of minimum total weight s.t. every pair of vertices connected in G are

More information

CSC Design and Analysis of Algorithms. Lecture 8. Transform and Conquer II Algorithm Design Technique. Transform and Conquer

CSC Design and Analysis of Algorithms. Lecture 8. Transform and Conquer II Algorithm Design Technique. Transform and Conquer CSC 301- Design and Analysis of Algorithms Lecture Transform and Conquer II Algorithm Design Technique Transform and Conquer This group of techniques solves a problem by a transformation to a simpler/more

More information

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees CSE1 Introduction to Algorithms Lecture 1 Minimum Spanning Trees Antoine Vigneron antoine@unist.ac.kr Ulsan National Institute of Science and Technology July 11, 201 Antoine Vigneron (UNIST) CSE1 Lecture

More information

CE 221 Data Structures and Algorithms

CE 221 Data Structures and Algorithms CE 2 Data Structures and Algorithms Chapter 6: Priority Queues (Binary Heaps) Text: Read Weiss, 6.1 6.3 Izmir University of Economics 1 A kind of queue Priority Queue (Heap) Dequeue gets element with the

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

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms, Lecture 1 /1/200 Introduction to Algorithms.04J/1.401J LECTURE 11 Graphs, MST, Greedy, Prim Graph representation Minimum spanning trees Greedy algorithms hallmarks. Greedy choice

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

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

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

More information

Applied Mathematics Letters. Graph triangulations and the compatibility of unrooted phylogenetic trees

Applied Mathematics Letters. Graph triangulations and the compatibility of unrooted phylogenetic trees Applied Mathematics Letters 24 (2011) 719 723 Contents lists available at ScienceDirect Applied Mathematics Letters journal homepage: www.elsevier.com/locate/aml Graph triangulations and the compatibility

More information

CS 372: Computational Geometry Lecture 3 Line Segment Intersection

CS 372: Computational Geometry Lecture 3 Line Segment Intersection CS 372: Computational Geometry Lecture 3 Line Segment Intersection Antoine Vigneron King Abdullah University of Science and Technology September 9, 2012 Antoine Vigneron (KAUST) CS 372 Lecture 3 September

More information

CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science

CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science Entrance Examination, 5 May 23 This question paper has 4 printed sides. Part A has questions of 3 marks each. Part B has 7 questions

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

Evolution Module. 6.1 Phylogenetic Trees. Bob Gardner and Lev Yampolski. Integrated Biology and Discrete Math (IBMS 1300)

Evolution Module. 6.1 Phylogenetic Trees. Bob Gardner and Lev Yampolski. Integrated Biology and Discrete Math (IBMS 1300) Evolution Module 6.1 Phylogenetic Trees Bob Gardner and Lev Yampolski Integrated Biology and Discrete Math (IBMS 1300) Fall 2008 1 INDUCTION Note. The natural numbers N is the familiar set N = {1, 2, 3,...}.

More information

Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course

Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course Irena Pevac Department of Computer Science Central Connecticut State University, New Britain, CT, USA Abstract: We propose

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

Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT

Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT In this paper we investigate the inherent complexity of the priority queue abstract data type. We show that, under reasonable

More information

COMP Data Structures

COMP Data Structures COMP 2140 - Data Structures Shahin Kamali Topic 5 - Sorting University of Manitoba Based on notes by S. Durocher. COMP 2140 - Data Structures 1 / 55 Overview Review: Insertion Sort Merge Sort Quicksort

More information

Chapter 9. Priority Queue

Chapter 9. Priority Queue Chapter 9 Priority Queues, Heaps, Graphs Spring 2015 1 Priority Queue Priority Queue An ADT in which only the item with the highest priority can be accessed 2Spring 2015 Priority Depends on the Application

More information

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND CSE 373 MAY 0 TH SPANNING TREES AND UNION FIND COURSE LOGISTICS HW4 due tonight, if you want feedback by the weekend COURSE LOGISTICS HW4 due tonight, if you want feedback by the weekend HW5 out tomorrow

More information

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14 CS200: Graphs Rosen Ch. 9.1-9.4, 9.6, 10.4-10.5 Walls and Mirrors Ch. 14 Trees as Graphs Tree: an undirected connected graph that has no cycles. A B C D E F G H I J K L M N O P Rooted Trees A rooted tree

More information