Question Score Points Out Of 25

Similar documents
Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

Relational Database: The Relational Data Model; Operations on Database Relations

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

CS-245 Database System Principles Winter 2002 Assignment 4

Hashing. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

CMSC Theory of Algorithms Second Midterm

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Summer I Instructions:

Introduction to Algorithms April 21, 2004 Massachusetts Institute of Technology. Quiz 2 Solutions

CS 564 Final Exam Fall 2015 Answers

Exam Datenstrukturen und Algorithmen D-INFK

U.C. Berkeley CS170 : Algorithms Midterm 1 Lecturers: Alessandro Chiesa and Satish Rao September 18, Midterm 1

Solutions for the Exam 6 January 2014

CS 222/122C Fall 2016, Midterm Exam

Student Number: CSE191 Midterm II Spring Plagiarism will earn you an F in the course and a recommendation of expulsion from the university.

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CS 337 Project 1: Minimum-Weight Binary Search Trees

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Introduction to Algorithms March 12, 2008 Massachusetts Institute of Technology Spring 2008 Professors Srini Devadas and Erik Demaine Quiz 1

CSIT5300: Advanced Database Systems

University of Waterloo CS240, Winter 2010 Assignment 2

Suffix Trees and Arrays

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

Exam Datenstrukturen und Algorithmen D-INFK

( ) n 5. Test 1 - Closed Book

Graduate Examination. Department of Computer Science The University of Arizona Spring March 5, Instructions

Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2010

CS4311 Design and Analysis of Algorithms. Lecture 1: Getting Started

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

COMPUTER SCIENCE TRIPOS

CS 3343 (Spring 2013) Exam 2

Algorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures

Sorting and Selection

CS2351 Data Structures. Lecture 1: Getting Started

Practice Midterm Exam Solutions

CS 373: Combinatorial Algorithms, Spring 1999

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

The resulting array is written as row i + 1 in our matrix:

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

1 (15 points) LexicoSort

Lower Bound on Comparison-based Sorting

Binary Search to find item in sorted array

Introduction to Hashing

Lecture 12 March 4th

Errors in Computation

CS264: Homework #4. Due by midnight on Wednesday, October 22, 2014

