# 4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

Save this PDF as:

Size: px
Start display at page:

Download "4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting..."

## Transcription

1 Contents 1 Introduction What is Competitive Programming? Programming Contests Tips for Practicing About This Book CSES Problem Set Other Resources Programming Techniques Language Features Input and Output Working with Numbers Shortening Code Recursive Algorithms Generating Subsets Generating Permutations Backtracking Bit Manipulation Bit Operations Representing Sets Efficiency Time Complexity Calculation Rules Common Time Complexities Estimating Efficiency Formal Definitions Examples Maximum Subarray Sum Two Queens Problem Sorting and Searching Sorting Algorithms Bubble Sort vii

2 viii Contents Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting Sweep Line Algorithms Scheduling Events Tasks and Deadlines Binary Search Implementing the Search Finding Optimal Solutions Data Structures Dynamic Arrays Vectors Iterators and Ranges Other Structures Set Structures Sets and Multisets Maps Priority Queues Policy-Based Sets Experiments Set Versus Sorting Map Versus Array Priority Queue Versus Multiset Dynamic Programming Basic Concepts When Greedy Fails Finding an Optimal Solution Counting Solutions Further Examples Longest Increasing Subsequence Paths in a Grid Knapsack Problems From Permutations to Subsets Counting Tilings Graph Algorithms Basics of Graphs Graph Terminology Graph Representation Graph Traversal Depth-First Search

3 Contents ix Breadth-First Search Applications Shortest Paths Bellman Ford Algorithm Dijkstra s Algorithm Floyd Warshall Algorithm Directed Acyclic Graphs Topological Sorting Dynamic Programming Successor Graphs Finding Successors Cycle Detection Minimum Spanning Trees Kruskal s Algorithm Union-Find Structure Prim s Algorithm Algorithm Design Topics Bit-Parallel Algorithms Hamming Distances Counting Subgrids Reachability in Graphs Amortized Analysis Two Pointers Method Nearest Smaller Elements Sliding Window Minimum Finding Minimum Values Ternary Search Convex Functions Minimizing Sums Range Queries Queries on Static Arrays Sum Queries Minimum Queries Tree Structures Binary Indexed Trees Segment Trees Additional Techniques Tree Algorithms Basic Techniques Tree Traversal Calculating Diameters All Longest Paths

4 x Contents 10.2 Tree Queries Finding Ancestors Subtrees and Paths Lowest Common Ancestors Merging Data Structures Advanced Techniques Centroid Decomposition Heavy-Light Decomposition Mathematics Number Theory Primes and Factors Sieve of Eratosthenes Euclid s Algorithm Modular Exponentiation Euler s Theorem Solving Equations Combinatorics Binomial Coefficients Catalan Numbers Inclusion-Exclusion Burnside s Lemma Cayley s Formula Matrices Matrix Operations Linear Recurrences Graphs and Matrices Gaussian Elimination Probability Working with Events Random Variables Markov Chains Randomized Algorithms Game Theory Game States Nim Game Sprague Grundy Theorem Advanced Graph Algorithms Strong Connectivity Kosaraju s Algorithm SAT Problem Complete Paths Eulerian Paths

5 Contents xi Hamiltonian Paths Applications Maximum Flows Ford Fulkerson Algorithm Disjoint Paths Maximum Matchings Path Covers Depth-First Search Trees Biconnectivity Eulerian Subgraphs Geometry Geometric Techniques Complex Numbers Points and Lines Polygon Area Distance Functions Sweep Line Algorithms Intersection Points Closest Pair Problem Convex Hull Problem String Algorithms Basic Topics Trie Structure Dynamic Programming String Hashing Polynomial Hashing Applications Collisions and Parameters Z-Algorithm Constructing the Z-Array Applications Suffix Arrays Prefix Doubling Method Finding Patterns LCP Arrays Additional Topics Square Root Techniques Data Structures Subalgorithms Integer Partitions Mo s Algorithm

6 xii Contents 15.2 Segment Trees Revisited Lazy Propagation Dynamic Trees Data Structures in Nodes Two-Dimensional Trees Treaps Splitting and Merging Implementation Additional Techniques Dynamic Programming Optimization Convex Hull Trick Divide and Conquer Optimization Knuth s Optimization Miscellaneous Meet in the Middle Counting Subsets Parallel Binary Search Dynamic Connectivity Appendix A: Mathematical Background References Index

