# COS 226 Algorithms and Data Structures Fall Final

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 COS 22 Algorithms and Data Structures Fall 200 Final This test has 4 questions worth a total of 00 points. You have 80 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet (8.5-by-, both sides, in your own handwriting). No calculators or other electronic devices are permitted. Give your answers and show your work in the space provided. Write out and sign the Honor Code pledge before turning in the test. I pledge my honor that I have not violated the Honor Code during this examination. Problem Score Problem Score Sub Sub 2 Total Name: Login ID: Precept: P0 Bob Tarjan P02 2:30 Yuri Pritykin P02A 2:30 Bob Tarjan P03 :30 Aman Dhesi P03A :30 Siyu Yang

2 2 PRINCETON UNIVERSITY 0. Miscellaneous. ( point) Write your name and Princeton NetID in the space provided on the front of the exam, and circle your precept number.. Analysis of algorithms. (2 points) Which of the following can be performed in linear time in the worst case? For the purposes of this question, assume P NP. Write P (possible), I (impossible), or U (unknown). Find a maximum spanning tree in a connected edge-weighted graph. Find all vertices reachable from a given set of source vertices in a digraph. Find a Hamilton path in a digraph (if one exists). A Hamilton path is a simple path that visits each vertex in the digraph exactly once. Find a Hamilton path in a DAG (if one exists). Find the strong components of a digraph. Insert N Comparable keys into a binary heap. Sort an array of N Comparable keys. Insert N Comparable keys into a binary search tree. Compute the inverse Burrows-Wheeler transform. Insert N strings into an R-way trie. (Here, linear means linear in the sum of the lengths of the N strings.) Print the N strings in a ternary search trie in ascending order. (Here, linear means linear in the sum of the lengths of the N strings.) Perform a nearest-neighbor query in a 2-d tree.

3 COS 22 FINAL, FALL Equivalence relations. (5 points) Which of the following are equivalence relations? Put a next to those that are equivalence relations. v.equals(w) for objects in a Java class that correctly implements the equals() method v.compareto(w) < 0 for objects in a Java class that correctly implements the Comparable interface connected(v, w) in CC for connectivity in an undirected graph reachable(v, w) in TransitiveClosure for reachability in a digraph stronglyconnected(v, w) in KosarajuSCC for strong connectivity in a digraph Recall, an equivalence relation is a binary relation that is reflexive: v v symmetric: if v w, then w v transitive: if v w and w x, then v x

4 4 PRINCETON UNIVERSITY 3. Depth-first search. (8 points) DFS, Fall 200 (a) Run depth-first search on the digraph below, starting at vertex A. Assume the adjacency lists are in sorted order: for example, when exploring vertex F, consider the edge F C before F E or F H. B G A C E I D F H List the vertices in preorder and postorder. preorder: A B 8 postorder: G B (b) Consider two vertices x and y that are simultaneously on the function-call stack at some point during the execution of depth-first search from vertex s in a digraph. Which of the following must be true? I. There is both a directed path from s to x and a directed path from s to y. II. If there is no directed path from x to y, then there is a directed path from y to x. III. There is both a directed path from x to y and a directed path from y to x. (a) I only. (b) I and II only. (d) I, II and III. (e) None. (c) I and III only.

5 COS 22 FINAL, FALL Minimum spanning tree. (8 points) Minimum Spanning Tree, Fall 200 Consider the following edge-weighted graph with 9 vertices and 9 edges. Note that the edge weights are distinct integers between and 9. F B I G E 9 D A 3 3 H 2 C (a) Complete the sequence of edges in the MST in the order that Kruskal s algorithm includes them (by specifying their edge weights). 4

6 PRINCETON UNIVERSITY Minimum Spanning Tree, Fall 200 The edge-weighted graph from the previous page is repeated here for reference. F B I G E 9 D A 3 3 H 2 C (b) Complete the sequence of edges in the MST in the order that Prim s algorithm includes them (by specifying their edge weights). Start Prim s algorithm from vertex A. 4

