COS 226 Algorithms and Data Structures Fall Midterm

Similar documents
Recursive Mergesort. CSE 589 Applied Algorithms Spring Merging Pattern of Recursive Mergesort. Mergesort Call Tree. Reorder the Merging Steps

Basic Algorithms Overview

Sorting: Merge Sort. College of Computing & Information Technology King Abdulaziz University. CPCS-204 Data Structures I

Heap and Merge Sorts

CS 2104 Intro Problem Solving in Computer Science Test 1 READ THIS NOW!

TÜ Information Retrieval

Predictive Coding. CSE 390 Introduction to Data Compression Fall Entropy. Bad and Good Prediction. Which Context to Use? PPM

Smith Waterman Algorithm - Performance Analysis

Final Exam (PRACTICE-3) #3

Artificial Intelligence Prof. Deepak Khemani Department of Computer Science and Engineering Indian Institute of Technology, Madras

St. Elizabeth & Our Lady Of Lourdes Ministry Schedule from. November ~ December, 2017

Order-Planning Neural Text Generation from Structured Data

This report is organized in four sections. The first section discusses the sample design. The next

Torah Code Cluster Probabilities

occasions (2) occasions (5.5) occasions (10) occasions (15.5) occasions (22) occasions (28)

End of the year test day 2 #3

Gesture recognition with Kinect. Joakim Larsson

CONTEST SCORE REPORT SUMMARY FOR GRADES 6, 7, AND 8 Summary of Results 6th Grade Contests Math League

STUDENT MINISTRY NEWSLETTER. June Daily Cross

Laboratory Exercise Saratoga Springs Temple Site Locator

Biometrics Prof. Phalguni Gupta Department of Computer Science and Engineering Indian Institute of Technology, Kanpur. Lecture No.

2014 Suburban One Continental Championships

2013 Division III Sectional Wrestling Championships. February 15-16, 2013

The World Wide Web and the U.S. Political News Market: Online Appendices

Outline. Uninformed Search. Problem-solving by searching. Requirements for searching. Problem-solving by searching Uninformed search techniques

Excel Lesson 3 page 1 April 15

Semantic Entailment and Natural Deduction

Midterm Review Part 1 #4

Houghton Mifflin MATHEMATICS

Haibin Shu Founder and Principal Consultant. April 19, 2017

2013 NRC Regular Category BOROBUDUR SHRINE RESTORATION

INTERMEDIATE LOGIC Glossary of key terms

Artificial Intelligence: Valid Arguments and Proof Systems. Prof. Deepak Khemani. Department of Computer Science and Engineering

Identifying Anaphoric and Non- Anaphoric Noun Phrases to Improve Coreference Resolution

Brigham Young University Idaho FDREL 122: Book of Mormon (Alma 30 Moroni 10) Spring 2015

An Efficient Indexing Approach to Find Quranic Symbols in Large Texts

THE SERMON ON THE AMOUNT! The Commitment to Keep the Church Going!

Steady and Transient State Analysis of Gate Leakage Current in Nanoscale CMOS Logic Gates

9/7/2017. CS535 Big Data Fall 2017 Colorado State University Week 3 - B. FAQs. This material is built based on

Lazy Functional Programming for a survey

The Calvary. Volume 17 - Issue 2 February 2016

OPENRULES. Tutorial. Determine Patient Therapy. Decision Model. Open Source Business Decision Management System. Release 6.0

The paradox we re discussing today is not a single argument, but a family of arguments. Here s an example of this sort of argument:!

An old problem in Mycology. solved with simple Mathematics

REL 3148: RELIGION AND VIOLENCE Summer B 2016

Rock Valley Conference Fall 2016 All Conference Teams Football Name Position School Year First Team Offense

Georgia Quality Core Curriculum

Kripke s skeptical paradox

Surveying Prof. Bharat Lohani Department of Civil Engineering Indian Institute of Technology, Kanpur. Module - 7 Lecture - 3 Levelling and Contouring

APPENDIX C ADDITIONAL CALCULATIONS


Who wrote the Letter to the Hebrews? Data mining for detection of text authorship

PMS 356 BRANDMARK PMS 357 PMS 356 LOGOTYPE TRADEMARK LOGO BRAND STYLE GUIDE

Sociology Exam 1 Answer Key February 18, 2011

The performance of the Apriori-DHP algorithm with some alternative measures

REL 011: Religions of the World

2012 District 1 AAA Section 2

Swim-A-Thon: Wall of Fame