Table : IEEE Single Format ± a a 2 a 3 :::a 8 b b 2 b 3 :::b 23 If exponent bitstring a :::a 8 is Then numerical value represented is ( ) 2 = (

Notes on Bloom filters

CSE 190D Spring 2017 Final Exam Answers

Midterm 1 for CS 170

Databases-1 Lecture-01. Introduction, Relational Algebra

CS 3343 (Spring 2018) Assignment 4 (105 points + 15 extra) Due: March 9 before class starts

Fundamentals of Database Systems

Lecture 6: Hashing Steven Skiena

RELATIONAL OPERATORS #1

Data Structure and Algorithm Midterm Reference Solution TA

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

CS264: Homework #1. Due by midnight on Thursday, January 19, 2017

CS222P Fall 2017, Final Exam

Math 5320, 3/28/18 Worksheet 26: Ruler and compass constructions. 1. Use your ruler and compass to construct a line perpendicular to the line below:

Quiz 2. Problem Parts Points Grade Grader. Total 120. Name: Recitation: Jayant 12 PM. Christina 10 AM. Jayant 1 PM. Jason 2 PM.

Exam 1. March 20th, CS525 - Midterm Exam Solutions

Algorithms and Data Structures, or

CS211 Spring 2005 Prelim 2 April 19, Instructions

Exam Datenstrukturen und Algorithmen D-INFK

CS 512, Spring 2017: Take-Home End-of-Term Examination

Hash table example. B+ Tree Index by Example Recall binary trees from CSE 143! Clustered vs Unclustered. Example

Review for Midterm Exam

Data Structure and Algorithm Homework #6 Due: 5pm, Friday, June 14, 2013 TA === Homework submission instructions ===

University of Waterloo Midterm Examination Sample Solution

Online Algorithms. Lecture 11

University of Waterloo CS240 Spring 2018 Help Session Problems

Non-Standard Models of Arithmetic

Introduction to Database Systems CSE 414. Lecture 26: More Indexes and Operator Costs

Mar. 20 Math 2335 sec 001 Spring 2014

Lecture 7: Efficient Collections via Hashing

CS261: Problem Set #1

CSE 344 FEBRUARY 14 TH INDEXING

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

CS 360 Exam 1 Fall 2014 Name. 1. Answer the following questions about each code fragment below. [8 points]

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

The SQL data-definition language (DDL) allows defining :

CS 245 Midterm Exam Winter 2014

1 Introduciton. 2 Tries /651: Algorithms CMU, Spring Lecturer: Danny Sleator

ECE368 Exam 2 Spring 2016

Spring 2013 CS 122C & CS 222 Midterm Exam (and Comprehensive Exam, Part I) (Max. Points: 100)

Layered Network Architecture. CSC358 - Introduction to Computer Networks

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1

Algorithms and Data Structures

specified or may be difficult to handle, we often have a tabulated data

Outline. Query Processing Overview Algorithms for basic operations. Query optimization. Sorting Selection Join Projection

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

CS 350 Final Algorithms and Complexity. It is recommended that you read through the exam before you begin. Answer all questions in the space provided.

CSCI 104 Log Structured Merge Trees. Mark Redekopp

CS2 Algorithms and Data Structures Note 4

ACO Comprehensive Exam October 12 and 13, Computability, Complexity and Algorithms

Algorithms & Data Structures

Transcription:

University of Texas at Austin 6 May 2005 Department of Computer Science Theory in Programming Practice, Spring 2005 Test #3 Instructions. This is a 50-minute test. No electronic devices (including calculators) are permitted. The test is closed book and closed notes, except that one page of notes is permitted (both sides may be used). Solve as many of the questions as you can. There are a total of 50 points available, but the test will be graded out of 25 (i.e., the maximum possible score is 50 out of 25). IMPORTANT: Unless you are explicitly asked to justify your answer, it is sufficient for you to simply provide a final answer. Question Score Points 1 6 2 4 3 8 4 9 5 5 6 5 7 4 8 3 9 6 Out Of 25 Name:

1. (6 points total) In the following parts, let R denote the database relation containing all triples of integers x, y, and z such that 0 < x y z and x + y + z = 7. (a) (2 points) Give a tabular representation of R. Hint: R contains four triples. (b) (2 points) Give a tabular representation of the database relation σ p (R), where p denotes the predicate x + y = 4. (c) (2 points) Give a tabular representation of the database relation π z (R). 2. (4 points) Explain why the following identity, in which p denotes a predicate and R and S denote relations, is useful in the context of query optimization. σ p (R) S = σ p (R S) 2

3. (8 points total) Consider a database with two tables. The first table is called parts and has columns partnum (a unique integer ID for a particular part) and price (a floating point value indicating the price of the part). The second table is called orders and has columns customer (a string specifying the name of the customer), partnum (the integer ID of the part being ordered), and quantity (a nonnegative integer indicating the order quantity). In each of the following parts, give a single SQL query that provides the specified information. (a) (2 points) For each part with at least one associated order, list the part number and the total quantity ordered. The output columns should be entitled partnum and quantity. (b) (3 points) For each order, list the customer name, the part number, and the total cost of the order. The output columns should be entitled customer, partnum, and cost. (c) (3 points) For each customer, list the customer name and the total cost of all that customer s orders. The output columns should be entitled customer and total. 3

4. (9 points total) In parts (a) and (b) below, you may assume that n is a power of 2. (a) (2 points) Give a Θ-bound on the number of comparisons used by bitonic merge to merge two sorted sequences of length n into a single sorted sequence of length 2n. (b) (2 points) Give a Θ-bound on the number of comparisons used by bitonic sort to sort an input of length n. (c) (3 points) Explain why the following algorithm correctly sorts any 0-1 input sequence of length n: Take the first element of the sequence, call it x, and use it to partition the entire set of n elements into those elements which are less than x (output these elements first, in arbitrary order), those which are equal to x (output these next), and those which are greater than x (output these last). (d) (2 points) Note that the algorithm of part (c) uses Θ(n) -type comparisons. (For example, to determine whether x = y, we can check whether x y and y x.) Does the zero-one principle therefore imply that there is an oblivious compare-interchange algorithm for sorting arbitrary sequences of n integers using Θ(n) comparisons? Justify your answer. 4

5. (5 points total) The following parts deal with the FFT algorithm as described in the course packet and lecture slides, i.e., over the complex numbers. (a) (2 points) Give a Θ-bound on the number of arithmetic operations needed to execute the FFT algorithm on a powerlist of length n. (b) (3 points) Suppose that the FFT of the powerlist a 0 a 1 a 2 a 3 is the powerlist b 0 b 1 b 2 b 3. Specify a polynomial p and a complex number z such that b 3 = p(z). 6. (5 points) Let n be a power of two and let p denote the powerlist As in the lectures, define p as the powerlist p 0 p 1 p 2 p n 1. 0 p 0 p 1 p 2 p n 2. Solve the following equation in the powerlist variable z = z 0 z 1 z 2 z n 1, that is, express each z i as a function of the p j s: z = z + p. Briefly justify your answer. 5

7. (4 points total) Consider an instance of the exact string matching problem in which the text string is of length m and the pattern string is of length n, where m n. (a) (2 points) Give an exact expression for the maximum possible number of matches, as a function of m and n. (b) (2 points) Suppose we look for matches using the Rabin-Karp algorithm (RK), and there are no matches to be found. Further assume that RK uses an idealized hash function that maps every string to a uniformly random 32-bit integer. Give an exact expression (as a function of m and n) for the expected number of false positives that occur during the execution of RK. Remark: By a false positive, we mean a situation in which RK is forced to do a normal string comparison because the hash of the current window is equal to the hash of the pattern. 8. (3 points) Let A be a program fragment that involves two nonnegative integer variables i and j, and assume that execution of A from any program state has one of the two following effects on the the values of i and j: (1) i is incremented and j is reduced by 9; (2) i is left unchanged and j is incremented. Specify an integer-valued function of i and j that is guaranteed to increase whenever A is executed. Briefly justify your answer. 6

9. (6 points total) Let p, r, r, s, and v be strings such that the following conditions hold: (1) r is a prefix of p; (2) s is a suffix of r; (3) v is the length-(p r + s) suffix of p; (4) s v; (5) c(v) s; (6) r is the length-(r s + c(v)) prefix of p. (a) (3 points) Prove that r > r. (b) (3 points) Prove that s is a suffix of r. 7