7

### Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Introduction to Algorithms Preface xiii 1 Introduction 1 1.1 Algorithms 1 1.2 Analyzing algorithms 6 1.3 Designing algorithms 1 1 1.4 Summary 1 6

### Introduction to Algorithms Third Edition

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Introduction to Algorithms Third Edition The MIT Press Cambridge, Massachusetts London, England Preface xiü I Foundations Introduction

### Introduction to Algorithms

Thomas H. Carmen Charles E. Leiserson Ronald L. Rivest Clifford Stein Introduction to Algorithms Third Edition The MIT Press Cambridge, Massachusetts London, England Contents Preface xiii - I Foundations

### Data Structures and Algorithm Analysis in C++

INTERNATIONAL EDITION Data Structures and Algorithm Analysis in C++ FOURTH EDITION Mark A. Weiss Data Structures and Algorithm Analysis in C++, International Edition Table of Contents Cover Title Contents

### Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

Introduction to TllG DCSISFI & mmmmm Analysis of Algorithms 3RD EDITION Anany Levitin Villa nova University International Edition contributions by Soumen Mukherjee RCC Institute of Information Technology

### CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION 1. What is performance measurement? 2. What is an algorithm? 3. How the algorithm is good? 4. What are the

### CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

CSCE 321/3201 Analysis and Design of Algorithms Prof. Amr Goneid Fall 2016 CSCE 321/3201 Analysis and Design of Algorithms Prof. Amr Goneid Course Resources Instructor: Prof. Amr Goneid E-mail: goneid@aucegypt.edu

### r=1 The Binomial Theorem. 4 MA095/98G Revision

Revision Read through the whole course once Make summary sheets of important definitions and results, you can use the following pages as a start and fill in more yourself Do all assignments again Do the

### ( D. Θ n. ( ) f n ( ) D. Ο%

CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j

### ( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally

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

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

### Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

### Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Course Name: B.Tech. 3 th Sem. Subject: Data Structures No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours Paper Code: ETCS-209 Topic Details No of Hours Planned

### n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in:

### Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

### Chapter 9 Graph Algorithms

Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

### Discuss the following operations on One-Dimensional array with algorithms.

(i). Searching (ii). Sorting (iii). Traversing (16CS503) DATA STRUCTURES THROUGH C UNIT-I Discuss the following operations on One-Dimensional array with algorithms. 2.Discuss the following operations on

### Preface... 1 The Boost C++ Libraries Overview... 5 Math Toolkit: Special Functions Math Toolkit: Orthogonal Functions... 29

Preface... 1 Goals of this Book... 1 Structure of the Book... 1 For whom is this Book?... 1 Using the Boost Libraries... 2 Practical Hints and Guidelines... 2 What s Next?... 2 1 The Boost C++ Libraries

### CLASSIC DATA STRUCTURES IN JAVA

CLASSIC DATA STRUCTURES IN JAVA Timothy Budd Oregon State University Boston San Francisco New York London Toronto Sydney Tokyo Singapore Madrid Mexico City Munich Paris Cape Town Hong Kong Montreal CONTENTS

### Design and Analysis of Algorithms - - Assessment

X Courses» Design and Analysis of Algorithms Week 1 Quiz 1) In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise.

### WITH C+ + William Ford University of the Pacific. William Topp University of the Pacific. Prentice Hall, Englewood Cliffs, New Jersey 07632

DATA STRUCTURES WITH C+ + William Ford University of the Pacific William Topp University of the Pacific Prentice Hall, Englewood Cliffs, New Jersey 07632 CONTENTS Preface xvii CHAPTER 1 INTRODUCTION 1

### Lecture 6 Basic Graph Algorithms

CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 6 Basic Graph Algorithms Uttam Thakore University of Illinois at Urbana-Champaign September 30, 2015 Updates ICPC Regionals teams will be

### UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

UCS-40 (Data Structure) Lab Assignment- (2 weeks) Implement the following programs in C/C++/Python/Java using functions a) Insertion Sort b) Bubble Sort c) Selection Sort d) Linear Search e) Binary Search

### Course Review. Cpt S 223 Fall 2009

Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

### Lecture Summary CSC 263H. August 5, 2016

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

