1 / 10

Lynbrook Computer Science

Lynbrook Computer Science. Member Meeting, November 3, 2008. Upcoming Competitions. Thursday: TopCoder Single Round Match Fri-Mon (11/7-11/10): USACO November. Silicon Valley Code Camp. 117 different sessions Lots of different topics Java, .NET, UI Design, Web Programming, AJAX

perry
Download Presentation

Lynbrook Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lynbrook Computer Science Member Meeting, November 3, 2008

  2. Upcoming Competitions • Thursday: TopCoder Single Round Match • Fri-Mon (11/7-11/10): USACO November

  3. Silicon Valley Code Camp • 117 different sessions • Lots of different topics • Java, .NET, UI Design, Web Programming, AJAX • This Saturday-Sunday, at Foothill College • Free! • siliconvalley-codecamp.com

  4. Pasture Walk (From USACO Qual.) • N pastures (2-1000), numbered 1..N • Given connecting walkways and lengths • Find length of shortest path between given pastures. • Input:4 2 (4 pastures, 2 queries)2 1 2 (distance from 2 to 1 is 2)4 3 2 (distance from 2 to 1 is 2)1 4 3 (distance from 1 to 4 is 3)1 2 (query: distance from 1 to 2?)3 2 (query: distance from 3 to 2?)

  5. Depth-First Search • For each pasture, store all outgoing paths • From each node, try all outgoing paths, except the one we came from • Use recursion! • Note: Only 1 possible path! Pasture 1 Pasture 2 Pasture 3 Pasture 4

  6. Pseudo-code int query(int from, intdest, int source = -1) { for each path connected to pasture[start] { if (path.to == source) continue; // don’t go backwards if (path.to == dest) return path.dist; // we can see the goal int dist = query(path.to, dest, from); if (dist == -1) continue; // can’t reach goal with this path return dist + path.length; } return -1; // no valid path from this node }

  7. ACSL Practice • 1. Evaluate the following: • 01011 OR 10110 AND 11010 • 2. Consider the stack operations at the right. What is the result of the next pop? • 3. Suppose @ is a binary operator whose value is the larger of its operands. Evaluate the prefix expression: • + @ 2 3 @ 4 @ 2 5 push ‘a’ push ‘c’ push 's' push 'l' pop push 'u' pop pop push 's' push 'a' pop pop

  8. Problem 1 • 01011 OR 10110 = 11111 • 11111 AND 11010 = 11010 • Answer: 11010

  9. Problem 2 STEP push ‘a’ push ‘c’ push 's' push 'l' pop push 'u' pop pop push 's' push 'a' pop pop STACK a c a s c a l s c a s c a u s c a s c a c a s c a a s c a s c a c a Next pop: C

  10. Problem 3 • + @ 2 3 @ 4 @ 2 5 • @ 2 3 = 3 • @ 2 5 = 5 • + 3 @ 4 5 • @ 4 5 = 5 • + 3 5 • + 3 5 = 8 • Answer: 8

More Related