7 COS 22 FINAL, FALL Shortest paths. (0 points) Dijkstra, Fall 200 Run the eager version of Dijkstra s algorithm on the following edge-weighted digraph, starting from vertex Dijkstra, Fall v edgeto[] distto[] (a) Complete the table of edgeto[] and distto[] 2-> values33.0 immediately 34.0 after the first 5 Dijkstra, vertices Fall (0, 2, 200 3, 5, and ) have been deleted from 2 0->2 the priority.0 queue.0and relaxed > v edgeto[] distto[] > > > > > (b) 33 Complete the table of edgeto[] 30 and distto[] values immediately after the th vertex has been deleted from the priority queue and relaxed. Circle those values that changed from (a) v edgeto[] distto[] > > > > (c) Draw the edges in the (final) shortest-paths tree with thick lines in the figure above. 9 9

8 8 PRINCETON UNIVERSITY. Polar sort. ( points) Consider the following proposed Comparator for sorting points in the plane by polar angle with respect to a base point. It is based on the ccw method from lecture. import java.util.comparator; public class Point { private final int x, y; public final Comparator<Point> POLAR_ORDER = new PolarOrder(); public Point(int x, int y) { this.x = x; this.y = y; } // is a->b->c a counterclockwise turn? // - if clockwise; + if counterclockwise; 0 if collinear public static int ccw(point a, Point b, Point c) { double area2 = (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x); if (area2 < 0) return -; else if (area2 > 0) return +; else return 0; } } // compare q and q2 by polar angle they make with this point private class PolarOrder implements Comparator<Point> { public int compare(point q, Point q2) { return ccw(point.this, q2, q); } } (a) What is the fatal flaw with the Comparator implementation? Note: there is nothing wrong with the Java code (and Point.this is Java s obscure way of referring to the enclosing object from within a nested class). Do not worry about integer overflow. (b) Suggest an easy approach to fixing the flaw.

9 COS 22 FINAL, FALL Kd-tree, Fall Kd-trees. (8 points) The figures below illustrate the results of inserting points through 0 into a 2d-tree (a) Circle all of the the points below in the 2d-tree that are examined (not necessarily just those inside the query rectangle) during the range search for the query rectangle specified above (b) Draw the result of inserting point, then point 2 in the two figures above.

10 0 PRINCETON UNIVERSITY 8. Substring search. ( points) Create the Knuth-Morris-Pratt DFA for the string abcabac over the alphabet { a, b, c } by completing the following table. As usual, state 0 is the start state and state 7 is the accept state a 4 b c Final, Fall 200 You may use the following partially-completed graphical representation of the DFA for scratch work (but we will consider your solution to be the completed table above). b a 0 a b 2 c 3 a 4 b 5 a c 7 c c

11 COS 22 FINAL, FALL Regular expressions. ( points) Convert the regular expression ( a ( b c d ) * ) into an equivalent NFA (nondeterministic finite state automaton) using the algorithm described in lecture and the textbook by adding ɛ-transition edges to the diagram below. Final, Fall ( a ( b c d ) * ) 74

12 2 PRINCETON UNIVERSITY 0. Substring search and pattern matching. (7 points) For each algorithm on the left (the version discussed in lecture and the textbook), give the best-matching worst-case order of growth on the right. brute-force substring search for a query string of size M in a text string of size N Knuth-Morris Pratt substring search for a query string of size M in a text string of size N Boyer-Moore (with only mismatch heuristic) substring search for a query string of size M in a text string of size N Monte Carlo version of Rabin-Karp substring search (that checks only for a hash match) for a query string of size M in a text string of size N A. M B. N/M C. N D. M + N E. MN F. 2 M G. 2 N regular-expression pattern matching for a pattern of size M on a text string of size N simulating a DFA with M vertices and 2M edges on a text string of size N simulating an NFA with M vertices and 3M edges on a text string of size N

13 COS 22 FINAL, FALL Huffman codes. (5 points) Consider the following variable-length codes for the 3-character text string: F C F C E C A C B D E D F E A B F B A F F C D C B E D F F F C C D E E F symbol freq code code 2 code 3 code 4 code 5 A B C D E F Identify each code (on the left) with the best-matching descriptions (on the right). Write as many letters next to each code as apply. code A. prefix-free code code 2 code 3 code 4 B. Huffman code (assume that when merging the two minimal subtries, either subtrie can become the left or right child) C. optimal prefix-free code code 5

14 4 PRINCETON UNIVERSITY 2. Cyclic rotation of a strings. (9 points) A string s is a cyclic rotation of a string t if s and t have the same length and s consists of a suffix of t followed by a prefix of t. Design a linear-time algorithm to determine whether one string is a cyclic rotation of another. You may assume they have the same length N. For example, "winterbreak" is a cyclic rotation of "breakwinter" (and vice versa). Your answer will be graded on correctness, efficiency, clarity, and succinctness. Let N denote the length of s and t. For full credit, the running time of your algorithm should be proportional to N in the worst case. (a) Describe your algorithm in the space below. (b) What is the order of growth of the worst-case running time of your algorithm as a function of N? Circle the best answer. log N N N log N N 2 N 3

15 COS 22 FINAL, FALL Reductions. (9 points) Consider the following two problems: Multiplication. Given two N-bit integers x and y, compute x y. Squaring. Given an N-bit integer x, compute x 2. We measure the running time as a function of the number of bits in the input(s). For example, adding or subtracting two N-bit integers takes time proportional to N using the standard grade-school algorithm. Potentially useful facts about integers: (a + b) 2 = a 2 + b 2 + 2ab; (a b) 2 = a 2 + b 2 2ab, (a + b)(a b) = a 2 b 2. (a) Show that Squaring linear-time reduces to Multiplication. To demonstrate your reduction, give the Multiplication instance(s) that you would construct to solve the following Squaring instance: given x, compute x 2. (b) Show that Multiplication linear-time reduces to Squaring. To demonstrate your reduction, give the Squaring instance(s) that you would construct to solve the following Multiplication instance: given x and y, compute x y.

16 (c) Suppose that Alice discovers an N log log log N algorithm for Squaring and Bob discovers an Nα(N) lower bound for Multiplication, where α(n) is a really really slowly growing (but super-constant) function. Which of the following can you infer from the fact that Squaring and Multiplication linear-time reduce to one another? I. There does not exist a linear-time algorithm for Multiplication. II. Squaring and Multiplication have the same asymptotic complexity. III. There exists an N log log log N algorithm for Multiplication. (a) I only. (b) I and II only. (d) I, II and III. (e) None. (c) I and III only.

### CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

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

### Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

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

### Data Structure [Question Bank]

Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:

### Class Notes CS 3137. 1 Creating and Using a Huffman Code. Ref: Weiss, page 433

Class Notes CS 3137 1 Creating and Using a Huffman Code. Ref: Weiss, page 433 1. FIXED LENGTH CODES: Codes are used to transmit characters over data links. You are probably aware of the ASCII code, a fixed-length

### 5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

### 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

### 2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)

### International Journal of Software and Web Sciences (IJSWS) www.iasir.net

International Association of Scientific Innovation and Research (IASIR) (An Association Unifying the Sciences, Engineering, and Applied Research) ISSN (Print): 2279-0063 ISSN (Online): 2279-0071 International

### Computational Geometry. Lecture 1: Introduction and Convex Hulls

Lecture 1: Introduction and convex hulls 1 Geometry: points, lines,... Plane (two-dimensional), R 2 Space (three-dimensional), R 3 Space (higher-dimensional), R d A point in the plane, 3-dimensional space,

### Homework Exam 1, Geometric Algorithms, 2016

Homework Exam 1, Geometric Algorithms, 2016 1. (3 points) Let P be a convex polyhedron in 3-dimensional space. The boundary of P is represented as a DCEL, storing the incidence relationships between the

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

### Home 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) n-element vector start address + ielementsize 0 +1 +2 +3 +4... +n-1 start address continuous memory block static, if size is known at compile time dynamic,

### Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

### CompSci-61B, Data Structures Final Exam

Your Name: CompSci-61B, Data Structures Final Exam Your 8-digit Student ID: Your CS61B Class Account Login: This is a final test for mastery of the material covered in our labs, lectures, and readings.

### To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers

To My Parents -Laxmi and Modaiah To My Family Members To My Friends To IIT Bombay To All Hard Workers Copyright 2010 by CareerMonk.com All rights reserved. Designed by Narasimha Karumanchi Printed in

### Divide-and-Conquer. Three main steps : 1. divide; 2. conquer; 3. merge.

Divide-and-Conquer Three main steps : 1. divide; 2. conquer; 3. merge. 1 Let I denote the (sub)problem instance and S be its solution. The divide-and-conquer strategy can be described as follows. Procedure

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

### 1. Sorting (assuming sorting into ascending order) a) BUBBLE SORT

DECISION 1 Revision Notes 1. Sorting (assuming sorting into ascending order) a) BUBBLE SORT Make sure you show comparisons clearly and label each pass First Pass 8 4 3 6 1 4 8 3 6 1 4 3 8 6 1 4 3 6 8 1