McDougal Littell High School Math Program. correlated to. Oregon Mathematics Grade-Level Standards

Church-Turing Thesis

Born Free and Equal? On the ethical consistency of animal equality summary Stijn Bruers

The Fixed Hebrew Calendar

Copyright 2012 Carlson, O Bryan & Joyner 47

+ _ + No mortal man can slay every dragon No mortal Dutchman can slay every dragon No mortal man can slay every animal No mortal man can decapitate

CMSC 341 Snow Day Chat March 14, 2017

Grade 6 Math Connects Suggested Course Outline for Schooling at Home

C228 Argumentation and Public Advocacy. Essay #2 Defense of a Propositional Value: Oppositional Research

Lesson 09 Notes. Machine Learning. Intro

ALEKS. Pairing Student LMS Accounts with ALEKS

RELIGION C 324 DOCTRINE & COVENANTS, SECTIONS 1-76

PRAYER TEAM with Church Online

How to secure the keyboard chain

HP-35s Calculator Program Cantilever Retaining Wall Design

Trees. Trees are everywhere. One of these is not a tree. Binary trees. Recursive data structures

Unification Task Force Survey Results

MTH 1825 Intermediate Algebra Online Syllabus Spring 2018

Against Monism. 1. Monism and pluralism. Theodore Sider

It is One Tailed F-test since the variance of treatment is expected to be large if the null hypothesis is rejected.

REL 4141, Fall 2013 RELIGION AND SOCIAL CHANGE

Team Scoring Summary

INTRODUCTION TO LOGIC 1 Sets, Relations, and Arguments

MTH 1825 Intermediate Algebra Online Syllabus Fall 2017

Philosophy 2: Introduction to Philosophy Section 2511, Room SOCS 205, 7:45-9:10am El Camino College Fall, 2014

Nassau BOCES IDW User Group Meeting January 15, 2013

Introduction to Philosophy: Knowledge and Reality

KIO Regional Directory Spring/Summer 2015

START GROUP WITH CONFESSION AND PRAYER

Pearlgate Twilight Meet #3

I. Plato s Republic. II. Descartes Meditations. The Criterion of Clarity and Distinctness and the Existence of God (Third Meditation)

Phil 341: Kierkegaard and Nietzsche. CSUN Spring, 2016 Prof. Robin M. Muller. Office: Sierra Tower 506

Coaches. Participants COACHES ROSTER 1/4/2016. All Cheerleaders. Tuesday - 6:30 PM. Division: Practice Night / Time: Practice Location:

New York Conference Church Dashboard User Guide

Application for curing ailments through mudra science

Supplement to Parent/Student Handbook Sacrament of Confirmation 2020

Religion 3000: Studying Religion: Theories and Methods Spring, 2015 T/Th, 2:00-3:15pm Hardin 235

Intel x86 Jump Instructions. Part 5. JMP address. Operations: Program Flow Control. Operations: Program Flow Control.

Externally Set Task Handbook 2018 / / /01/17

Agnostic KWIK learning and efficient approximate reinforcement learning

THE FIRST WORD. Fall 2018 Vol. 22. From your Pastor. Dear Members and Friends,

THE ST. JOHN NEWS July 2014

Transcription:

COS 226 Algorithms and Data Structures Fall 2005 Midterm This test has 6 questions worth a total of 50 points. You have 80 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet. 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 1 4 2 5 3 6 Sub 1 Sub 2 Total Name: Login ID: Precept: 1 12:30 Keith 3 3:30 Harlan 1

