AP Computer Science AB 2005 Scoring Guidelines

Similar documents
AP Computer Science A 2004 Scoring Commentary

AP Computer Science A 2003 Scoring Guidelines

AP Computer Science AB 2007 Free-Response Questions

AP Computer Science A 2008 Scoring Guidelines

AP Calculus BC 2009 Free-Response Questions Form B

AP Computer Science AB 2002 Free-Response Questions

AP Computer Science A

AP Computer Science. Peeking at Programming with JavaScript Student Guide. Martin Callaghan John Leggott College Scunthorpe, UK

----- o Implicit Differentiation ID: A. dy r.---; d 2 Y 2. If- = '" 1-y- then - = dx 'dx 2. a c. -1 d. -2 e.

Computer. Course Description

AP Computer Science A 2013 Free-Response Questions

AP Computer Science A

CS61BL Summer 2013 Midterm 2

AP Computer Science A

SCourse Description. Includes important information regarding the introduction of the language Java. MAY 2004, MAY 2005

Name CPTR246 Spring '17 (100 total points) Exam 3

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

182 review 1. Course Goals

Computer. Course Description. Computer Science AB. M a y , M a y

AP COMPUTER SCIENCE A 2006 SCORING GUIDELINES

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

Sample Questions for Midterm Exam 2

EXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

Java 1996 AP Computer Science Question 3

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2011

! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge

Chapter 20: Binary Trees

Points off Total off Net Score. CS 314 Final Exam Spring 2016

AP COMPUTER SCIENCE AB 2006 SCORING GUIDELINES

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge

AP Computer Science A

CS 216 Exam 1 Fall SOLUTION

STUDENT LESSON AB30 Binary Search Trees

Topic 10: The Java Collections Framework (and Iterators)

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

CS314 Exam 2 - Spring Suggested Solution and Criteria 1

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2011

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Prelim 2 Solutions. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

AP CALCULUS BC 2014 SCORING GUIDELINES

Also, recursive methods are usually declared private, and require a public non-recursive method to initiate them.

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

Introduction to Computing II (ITI 1121) Final Examination

COMP 103 Introduction to Data Structures and Algorithms

EXAMINATIONS 2010 END YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

Chief Reader Report on Student Responses:

AP COMPUTER SCIENCE AB 2007 SCORING GUIDELINES

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2010

Student Performance Q&A:

Model Solutions. COMP 103: Test May, 2013

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

AP COMPUTER SCIENCE AB 2008 SCORING GUIDELINES

a graph is a data structure made up of nodes in graph theory the links are normally called edges

Compsci 201 Binary Trees Recurrence Relations

SOLUTIONS. COMP103 Introduction to Data Structures and Algorithms

EXAMINATIONS 2016 TRIMESTER 2

CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008

AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES

Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.

Summer Final Exam Review Session August 5, 2009

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

COMP 250 Midterm #2 March 11 th 2013

Introduction to Computing II (ITI 1121) Final Examination

Final Exam. Name: Student ID: Section: Signature:

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

If you took your exam home last time, I will still regrade it if you want.

EXAMINATIONS 2005 END-YEAR. COMP 103 Introduction to Data Structures and Algorithms

Unit 9 Practice Test (AB27-30)

Student Performance Q&A:

Announcements HEAPS & PRIORITY QUEUES. Abstract vs concrete data structures. Concrete data structures. Abstract data structures

APCS :: Winter Quarter Exam Review Packet

CS171 Midterm Exam. October 29, Name:

CSE373 Fall 2013, Midterm Examination October 18, 2013

Programming II (CS300)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2018 TRIMESTER 2 COMP 103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

CONTAINS SOLUTIONS!!!

Prelim 2 SOLUTION. CS 2110, 16 November 2017, 7:30 PM Total Question Name Short Heaps Tree Collections Sorting Graph

Data Structures. Giri Narasimhan Office: ECS 254A Phone: x-3748

CMSC132, Practice Questions

EXAMINATIONS 2017 TRIMESTER 2

U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2018 TRIMESTER 2 COMP 103 PRACTICE EXAM

ITI Introduction to Computing II

HEAPS & PRIORITY QUEUES

Model Solutions. COMP 103: Mid-term Test. 21st of August, 2014

TREES Lecture 12 CS2110 Fall 2016

tree nonlinear Examples

ITI Introduction to Computing II

CS 302 ALGORITHMS AND DATA STRUCTURES

Announcements. CS18000: Problem Solving And Object-Oriented Programming

Title Description Participants Textbook

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

Trees. (Trees) Data Structures and Programming Spring / 28

Samples of Evidence to Satisfy the AP Computer Science AB Curricular Requirements

TREES Lecture 12 CS2110 Spring 2018

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28

ITI Introduction to Computing II

Transcription:

AP Computer Science AB 2005 Scoring Guidelines The College Board: Connecting Students to College Success The College Board is a not-for-profit membership association whose mission is to connect students to college success and opportunity. Founded in 1900, the association is composed of more than 4,700 schools, colleges, universities, and other educational organizations. Each year, the College Board serves over three and a half million students and their parents, 23,000 high schools, and 3,500 colleges through major programs and services in college admissions, guidance, assessment, financial aid, enrollment, and teaching and learning. Among its best-known programs are the SAT, the PSAT/NMSQT, and the Advanced Placement Program (AP ). The College Board is committed to the principles of excellence and equity, and that commitment is embodied in all of its programs, services, activities, and concerns. Copyright 2005 by College Board. All rights reserved. College Board, AP Central, APCD, Advanced Placement Program, AP, AP Vertical Teams, Pre-AP, SAT, and the acorn logo are registered trademarks of the College Entrance Examination Board. Admitted Class Evaluation Service, CollegeEd, Connect to college success, MyRoad, SAT Professional Development, SAT Readiness Program, and Setting the Cornerstones are trademarks owned by the College Entrance Examination Board. PSAT/NMSQT is a registered trademark of the College Entrance Examination Board and National Merit Scholarship Corporation. Other products and services may be trademarks of their respective owners. Permission to use copyrighted College Board materials may be requested online at: http://www.collegeboard.com/inquiry/cbpermit.html. Visit the College Board on the Web: www.collegeboard.com. AP Central is the official online home for the AP Program and Pre-AP: apcentral.collegeboard.com.

AP COMPUTER SCIENCE AB 2005 SCORING GUIDELINES 2005 AB Question 1: Salmon Part A: nextlocation 5 points +1/2 test if age < matureage +1/2 return super.nextlocation() if juvenile (no credit for reimplementation) +1 check neighboring locations +1/2 correctly call emptyneighbors() or neighborsof ex: environment().neighborsof(<location>) (must also call isempty) +1/2 reference all (N) neighbors (must not remove the location behind) +2 compare neighbor distance with current distance +1/2 get current location (lose this if reference inaccessible field) +1/2 attempt to identify closer location +1 correctly compare distances from present location using distancehome (may not (re)implement distancehome, must potentially test all possibilities) +1 return value +1/2 return any empty neighbor that is closer to home +1/2 return current location if none closer Part B: act 4 points +1 distinguish juvenile from mature +1/2 test if age < matureage +1/2 juvenile actions or mature actions, based on decision +1/2 juvenile action: move() +2 mature actions +1/2 test if location().equals(homelocation) (lose this if reference inaccessible field) +1/2 call breed() if and only if at homelocation +1/2 call die() if and only if breed() succeeds +1/2 call move() in context of homelocation test Note: Methods breed(), die()and move() may not be reimplemented, but equals() can be replaced by distancehome() or compareto() if done correctly. +1/2 increment age (after processing) Copyright 2005 by College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents). 2

AP COMPUTER SCIENCE AB 2005 SCORING GUIDELINES 2005 AB Question 2: Postal Codes Part A: efficiency 1 point +1/2 O (1) for getcitiesforcode +1/2 O (1) for addcitycodepair Part B: design 4 points +1 data structure +1/2 supports storing city names (list or set OK) +1/2 supports storing city codes mapping +1 initialization and declaration +1/2 attempt (new Map() OK) +1/2 correct (for data structures provided) (must be private) +1 explanation +1/2 describe how cities are stored +1/2 describe how codes are stored and mapped +1 addcitycodepair update +1/2 describe how cities are updated +1/2 describe how codes are updated (mapped) Part C: getcodesforcity efficiency 1 point +1 O(log N ) or better +1/2 data structure supports O(log N ) +1/2 explanation (must identify big-oh for structure used) Part D: printallcities 3 points +1 iterate and print all cities +1/2 attempt to iterate/traverse and print the cities +1/2 prints all, no dups (System.out.println(cityToCodeMap.keySet()); is OK) +1 cities printed in alphabetical order +1 ON ( ) efficiency (must iterate over data structure that contains cities) Copyright 2005 by College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents). 3

AP COMPUTER SCIENCE AB 2005 SCORING GUIDELINES 2005 AB Question 3: Successor Nodes Part A: verifyparentlinks 5 points +1/2 return true if empty +1/2 check parent link of root node is null +1 1/2 check parent link of at least one non-root node +1/2 attempt (call to getparent is enough) +1 correct relationship test +1 1/2 traversal +1/2 attempt (recursion or iteration) +1/2 traverse to bottom of tree somewhere +1/2 traverse every node +1 return correct boolean in all cases for non-empty trees Part B: successor 4 points +1 1/2 identify and handle case where successor is below t: +1/2 attempt (must test if t.getright()!= null and do something with the right subtree OR put in another data structure and look for successor of t) +1 return minimum node from right subtree, e.g., return minnode(t.getright()) +1 1/2 handle case where successor is above t: +1/2 attempt traversal (loop) above t e.g., up to parent OR down from root to t OR put in another data structure and look for successor of t +1 return successor node +1 in the case where there s no successor, return null Note: Must accept any correct solution, regardless of efficiency (e.g., can do inorder traversal, store nodes in a list, search for t, then get next entry). Note: equals method not redefined in TreeNode, so equivalent to == as long as the invoking object is not null Copyright 2005 by College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents). 4