### The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

### Theory of Computation

Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

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

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

### Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Outline NP-completeness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2-pairs sum vs. general Subset Sum Reducing one problem to another Clique

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

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

### CS711008Z Algorithm Design and Analysis

CS711008Z Algorithm Design and Analysis Lecture 7 Binary heap, binomial heap, and Fibonacci heap 1 Dongbo Bu Institute of Computing Technology Chinese Academy of Sciences, Beijing, China 1 The slides were

### Algorithms and Data Structures (INF1) Lecture 14/15 Hua Lu

Algorithms and Data Structures (INF1) Lecture 14/15 Hua Lu Department of Computer Science Aalborg University Fall 2007 This Lecture Shortest paths Problem preliminary Shortest paths in DAG Bellman-Moore

### Algorithms and Data Structures

Algorithm Analysis Page 1 BFH-TI: Softwareschule Schweiz Algorithm Analysis Dr. CAS SD01 Algorithm Analysis Page 2 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations

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

### A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION Tao Chen 1, Tarek Sobh 2 Abstract -- In this paper, a software application that features the visualization of commonly used

### 1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated

### Informatique Fondamentale IMA S8

Informatique Fondamentale IMA S8 Cours 4 : graphs, problems and algorithms on graphs, (notions of) NP completeness Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université