2 PRINCETON UNIVERSITY 1. 8 sorting algorithms. (8 points) The column on the left is the original input of strings to be sorted. The columns to the right are the contents at some intermediate step during one of the 8 sorting algorithms listed below. Match up each algorithm by writing its number under the corresponding column. Use each number exactly once. Jane Adam Anna Abby Will Adam Jada Abby Adam Abby Adam Alex Adam Cole Seth Alex Emma Adam Dave Adam Mary Cole Abby Alex Ryan Abby Ella Alex Erik Alex Jeff Dave Ella Anna Sean Anna Maya Anna Erin Anna Erik Erik Emma Adam Mark Cole Anna Cole Evan Cole Dave Erin Dave Dave Noah Dave Sara Dave Jack Dave Evan Evan Alex Erin Owen Erik Eric Ella Jada Ella Sean Jack Cole Emma Sara Evan Jane Emma Jane Emma Erin Jada Eric Ella Hart Erin Dave Eric Jeff Eric Jada Jane Jada Eric Joey Emma Luke Erik Mary Erik Jack Jeff Jack Erik Jack Ella Kyle Erin Noah Erin Noah Kyle Noah Evan Maya Eric Cole Evan Sean Evan Luke Luke Luke Luke Luke Hart Jake Luke Luke Hart Kyle Mary Kyle Kyle Kyle Jane Jeff Kyle Kyle Jack Owen Noah Owen Owen Mary Jeff Noah Owen Owen Jada Seth Owen Seth Seth Jeff Jada Seth Seth Seth Jake Cole Sean Sean Sean Eric Jack Leah Jada Cole Jane Alex Seth Evan Sara Alex Joey Josh Mary Alex Jeff Hart Abby Hart Hart Erin John Erik Hart Hart Joey Mark Anna Mark Mark Jada Josh Jack Mark Mark John Joey Ella Joey Joey Erik Jake Mark Joey Joey Josh Emma Emma Erik Will Emma Kyle Will Sean Emma Kyle Ella Eric Jeff Jeff Ella Luke Adam Noah Ella Leah Lily Hart Lily Lily Lily Lily Evan Lily Lily Lily Maya Jake Maya Maya Dave Leah Sean Maya Maya Luke Leah Joey Leah Leah Leah Mary Erin Leah Leah Mark Abby John Mary Mary Abby Mark Owen Jane Abby Mary Anna Josh Jane Jane Anna Maya John Jeff Anna Maya John Leah John John John Noah Ryan John John Noah Ryan Lily Ryan Ryan Evan Owen Hart Ryan Ryan Owen Josh Mark Josh Josh Josh Ryan Alex Josh Josh Ryan Jake Maya Jake Jake Jake Sean Mary Jake Jake Sara Sara Ryan Sara Noah Jane Seth Joey Sara Sara Sean Will Sara Will Jack Cole Sara Lily Will Will Seth Eric Will Erin Jada Adam Will Abby Jack Eric Will ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 0 (0) Original input (1) 3-way radix quicksort (2) Heap sort (3) Insertion sort (4) LSD radix sort (5) Mergesort (6) MSD radix sort (7) Quicksort (8) Selection sort (9) All of them

COS 226 MIDTERM, FALL 2005 3 2. Algorithm Properties. (10 points) Match up each worst-case quantity on the left with the best matching asymptotic value on the right. You may use a letter more than once. Max height of a binary heap with N items. Max height of red black tree with N items. Max function call stack depth to mergesort N items. Max number of probes to search for a key in a double hashing table with N key-value pairs. Max height of a WQUPC (weighted quick union with path compression) tree with N items. A. 1 B. log N C. log N D. N E. N 2

4 PRINCETON UNIVERSITY 3. Analysis of algorithms. (6 points) Each of the Java functions on the left take a string s as input, and returns its reverse. Choose the best matching asymptotic complexity (as a function of the string length N) bound on the right. Recall that concatenating two strings in Java takes time proportional to the sum of their lengths, and extracting a substring takes constant time. public static String reverse1(string s) { int N = s.length(); String reverse = ""; for (int i = 0; i < N; i++) reverse = s.charat(i) + reverse; return reverse; } public static String reverse2(string s) { int N = s.length(); if (N <= 1) return s; String left = s.substring(0, N/2); String right = s.substring(n/2, N); return reverse2(right) + reverse2(left); } A. log N B. N C. N log N D. N 2 E. 2 N public static String reverse3(string s) { int N = s.length(); char[] a = new char[n]; for (int i = 0; i < N; i++) a[i] = s.charat(n-i-1); return new String(a); }

COS 226 MIDTERM, FALL 2005 5 4. Priority queues. (8 points) Insert the following keys into an initially empty minimum-based binary heap. A L G O R I T H M Show the heap representation (the array) and the binary tree representation (the picture). Now perform a delete-the-minimum operation and show the resulting binary tree representation (the picture).

6 PRINCETON UNIVERSITY 5. Red-black trees. (8 points) Draw the top-down 2-3-4 tree that results when the keys A L G O R I T H M are inserted in that order into an initially empty tree, using the standard top-down algorithm. Then draw the corresponding red-black tree that is constructed by the standard top-down red-black tree algorithm.

COS 226 MIDTERM, FALL 2005 7 6. Longest common substring. (10 points) Your must find the longest (contiguous) substring that appears in both Tolstoy s War and Peace and Sedgewick s Algorithms in Java. How would you write a program to compute the answer as quickly as possible? Describe and justify your approach. Your solution will be graded on correctness, efficiency, and clarity.