### Contents. Preface xvii Acknowledgments. CHAPTER 1 Introduction to Parallel Computing 1. CHAPTER 2 Parallel Programming Platforms 11

Preface xvii Acknowledgments xix CHAPTER 1 Introduction to Parallel Computing 1 1.1 Motivating Parallelism 2 1.1.1 The Computational Power Argument from Transistors to FLOPS 2 1.1.2 The Memory/Disk Speed

### Question Paper Code : 97044

Reg. No. : Question Paper Code : 97044 B.E./B.Tech. DEGREE EXAMINATION NOVEMBER/DECEMBER 2014 Third Semester Computer Science and Engineering CS 6301 PROGRAMMING AND DATA STRUCTURES-II (Regulation 2013)

### UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.

### Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Topics VCU, Department of Computer Science CMSC 302 Trees Vojislav Kecman Terminology Trees as Models Some Tree Theorems Applications of Trees Binary Search Tree Decision Tree Tree Traversal Spanning Trees

### Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions

U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front

### Solving problems on graph algorithms

Solving problems on graph algorithms Workshop Organized by: ACM Unit, Indian Statistical Institute, Kolkata. Tutorial-3 Date: 06.07.2017 Let G = (V, E) be an undirected graph. For a vertex v V, G {v} is

### 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

### Final Examination CSE 100 UCSD (Practice)

Final Examination UCSD (Practice) RULES: 1. Don t start the exam until the instructor says to. 2. This is a closed-book, closed-notes, no-calculator exam. Don t refer to any materials other than the exam

### CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I PART A(2MARKS) 1. What is an algorithm? 2. What is meant by open hashing? 3. Define Ω-notation 4.Define order of an algorithm. 5. Define O-notation

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

www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the

Chapter 14 Graphs 2011 Pearson Addison-Wesley. All rights reserved 14 A-1 Terminology G = {V, E} A graph G consists of two sets A set V of vertices, or nodes A set E of edges A subgraph Consists of a subset

### Competitive Programmer s Handbook. Antti Laaksonen

Competitive Programmer s Handbook Antti Laaksonen Draft December 0, 207 ii Contents Preface ix I Basic techniques Introduction 3. Programming languages......................... 3.2 Input and output..............................

### Minimum Spanning Trees

Minimum Spanning Trees Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting houses u and v has a repair cost w(u, v). Goal: Repair enough (and no

### 1. Consider the 62-element set X consisting of the twenty-six letters (case sensitive) of the English

MATH 3012 Final Exam, May 3, 2013, WTT Student Name and ID Number 1. Consider the 62-element set X consisting of the twenty-six letters (case sensitive) of the English alphabet and the ten digits {0, 1,

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

Course Review Cpt S 223 Fall 2012 1 Final Exam When: Monday (December 10) 8 10 AM Where: in class (Sloan 150) Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes

### CS301 - Data Structures Glossary By

CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm

### Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Lecture 13 Connectedness in graphs Spanning trees in graphs Finding a minimal spanning tree Time costs of graph problems and NP-completeness Finding a minimal spanning tree: Prim s and Kruskal s algorithms

### GRAPHS: THEORY AND ALGORITHMS

GRAPHS: THEORY AND ALGORITHMS K. THULASIRAMAN M. N. S. SWAMY Concordia University Montreal, Canada A Wiley-Interscience Publication JOHN WILEY & SONS, INC. New York / Chichester / Brisbane / Toronto /

### CS 440 Theory of Algorithms /

CS 440 Theory of Algorithms / CS 468 Algorithms in Bioinformaticsi Brute Force. Design and Analysis of Algorithms - Chapter 3 3-0 Brute Force A straightforward approach usually based on problem statement

### Minimum Spanning Trees Ch 23 Traversing graphs

Next: Graph Algorithms Graphs Ch 22 Graph representations adjacency list adjacency matrix Minimum Spanning Trees Ch 23 Traversing graphs Breadth-First Search Depth-First Search 11/30/17 CSE 3101 1 Graphs

### Lecture 4: Graph Algorithms

Lecture 4: Graph Algorithms Definitions Undirected graph: G =(V, E) V finite set of vertices, E finite set of edges any edge e = (u,v) is an unordered pair Directed graph: edges are ordered pairs If e

### ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

ASSIGNMENTS Chapter Q. No. Questions Course Outcom e (CO) Progra m Outcom e I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n)) 2 3. What is the time complexity of the algorithm? 4

### Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico.

Graph Algorithms Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico May, 0 CPD (DEI / IST) Parallel and Distributed Computing 0-0-0 / Outline

### Algorithms and Data Structures

Algorithm Analysis Page 1 - Algorithm Analysis Dr. Fall 2008 Algorithm Analysis Page 2 Outline Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Growth Rate and Big-Oh Notation

### Shortest path problems

Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths

CSE 5311-001: ADVANCED ALGORITHMS Summer 2014: TR 10:30-12:20, ERB 130 Instructor: Bob Weems, Associate Professor Office: 627 ERB (weems@uta.edu, http://ranger.uta.edu/~weems/ ) Hours: MW 3:00-4:00, TR

### 1. Basic idea: Use smaller instances of the problem to find the solution of larger instances

Chapter 8. Dynamic Programming CmSc Intro to Algorithms. Basic idea: Use smaller instances of the problem to find the solution of larger instances Example : Fibonacci numbers F = F = F n = F n- + F n-

### 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

### Introduction to Parallel & Distributed Computing Parallel Graph Algorithms

Introduction to Parallel & Distributed Computing Parallel Graph Algorithms Lecture 16, Spring 2014 Instructor: 罗国杰 gluo@pku.edu.cn In This Lecture Parallel formulations of some important and fundamental

### LOGIC SYNTHESIS AND VERIFICATION ALGORITHMS. Gary D. Hachtel University of Colorado. Fabio Somenzi University of Colorado.

LOGIC SYNTHESIS AND VERIFICATION ALGORITHMS by Gary D. Hachtel University of Colorado Fabio Somenzi University of Colorado Springer Contents I Introduction 1 1 Introduction 5 1.1 VLSI: Opportunity and

### List of Transparencies

List of Transparencies Chapter 1 Primitive Java 1 A simple first program 2 The eight primitve types in Java 3 Program that illustrates operators 4 Result of logical operators 5 Examples of conditional

### HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING

HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING Alan G. Konheim JOHN WILEY & SONS, INC., PUBLICATION HASHING IN COMPUTER SCIENCE HASHING IN COMPUTER SCIENCE FIFTY YEARS OF SLICING AND DICING

### Lecture 6: Combinatorics Steven Skiena. skiena

Lecture 6: Combinatorics Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Learning to Count Combinatorics problems are

### CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 25: Review and Open Problems Course Overview Programming Concepts Object-Oriented Programming Interfaces

### 7.3 Spanning trees Spanning trees [ ] 61

7.3. Spanning trees [161211-1348 ] 61 7.3 Spanning trees We know that trees are connected graphs with the minimal number of edges. Hence trees become very useful in applications where our goal is to connect

### CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH WINTER 2016 http://cseweb.ucsd.edu/classes/wi16/cse20-ab/ Today's learning goals Explain the steps in a proof by (strong) mathematical induction Use (strong) mathematical induction

### Unit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1

Unit #9: Graphs CPSC 1: Algorithms and Data Structures Will Evans 01W1 Unit Outline Topological Sort: Getting to Know Graphs with a Sort Graph ADT and Graph Representations Graph Terminology More Graph

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

### 15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015

15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015 Dynamic Programming is a powerful technique that allows one to solve many different types

### FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART

### INTRODUCTION TO HEURISTIC SEARCH

INTRODUCTION TO HEURISTIC SEARCH What is heuristic search? Given a problem in which we must make a series of decisions, determine the sequence of decisions which provably optimizes some criterion. What

### Graphs & Digraphs Tuesday, November 06, 2007

Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements

### CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

CS490 Quiz 1 NAME: STUDENT NO: SIGNATURE: This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed. Not all questions are of the same

### SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN. Sec. Name Office Office hour Mail id

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN Course Code Course Title : DATA STRUCTURES AND ALGORITHMS Semester : I Course Time : July Dec 207

### Greedy Algorithms. At each step in the algorithm, one of several choices can be made.

Greedy Algorithms At each step in the algorithm, one of several choices can be made. Greedy Strategy: make the choice that is the best at the moment. After making a choice, we are left with one subproblem

### Design and Analysis of Algorithms COT-301

Design and Analysis of Algorithms COT-301 L T P Theory: 100 4 1 - Sessional: 25 1. Introduction Review of elementary data structures, analyzing algorithms, asymptotic notation, recurrence relations, Hash

### A Survey of Mathematics with Applications 8 th Edition, 2009

A Correlation of A Survey of Mathematics with Applications 8 th Edition, 2009 South Carolina Discrete Mathematics Sample Course Outline including Alternate Topics and Related Objectives INTRODUCTION This

### Algorithms and Theory of Computation. Lecture 5: Minimum Spanning Tree

Algorithms and Theory of Computation Lecture 5: Minimum Spanning Tree Xiaohui Bei MAS 714 August 31, 2017 Nanyang Technological University MAS 714 August 31, 2017 1 / 30 Minimum Spanning Trees (MST) A

### Advanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012

topological ordering, minimum spanning tree, Union-Find problem Jiří Vyskočil, Radek Mařík 2012 Subgraph subgraph A graph H is a subgraph of a graph G, if the following two inclusions are satisfied: 2

### Unweighted Graphs & Algorithms

Unweighted Graphs & Algorithms Zachary Friggstad Programming Club Meeting References Chapter 4: Graph (Section 4.2) Chapter 22: Elementary Graph Algorithms Graphs Features: vertices/nodes/dots and edges/links/lines

### CS Final - Review material

CS4800 Algorithms and Data Professor Fell Fall 2009 October 28, 2009 Old stuff CS 4800 - Final - Review material Big-O notation Though you won t be quizzed directly on Big-O notation, you should be able

### 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

### CS DATA STRUCTURES AND ALGORITHMS

Computer Science and Engineering Third Semester CS1211 - DATA STRUCTURES AND ALGORITHMS UNIT-I - INTRODUCTION TO DATASTRUCTURES 1.Write down the definition of data structures? PART -A A data structure

### Graph Algorithms Using Depth First Search

Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth

### U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, Midterm 1 Solutions

U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, 2013 Midterm 1 Solutions 1 True/False 1. The Mayan base 20 system produces representations of size that is asymptotically

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

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

### Agenda. Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp

Graph Charles Lin genda Graph Representation FS BFS ijkstra * Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp Graph Representation djacency Matrix bool way[100][100];

### Dynamic Programming Homework Problems

CS 1510 Dynamic Programming Homework Problems 1. (2 points) Consider the recurrence relation T (0) = T (1) = 2 and for n > 1 n 1 T (n) = T (i)t (i 1) i=1 We consider the problem of computing T (n) from

### Testing Bipartiteness of Geometric Intersection Graphs David Eppstein

Testing Bipartiteness of Geometric Intersection Graphs David Eppstein Univ. of California, Irvine School of Information and Computer Science Intersection Graphs Given arrangement of geometric objects,

### We can use a max-heap to sort data.

Sorting 7B N log N Sorts 1 Heap Sort We can use a max-heap to sort data. Convert an array to a max-heap. Remove the root from the heap and store it in its proper position in the same array. Repeat until

### 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

### Lecture 5: Suffix Trees

Longest Common Substring Problem Lecture 5: Suffix Trees Given a text T = GGAGCTTAGAACT and a string P = ATTCGCTTAGCCTA, how do we find the longest common substring between them? Here the longest common

### Optimization II: Dynamic Programming

Chapter 12 Optimization II: Dynamic Programming In the last chapter, we saw that greedy algorithms are efficient solutions to certain optimization problems. However, there are optimization problems for

### Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

DATA STRUCTURES COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges book. Data

### Design and Analysis of Algorithms

CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 9: Minimum Spanning Trees Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Goal: MST cut and cycle properties Prim, Kruskal greedy algorithms

### Tribhuvan University Institute of Science and Technology Computer Science and Information Technology (CSC. 154) Section A Attempt any Two questions:

Tribhuvan University 2065 Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSC. 154) Pass Marks: 24 (Data Structure and Algorithm) Time:

### Shortest Path Problem

Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths

### 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

### CS 170 DISCUSSION 8 DYNAMIC PROGRAMMING. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17

CS 170 DISCUSSION 8 DYNAMIC PROGRAMMING Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17 DYNAMIC PROGRAMMING Recursive problems uses the subproblem(s) solve the current one. Dynamic

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

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

### Module 5 Graph Algorithms

Module 5 Graph lgorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu 5. Graph Traversal lgorithms Depth First

### Minimum Spanning Tree

Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we