### Data Structures. Chapter 8

Chapter 8 Data Structures Computer has to process lots and lots of data. To systematically process those data efficiently, those data are organized as a whole, appropriate for the application, called a

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

### Midterm Practice Problems

6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator

### Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : 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

### The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical

### AP Computer Science AB Syllabus 1

AP Computer Science AB Syllabus 1 Course Resources Java Software Solutions for AP Computer Science, J. Lewis, W. Loftus, and C. Cocking, First Edition, 2004, Prentice Hall. Video: Sorting Out Sorting,

### Java Software Structures

INTERNATIONAL EDITION Java Software Structures Designing and Using Data Structures FOURTH EDITION John Lewis Joseph Chase This page is intentionally left blank. Java Software Structures,International Edition

### Mathematics for Algorithm and System Analysis

Mathematics for Algorithm and System Analysis for students of computer and computational science Edward A. Bender S. Gill Williamson c Edward A. Bender & S. Gill Williamson 2005. All rights reserved. Preface

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

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

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### Arithmetic Coding: Introduction

Data Compression Arithmetic coding Arithmetic Coding: Introduction Allows using fractional parts of bits!! Used in PPM, JPEG/MPEG (as option), Bzip More time costly than Huffman, but integer implementation

### CMPS 102 Solutions to Homework 1

CMPS 0 Solutions to Homework Lindsay Brown, lbrown@soe.ucsc.edu September 9, 005 Problem..- p. 3 For inputs of size n insertion sort runs in 8n steps, while merge sort runs in 64n lg n steps. For which

### Social Media Mining. Graph Essentials

Graph Essentials Graph Basics Measures Graph and Essentials Metrics 2 2 Nodes and Edges A network is a graph nodes, actors, or vertices (plural of vertex) Connections, edges or ties Edge Node Measures

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

### 10CS35: Data Structures Using C

CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

### GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: 3330704)

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT Course Curriculum DATA STRUCTURES (Code: 3330704) Diploma Programme in which this course is offered Semester in which offered Computer Engineering,

### UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE

STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia

### Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

### CS/COE 1501 http://cs.pitt.edu/~bill/1501/

CS/COE 1501 http://cs.pitt.edu/~bill/1501/ Lecture 01 Course Introduction Meta-notes These notes are intended for use by students in CS1501 at the University of Pittsburgh. They are provided free of charge

### Everyday Mathematics CCSS EDITION CCSS EDITION. Content Strand: Number and Numeration

CCSS EDITION Overview of -6 Grade-Level Goals CCSS EDITION Content Strand: Number and Numeration Program Goal: Understand the Meanings, Uses, and Representations of Numbers Content Thread: Rote Counting

### MATHEMATICS Unit Decision 1