AP COMPUTER SCIENCE AB 2005 SCORING GUIDELINES 2005 AB Question 4: Expand Aliases Part A: appendsettoqueue 3 points +2 iterate over set +1 attempt (must access set members) +1 correct +1 each item added to end of q no loop, no credit Part B: expandalias 6 points +1 instantiate set +1/2 attempt (new Set() OK) +1/2 correct +1/2 create queue* +1/2 enqueue alias or its expansion +1 access all items in queue +1/2 attempt (must access queue in body) +1/2 correct +1/2 get next alias/address (in context of loop) +2 process alias/address (in context of loop) +1/2 test whether alias or address +1/2 expand alias +1/2 store expansion +1/2 store address in set +1/2 return a set of addresses *Note: Alternative data structures for queue are acceptable. Usage: No penalty for use of enque for enqueue or deque for dequeue Copyright 2005 by College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents). 5

Workshop Exam Materials Canonical Solutions 2005 AP Computer Science AB Question 1 PART A: protected Location nextlocation() if (age < matureage) return super.nextlocation(); else Location currentloc = location(); int currentdistance = distancehome(currentloc); ArrayList posslocs = emptyneighbors(); for (int i = 0; i < posslocs.size(); i++) if (distancehome((location)posslocs.get(i)) < currentdistance) return (Location)possLocs.get(i); return currentloc; PART B: public void act() if (! isinenv() ) return; if (age >= matureage && location().equals(homelocation)) if ( breed() ) die(); else move(); age++; Copyright 2005 by College Entrance Examination Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for students and parents).

Workshop Exam Materials Canonical Solutions 2005 AP Computer Science AB Question 2 PART A: getcitiesforcode: O (1) addcitycodepair: O (1) PART B: private Map citytocodemap; public PostalCodeDB()... citytocodemap = new TreeMap(); citytocodemap will have cities for keys, and sets of codes for that city as corresponding value. addcitycodepair will need to similarly update citytocodemap (adding to the set of codes for that city, adding a city entry to the map if first occurrence). private Map citytocodemap; private Set cities; public PostalCodeDB()... citytocodemap = new HashMap(); cities = new TreeSet(); citytocodemap will have cities for keys, and sets of codes for that city as corresponding value. cities will store the city names. addcitycodepair will need to similarly update citytocodemap (adding to the set of codes for that city, adding a city entry to the map if first occurrence). For each new city, its name must be entered into cities. PART C: Since citytocodemap is a TreeMap, the get method is O(log N ). Since citytocodemap is a HashMap, the get method is O (1). PART D: public void printallcities() Set cities = citytocodemap.keyset(); Iterator iter = cities.iterator(); while (iter.hasnext()) System.out.println(iter.next()); OR public void printallcities() Set cities = citytocodemap.keyset(); System.out.println(cities); public void printallcities() Iterator iter = cities.iterator(); while (iter.hasnext()) System.out.println(iter.next()); OR public void printallcities() System.out.println(cities); Copyright 2005 by College Entrance Examination Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for students and parents).

Workshop Exam Materials Canonical Solutions 2005 AP Computer Science AB Question 3 PART A: private boolean verifyparentlinks() return verifyparent(root, null); private boolean verifyparent(treenode t, TreeNode parent) return (t == null (t.getparent() == parent && verifyparent(t.getleft(), t) && verifyparent(t.getright(), t))); OR private boolean verifyparentlinks() if (root == null) return true; if (root.getparent()!= null) return false; return verifychildren (root); private boolean verifychildren(treenode parent) if (parent == null) return true; if (parent.getleft()!= null && parent.getleft().getparent()!= parent) return false; if (parent.getright()!= null && parent.getright().getparent()!= parent) return false; return verifychildren(parent.getleft()) && verifychildren(parent.getright()); PART B: private TreeNode successor(treenode t) if (maxnode(root) == t) return null; if (t.getright()!= null) return minnode(t.getright()); while (t.getparent()!= null && t.getparent().getright() == t) t = t.getparent(); return t.getparent(); Copyright 2005 by College Entrance Examination Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for students and parents).

Workshop Exam Materials Canonical Solutions 2005 AP Computer Science AB Question 4 PART A: private void appendsettoqueue(set items, Queue q) Iterator iter = items.iterator(); while (iter.hasnext()) q.enqueue(iter.next()); PART B: public Set expandalias(string alias) Set expanded = new HashSet(); Queue partial = new ListQueue(); partial.enqueue(alias); while (!partial.empty()) String front = (String)partial.dequeue(); if (addressbook.containskey(front)) appendsettoqueue((set)addressbook.get(front), partial); else expanded.add(front); return expanded; Copyright 2005 by College Entrance Examination Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for students and parents).