2 Pages

hw1

Course: CS 223, Fall 2009
School: Yale
Rating:
 
 
 
 
 

Word Count: 622

Document Preview

223: CS Data Structures. Instructor: Jim Aspnes Homework One Due Friday, January 25th, 2002, at 5:00pm. Get an account Get an account on the Zoo. Instructions can be found on the Web in the CS 223 How To document, accessible off of the main Web page. Send me email Send me email! My address is aspnes@cs.yale.edu. Send me an email message with your full name, residential college (or department, if you are a...

Register Now

Unformatted Document Excerpt

Coursehero >> Connecticut >> Yale >> CS 223

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
223: CS Data Structures. Instructor: Jim Aspnes Homework One Due Friday, January 25th, 2002, at 5:00pm. Get an account Get an account on the Zoo. Instructions can be found on the Web in the CS 223 How To document, accessible off of the main Web page. Send me email Send me email! My address is aspnes@cs.yale.edu. Send me an email message with your full name, residential college (or department, if you are a graduate student), and your Zoo login name. Include a brief greeting or question if you want to. Remember: it's important that you be able to read mail at the account that you send your message from; among other things, it's where I'll send your password for Grade-o-Matic. Write a program Your task is to write a program that translates an obscure numbering system back into the standard Arabic numbers we all know and love. Each number is represented as a sequence of phrases separated by whitespace, and each phrase consists of either one or two positive numbers, also separated by whitespace. In a two-number phrase X Y, X must be strictly less than Y, and the value of the phrase is the product X*Y. The value of a one-number phrase X is just X. To compute the value of a sequence, first we group it into phrases by starting at the left and grouping each number X with its successor Y provided X is less than Y and X is not already part of a phrase. We then compute the value of each phrase and add them up. Some examples: Original sequence 1 2 3 4 5 2 1000 3 100 2 10 6 1 1 1 1 1 1 1 1 10 2 50 6 Phrases, marked with () (1 2) (3 4) 5 (2 1000) (3 100) (2 10) 6 1 1 1 1 1 1 1 1 10 (2 50) 6 Value 19 2327 7 116 Your task is to write a program number.c that reads a sequence of numbers from stdin, terminated by end-of-file, computes the value of this sequence according to the rules described above, and writes the value stdout, to followed by a newline. Your program should tolerate trailing whitespace in its input (such as a newline at the end of the sequence of numbers). Your program does not need to produce sensible outputs for empty inputs or inputs that contain characters other than whitespace and positive numbers, but should terminate normally in such cases (this means no infinite loops, bus errors, or similar catastrophes). You may assume that no value exceeds 231 - 1. Submit your program with /c/cs223/bin/submit 1 number.c. 1 Clarifications How do I send input to my program on stdin? If you are running your program from a terminal, just type at it. To send end-of-file, hit control-D at the start of a line. You can also create a file with a test input and redirect stdin to point to that file using the shell's redirection syntax, e.g., by running a command like: ./myprogram < test-input-file. How can I parse numbers in my input? We recommend using scanf, e.g. scanf("%u", &number). You can test the return value of scanf to detect end-of-file. Should I expect more than one sequence per file? No. The picture in the assignment is a little bit misleading in this respect; you do not need to detect anything but end of file to find the end of a sequence. For example, the following text is a perfectly legitimate input, which should cause your program to print the value 51: 1 2 3 4 5 6 7 What about non-integers in the input? program only needs to handle integers. This would be an error. Your Do I need to use an array to store the input? It is possible (and probably easier) to solve the problem without using an array. Is there any limit to how long the input can be? No. CS 223 home page: http://zoo.cs.yale.edu/classes/cs223/ Fri 03 May 2002 23:06:32 EDT hw1.tyx Copyright c 1998-2002 by Jim Aspnes 2
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington - CSSAP - 432
Final Project -1CSS 432 2000University of Washington - Bothell Department of Computing and Software SystemsSummerName_ Our final project for this quarter will explore the process of setting up a real world network. The Tulalip Indian Reservation will
Auburn - CS - 122
CS122 Algorithms and Data StructuresUses for Binary Trees. - Binary Search TreesUse for storing and retrieving information n Insert, delete, and search faster than with a linked list n Take advantage of logn height n Idea: Store information in an ordere
UGA - ACTIVITIES - 0607
Indonesia Name: Present Position: Previous Positions: Mr. Benny BUTAR-BUTAR National Editor, ANTARA News Agency News Coverage Coordinator, ANTARA News Agency, 2000-2004 Reporter, Economic Affairs, ANTARA News Agency, 1996-2000 Reporter, Social, Political
Messiah - STAT - 292
NAMESTA 292 - Statistics for the Mathematical Sciences IIExample Confidence Interval Problems 1. A community group recently conducted a study to see how long the residents of a certain city had lived at their current address. Based on twenty-eight rando
Tennessee - MICROSYS - 551
1996: The Year of the XC4000E!ts en OS m ve M ro M C p Im TL em ur 5 ct d 0. ite e ch anc Ar - Adv -ss ce o PrXC4000EThe Solution for Advanced Performance 50% Faster Than the XC4000 100% PCI Compliant Breakthrough Select-RAM TM memory 3,000 to 25,000
UVA - LAW - 0607
TO: FROM: SUBJECT:VIRGINIA READERS MITCH POLINSKY &quot;READING&quot; MY PAPER FOR THE SEMINAR ON OCTOBER 23RDAs you will see, this paper (&quot;Mandatory Versus Voluntary Disclosure of Product Risks&quot;) was written mainly for an economics audience and is fairly technic
Indiana State - CARBON - 106
Name _ Chem 106 1. 2. 3. 4. May 6, 2009 Final Exam (2 pts) Circle the molecules that have a permanent dipole moment. CH3OH NO He CH3CH3 HCN (2 pts) Circle the molecules that interact via hydrogen bonding, and cross out those that interact only by dispe
Penn State - ERE - 100
METBD 050 LOOK-UP FunctionsThe LOOK-UP function is used to &quot;look-up&quot; a value from a table placed in a range of cells. The two most common functions are VLOOKUP and HLOOKUP. VLOOKUP searches for a value in the leftmost column of a table, and then returns
Illinois State - COE - 081
C&amp;I 210: Child Growth and DevelopmentIllinois State University Spring 2008Instructor Dr. Alan Bates Office: DeGarmo 224 Phone: 438-5462 (office) E-mail: abates@ilstu.edu Office hours: Tuesdays and Thursdays, 8:009:00am &amp; 3:30- 4:30pm or anytime by appoi
GWU - CS - 195
SYSTEMS ANALYST ($45.00/HOUR) KEYWORDS: DESIGN; PLAN HANDLES ALL: LEADING OF DESIGN MEETINGS DESIGN WORK ESTIMATION (TIME &amp; COST) PRESENTATIONS KEEPS A VERY-DETAILED NOTEBOOK INPUT: HIGH-LEVEL SYSTEM SPEC. OUTPUT: DESIGN DOCUMENTS; TIME AND COST ESTIMA
uofl.edu - PA - 107
http:/discovermagazine.com/2008/nov/10-how-long-until-we-find-a-second-earth How Long Until We Find a Second Earth?Researchers are racing to find the first planet that might support life as we know it.by Robert Kunzigpublished online October 10, 2008
North Texas - MATH - 1200
World Regional GeographyGEOGRAPHY The study of place and space Studies the location and distribution of features on the Earths surface Earth Studies human activity, the natural environment, and the relationship between the two Answers where and whyWher
Miami University - AREA - 351
SPSS Advanced Models 15.0TMFor more information about SPSS software products, please visit our Web site at http:/www.spss.com or contact SPSS Inc. 233 South Wacker Drive, 11th Floor Chicago, IL 60606-6412 Tel: (312) 651-3000 Fax: (312) 651-3668 SPSS is
Maryland - LECTURE - 311
Carry lookaheadCan calculate carries in parallel Tradeoff: need more hardware (space vs. time) Boolean expression for carry-out: cout = \xycin + x\ycin + xy\cin + xycin What does this expression look like? z = \abc + a\bc + ab\c + abc How many inputs? 3
Maryland - LECTURE - 311
Combinational circuits: ALUALU is a combinational circuit outputs depend only on inputs operations performed AND OR ADD SUB SLT Zero (a = b) This is an ARITHMETIC/logic unit What about multiplication? Result depends only on inputs1 1 1 0 0(Fig. 4.21)1
Grinnell College - CS - 152
Fund. CS II (CS152 2004F)End-of-Course SurveyPlease take a few minutes to fill out this survey. Your comments will be valuable in helping to improve the course. These forms will not be read until after grades are assigned. Background a. How much time pe
Colby - BI - 235
PlantreproductionWide diversity among groups x Our focus will be on Angiosperms (flowering plants) x Many plants reproduce asexuallyx shoots from rootstocks parts that break off and form roots parts formed especially for reproduction (bulbs, etc.)Flow
Western Washington - BIOL - 102
Continuing Trends in Plant Evolution Reduction of water-dependent gametophyte Vascular tissue improved water/food transport More efficient roots, stems, leaves* Tissues * Stomates Green: all these are in sporophyteReduction of gametophyte Specializatio
Idaho - FSTMMBB - 417
SalmonellaTUESDAY, DECEMBER 2, 2008: TECRA uniQue Salmonella: Sample preparation and enrichment (35-37oC or 41-43oC for 1620 hours) 1. Food sample (Orange juice): 25 g (ml) per team; 5 x 25 g (ml) sample for the entire class 2. Sterile 25-ml pipettes 3.
U. Memphis - CE - 7166
Equivalent Axle LoadsMazda MiataCurb weight = 2300 lb1 dM = ( consumption per passage ) NMFord ExcursionCurb weight = 6300 lb1 dF = ( consumption per passage ) NFStandard VehicleCurb weight = 4000 lb1 dS = ( consumption per passage ) NSEquivalen
ECCD - CS - 134
Basic graphics in Java, without ProcessingThe text below describes standard Java AWT, but we recommend using Swing. See the documentation for Swing, or search in the API for the classes below with J as prefix (JFrame, JButton, etc.). All documentation fo
Rose-Hulman - ES - 204
ROSE-HULMAN INSTITUTE OF TECHNOLOGYDepartment of Mechanical EngineeringES 204 Mechanical SystemsExample Problem - Le 20Ex. The 6-lb, 3-ft rod AB is originally at rest and is hit by a 1-lb ball C traveling at 50ft/s at a distance d below the pin at A.
Yale - RP - 269
STATE MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHTRA MAHARASHT
RIT - IST - 409
409 Individual Midterm Project Grade Sheet for _ - do NOT use Director, Shockwave, Flash etc to embed media on the page - do NOT use PHP/mySQL or any other back-end solution/content management system - do NOT use tables for your design 1. Demonstrates pag
Iowa State - MATE - 271
www.mrs.org/publications/bulletinMATERIALS CHALLENGES FOR THE NEXT CENTURYMarket Drivers for Materials and Process Development in the 21st CenturyF.R. Field III, J.P. Clark, and M.F. AshbyEconomics has made us partners and necessity has made us allies
Berkeley - EE - 219
Caltech - GE - 128
THE ASTROPHYSICAL JOURNAL, 536 : 347356, 2000 June 10( 2000. The American Astronomical Society. All rights reserved. Printed in U.S.A.AN INVENTORY OF INTERSTELLAR ICES TOWARD THE EMBEDDED PROTOSTAR W33A1 E. L. GIBB,2,3 D. C. B. WHITTET,2,3 W. A. SCHUTTE
Cal Poly - CSC - 484
UserCenteredDesignand DevelopmentInstructor:FranzJ.KurfessComputerScienceDept. CalPolySanLuisObispoFJK 2005Copyright Notice These slides are a revised version of the originals provided with the book Interaction Design by Jennifer Preece, Yvonne Roger
ASU - AST - 113
AST 113 Fall 2008 Launching to Orbit LAUNCHING TO ORBIT What will you learn in this lab? This lab will touch on the basics of rocket science. You will learn to calculate just how much effort it takes to send something into orbit by figuring out how m
Oregon State - MTH - 437
MTH 437/537 1.HW #3Spring 2009ORBITING A BLACK HOLE A spaceship is moving without power in a circular orbit with radius r = 7m about a Schwarzschild black hole of mass m.(a) What is the period of the orbit as measured by an observer at inifinity? (b)
Washington University in St. Louis - CSE - 573
CSE 573S: Networking Protocols Overview Instructor: Manfred GeorgAcknowledgmentsMany slides are from Dina Katabi who stated:&quot;Some slides are from lectures by Nick Mckeown, Ion Stoica, Frans Kaashoek, Hari Balakrishnan, and Sam Madden&quot;Other slides are
Iowa State - NR - 71461
Powerful Tools for Caregivers Tasks and TimelineTask/Responsibility Put together a planning committee Meet with planning committee Share program overview Decide date, time and place Secure facility Discuss respite options for participants Identify potent
FIU - ENC - 1101
1 Inner Childhood&quot;What do you think is the first letter in the word `bunny'?&quot; I ask Jodi. &quot;E!&quot; he shouts proudly, picking the sound that sticks out the most. I do not know the questions to ask, the things to say that will breach the dam in his brain that
IUPUI - N - 341
1 N241: Introduction 2Javascript: Show Last Modified Date &amp; Time (showLastMod.js) 1/Create variables to store date objects 2var update = new Date(document.lastModified); 3var day = update.getDay(); 4var date = update.getDate(); 5var month = update.getMont
Michigan - SI - 609
Application: Market for EvaluationsSI 609 - Foundations 1996, Prof. Jeffrey K. MacKie-Mason11/21/961Evaluations How do you decide what movie to go to? Do you pay for advice? Why might an evaluation service be especially desirable on the Internet? S
UCCS - ECE - 3430
Department of Electrical and Computer Engineering ECE 3430 Fall 2000 HW#8 - Solutions 1, 2, 3, 4, 7, 8, 10(b), 15 form pages 422-423 of text. 1. a. b. c. d. 2. a. b. c. d. 3. a. b. c. d. 4. a. b. c. d. a. b. c. d. a. b. c. d. 2K block/1K chip = 2 chips 4M
Arizona - ANTH - 235
J Archaeol Method Theory (2007) 14:209216 DOI 10.1007/s10816-007-9034-4Doing Archaeology as a Feminist: IntroductionAlison WyliePublished online: 10 August 2007 # Springer Science + Business Media, LLC 2007Abstract Gender research archaeology has made
Maryland - CMSC - 828
Questions? Project #1 Grad projectSurvey One minute paper Task structure diagram How do I apply this knowledge Confirmation steps Survey (Thanks to Nick) Speak loader Participation Not presenting the chart in enough detail How to process the informa
UMass (Amherst) - PSYC - 643
Checklist for Critical Review 1. Theoretical Aspects * Is the topic interesting, important? * Is the literature adequately reviewed? * Are the hypotheses clearly stated? * Are the hypotheses well justified? Are they consistent with prior work? Do they fol
Michigan State University - ECON - 251
Economics 251H Fall 2006 Mike ConlinHW8SOLUTIONS 1. Consider the market for houses. Suppose there exist two different types of houses. Type S is a structural sound house and Type F is a structurally flawed house. There are sixty Type S houses and forty
UCF - EEL - 4768
EEL 4768 Computer System Design II Lecture 2 Von Neumann Model Prof. Taskin Kocak http:/www.cs.ucf.edu/~tkocak/eel4768.htmlComputer Organization (Von Neumann) The architecture of a computer system is what the user sees or has access to. The structure is
Ill. Chicago - EECS - 265
Comparison between Motorola 68HC11 assembly language and Intel 80X86 assembly language: Motorola -LDAA #5 LDAB #$AF ABA CLRA TAB TBA CLR Mem_Label STAA Mem_Label STAA $00DE LDX #Mem_Label LDX #Mem_Label STAA 0,X LDX #Mem_Label STAA 5,X LDD Mem_Label CPD M
Oregon - WRI - 121
Zach Hutsell Kunyosying Writing 121 21 January 2004 Essay 1.1 On Fear and Progress Walking through the streets of downtown San Francisco alone at night, I get scared. I can't help it. I can't help but think about the dark shadows of the alleys, the strang
Idaho - FSTMMBB - 417
Experiment 4: Sanitation Microbiology Background:Environmental sanitation in food plants is one of the most efficient methods of preventing the introduction of pathogenic microorganisms into finished food products. A good environmental sanitation program
Michigan State University - PHILL - 278
Is Napster going to be shut down forever? Ever since 1999, the year when Napster started, the music world has changed dramatically. People could now join this musiccommunity for free, and swap songs with friends, or millions of other clients on the netwo
Anderson University - PAST - 5440
1 David Aukerman Reading Reaction #1: A Lasting Promise PAST5440: Family Life Cycle and Pastoral Care February 1, 2005 This book appears at a significant moment in the span of my life, for just a month ago I became engaged to my fianc Tara whom I had date
University of Toronto - CSC - 165
Chapter 6Correctness, running time of programso fr we hve een proving sttements out dtsesD mthemtis nd rithmetiD or sequenes of numersF hough these types of sttements re ommon in omputer sieneD you9ll proly enounter lgorithms most of the timeF yften we
Penn State - INFSY - 554
Expert Systems with ApplicationsPERGAMONExpert Systems with Applications 17 (1999) 5170Neural networks in business: a survey of applications (19921998)A. Vellido a,*, P.J.G. Lisboa a, J. Vaughan baSchool of Computing and Mathematical Sciences, Liver
Acton School of Business - STAT - 310
a o cm o a 3@3Dm R o am o cm o c c o a 3D@3~3~m $3Dm o a o c Dm ~m R 8~m ~m oo a c a o a o c 3Dm ~m R 8~m oo m o am o a 3lx3Dm 3c o a o c ` 3Dm m o ~m V f 6 4 6 7 7 2 6 2 f f f 7 E B 2 6 C E 6 4 C G 7 V 7 q 6 4 k q 7 k 9 7 P E C 7 2 6 FHC8d7 5 ey6Xev h$0$
Michigan - P - 130
Name _ Physics 130 Astronomy Exam 2 October 22, 2004 Multiple Choice: 1. _ When light passes through a prism of glass a.) the different colors or wavelengths of light are separated in angle by the prism. b.) the different colors are caused by multiple ref
Broward College - IT - 20000430
4567!83)9) )4$;#,'&quot;)9.&lt;))!&quot;#$%&amp;'()*$&amp;+,'&quot;)-./) 0$1$2+$)3'#$+) ! :450)38754)) =&gt;8?@) A&lt;BC&lt;) ) 4D807)E5460!=7!83)8F)7D5)=08G&gt;5HI) 344!567!+89:74;87&lt;!59!3;59&quot;35=:3&amp;&gt;!87?;7&lt;5!&lt;35!3@4098!3:5! 57&lt;5!&lt;:987&lt;!A89&quot;!567!&lt;5357B!56787!387!+89C83&quot;!&lt;+7:=A=:35=9@&lt;! 3D
Penn State - HUT - 113
MATH 22 FINAL EXAM NUMBER DECEMBER 2005 TOR FORM A NUMBERNAME STUDENT1. Find the equation of the line that is perpendicular to 8y 7x = 4 and passes through (8, 0). 64 8 a) y = x + 7 7 b) y = 7 7 x+ 8 64INSTRUC-SECTION8 c) y = x + 4 7 d) y = e) y = 8
UPR Mayagüez - QUIM - 3041
6. THERMOCHEMISTRY Solutions to ExercisesNote on significant figures: If the final answer to a solution needs to be rounded off, it is given first with one nonsignificant figure, and the last significant figure is underlined. The final answer is then ro
NMT - PHYS - 122
xg r U t A Y F a A C C F S W F A F Q PDBI4RmXbHBhBTGIH$XIQRXbaIFItXwB r U F U UU W CUA F H r UU C S YA H FC F i C F C 4XH y ECuDRkEPpbCBXhuRmXRGTBX4I8R@XIH&amp;XRueUP7 @$shu8 yg rU t BTBI4RA IUvRmXTvBTISTge8#ISTBXRpG@PBXwBRgPTveUuGP 4h$a y F U U C A C H FC
CofC - RM - 205
Page 1/5Material Safety Data Sheetacc. to ISO/DIS 11014Printing date 07/01/2003 Reviewed on 07/01/20031 Identification of substance: Product details: Product name: MacConkey Broth Catalog number: 211397 Manufacturer/Supplier: BD Diagnostic Systems 7
South Carolina State University - PSC - 152
OverviewThe Inner PlanetsPSC 152In this section:What are the charcteristics of each planet? What are the common characteristics? How do these properties relate to each other?Major CharacteristicsWhat are the major characteristics of each of the inne
MO St. Louis - BIOL - 440
COMMON PLANTS OF LAKE MICHIGAN SAND DUNES The sand dunes occurring on the eastern and southern shores of Lake Michigan result from wind-blown sand deposited on the beach by wave action. The dunes vary in height from a few meters to approximately 50 m. Suc
MO St. Louis - BIOL - 440
Diversity of Galling Species Along Two Successional GradientsPrincipal Investigator: XXXXXXXX Sites: Indiana Dunes National Lakeshore, Indiana, and Mud Lake Nature Preserve, Michigan Key words: biodiversity, bog lakes, galls, insect-plant interaction, sa
UMass (Amherst) - LING - 610
== REPLIES TO SOME OF YOUR QUESTIONS and HUNCHES ROUND 3 Chris Potts, Ling 610: Semantics and Generative Grammar, Fall 2004 September 29, 2004==Mike: At the end of HK Ch. 3, they discuss the case of unaccusative vs. unergative verbs and how
Middlebury - B - 915
Middlebury College Womens Soccer Individual Records (1979-2008)SINGLE GAME* GOALS G T1. 4 T1. 4 T1. 4 9/12/01 Name Date Nora T. Weintraub 10/18/06 Ashley Pfaff 10/5/05 Leah Cumsky-Whitlock SINGLE SEASON GOALS G 1. 19 2. 16 T3. 13 T3. 13 T3. 13 Yr. 04 02
Los Angeles Southwest College - LAW - 200921
Memo to: From: Re: Date:Summer Term - Corporations Class Jim Burkhard First Class Assignment May 26, 2009Text:We will use the 2nd edition of Epstein, Freer, Roberts &amp; Shepherd, BUSINESS STRUCTURES You will also need a South Carolina statutory supplemen