General Certificate of Education January 2008 Advanced Subsidiary Examination MATHEMATICS Unit Decision 1 MD01 Tuesday 15 January 2008 9.00 am to 10.30 am For this paper you must have: an 8-page answer

### Everyday Mathematics GOALS

Copyright Wright Group/McGraw-Hill GOALS The following tables list the Grade-Level Goals organized by Content Strand and Program Goal. Content Strand: NUMBER AND NUMERATION Program Goal: Understand the

### Any two nodes which are connected by an edge in a graph are called adjacent node.

. iscuss following. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs

### 2.3 Scheduling jobs on identical parallel machines

2.3 Scheduling jobs on identical parallel machines There are jobs to be processed, and there are identical machines (running in parallel) to which each job may be assigned Each job = 1,,, must be processed

### Shortest Path Algorithms

Shortest Path Algorithms Jaehyun Park CS 97SI Stanford University June 29, 2015 Outline Cross Product Convex Hull Problem Sweep Line Algorithm Intersecting Half-planes Notes on Binary/Ternary Search Cross

### CMPSCI611: Approximating MAX-CUT Lecture 20

CMPSCI611: Approximating MAX-CUT Lecture 20 For the next two lectures we ll be seeing examples of approximation algorithms for interesting NP-hard problems. Today we consider MAX-CUT, which we proved to

### Chapter 6: Graph Theory

Chapter 6: Graph Theory Graph theory deals with routing and network problems and if it is possible to find a best route, whether that means the least expensive, least amount of time or the least distance.

### L T P C Course Name: Linux Lab 0 0 4 2. Course Code: PBC - 602

Course Code: PBC - 602 Course Name: Linux Lab 0 0 4 2 1) Write a shell script to input two numbers and perform all mathematical operations on them 2) Write a shell script to print the information about

### CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

CS104: Data Structures and Object-Oriented 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

### CS 2112 Spring 2014. 0 Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

CS 2112 Spring 2014 Assignment 3 Data Structures and Web Filtering Due: March 4, 2014 11:59 PM Implementing spam blacklists and web filters requires matching candidate domain names and URLs very rapidly

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

### Finite Automata. Reading: Chapter 2

Finite Automata Reading: Chapter 2 1 Finite Automaton (FA) Informally, a state diagram that comprehensively captures all possible states and transitions that a machine can take while responding to a stream

### Dynamic Programming. Applies when the following Principle of Optimality

Dynamic Programming Applies when the following Principle of Optimality holds: In an optimal sequence of decisions or choices, each subsequence must be optimal. Translation: There s a recursive solution.

### CS2 Algorithms and Data Structures Note 11. Breadth-First Search and Shortest Paths

CS2 Algorithms and Data Structures Note 11 Breadth-First Search and Shortest Paths In this last lecture of the CS2 Algorithms and Data Structures thread we will consider the problem of computing distances

### Maths Targets Year 1 Addition and Subtraction Measures. N / A in year 1.

Number and place value Maths Targets Year 1 Addition and Subtraction Count to and across 100, forwards and backwards beginning with 0 or 1 or from any given number. Count, read and write numbers to 100

### Algorithm Homework and Test Problems

Algorithm Homework and Test Problems Steven S. Skiena Department of Computer Science State University of New York Stony Brook, NY 11794-4400 skiena@cs.sunysb.edu January 29, 2006 All of the midterm and

### Questions and Answers in Computer Science. By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel

Questions and Answers in Computer Science By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel The Questions in this material are collected from Computer Science Subject Graduate Record

### Lecture 1: Data Storage & Index

Lecture 1: Data Storage & Index R&G Chapter 8-11 Concurrency control Query Execution and Optimization Relational Operators File & Access Methods Buffer Management Disk Space Management Recovery Manager

### Introduction to Algorithms Review information for Prelim 1 CS 4820, Spring 2010 Distributed Wednesday, February 24

Introduction to Algorithms Review information for Prelim 1 CS 4820, Spring 2010 Distributed Wednesday, February 24 The final exam will cover seven topics. 1. greedy algorithms 2. divide-and-conquer algorithms

### Binary 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 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using

### Union-Find Algorithms. network connectivity quick find quick union improvements applications

Union-Find Algorithms network connectivity quick find quick union improvements applications 1 Subtext of today s lecture (and this course) Steps to developing a usable algorithm. Define the problem. Find

### Information 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 Shannon-Fano-Elias Coding and Introduction to Arithmetic Coding

### Data Structures in Java. Session 15 Instructor: Bert Huang http://www1.cs.columbia.edu/~bert/courses/3134

Data Structures in Java Session 15 Instructor: Bert Huang http://www1.cs.columbia.edu/~bert/courses/3134 Announcements Homework 4 on website No class on Tuesday Midterm grades almost done Review Indexing

### AFF 808. Sub. Code 4BIT1C1. B.Sc. DEGREE EXAMINATION, NOVEMBER 2015. First Semester. Information Technology

Ws4 AFF 808 Sub. Code 4BITC B.Sc. DEGREE EXAMINATION, NOVEMBER 05 First Semester Information Technology PRINCIPLES OF INFORMATION TECHNOLOGY AND OS (CBCS 04 onwards) Time : 3 Hours Maximum : 75 Marks Part

### B AB 5 C AC 3 D ABGED 9 E ABGE 7 F ABGEF 8 G ABG 6 A BEDA 3 C BC 1 D BCD 2 E BE 1 F BEF 2 G BG 1

p.9 9.5 a. Find the shortest path from A to all other vertices for the graph in Figure 9.8. b. Find the shortest unweighted path from B to all other vertices for the graph in Figure 9.8. A 5 B C 7 7 6

### Mathematical Procedures

CHAPTER 6 Mathematical Procedures 168 CHAPTER 6 Mathematical Procedures The multidisciplinary approach to medicine has incorporated a wide variety of mathematical procedures from the fields of physics,

### Charlesworth School Year Group Maths Targets

Charlesworth School Year Group Maths Targets Year One Maths Target Sheet Key Statement KS1 Maths Targets (Expected) These skills must be secure to move beyond expected. I can compare, describe and solve

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

### CAD Algorithms. P and NP

CAD Algorithms The Classes P and NP Mohammad Tehranipoor ECE Department 6 September 2010 1 P and NP P and NP are two families of problems. P is a class which contains all of the problems we solve using

### AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note Attempts all the questions. All carry equal marks Section A

### Lecture 4: Exact string searching algorithms. Exact string search algorithms. Definitions. Exact string searching or matching

COSC 348: Computing for Bioinformatics Definitions A pattern (keyword) is an ordered sequence of symbols. Lecture 4: Exact string searching algorithms Lubica Benuskova http://www.cs.otago.ac.nz/cosc348/

### Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Chapter Objectives Chapter 9 Search Algorithms Data Structures Using C++ 1 Learn the various search algorithms Explore how to implement the sequential and binary search algorithms Discover how the sequential

### Finite Automata. Reading: Chapter 2

Finite Automata Reading: Chapter 2 1 Finite Automata Informally, a state machine that comprehensively captures all possible states and transitions that a machine can take while responding to a stream (or

### GCE Computing. COMP3 Problem Solving, Programming, Operating Systems, Databases and Networking Report on the Examination.

GCE Computing COMP3 Problem Solving, Programming, Operating Systems, Databases and Networking Report on the Examination 2510 Summer 2014 Version: 1.0 Further copies of this Report are available from aqa.org.uk

### Binary Search. Search for x in a sorted array A.

Divide and Conquer A general paradigm for algorithm design; inspired by emperors and colonizers. Three-step process: 1. Divide the problem into smaller problems. 2. Conquer by solving these problems. 3.

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

### GRAPH THEORY LECTURE 4: TREES

GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection

### Mining Social Network Graphs

Mining Social Network Graphs Debapriyo Majumdar Data Mining Fall 2014 Indian Statistical Institute Kolkata November 13, 17, 2014 Social Network No introduc+on required Really? We s7ll need to understand

### System Interconnect Architectures. Goals and Analysis. Network Properties and Routing. Terminology - 2. Terminology - 1

System Interconnect Architectures CSCI 8150 Advanced Computer Architecture Hwang, Chapter 2 Program and Network Properties 2.4 System Interconnect Architectures Direct networks for static connections Indirect

### Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.

Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used

### Introduction to Algorithms. Part 3: P, NP Hard Problems

Introduction to Algorithms Part 3: P, NP Hard Problems 1) Polynomial Time: P and NP 2) NP-Completeness 3) Dealing with Hard Problems 4) Lower Bounds 5) Books c Wayne Goddard, Clemson University, 2004 Chapter