L YNBROOK C OMPUTER S CIENCE Member Meeting, November 3, 2008.

Slides:



Advertisements
Similar presentations
L YNBROOK C OMPUTER S CIENCE Member Meeting, November 10, 2008.
Advertisements

Chapter 4 Computation Bjarne Stroustrup
9-Jun-14 Enum s (and a review of switch statements)
Traffic assignment.
Coloring Warm-Up. A graph is 2-colorable iff it has no odd length cycles 1: If G has an odd-length cycle then G is not 2- colorable Proof: Let v 0, …,
§3 The Stack ADT 1. ADT A stack is a Last-In-First-Out (LIFO) list, that is, an ordered list in which insertions and deletions are.
Recursion CS 367 – Introduction to Data Structures.
CS252: Systems Programming Ninghui Li Program Interview Questions.
Stacks & Their Applications COP Stacks  A stack is a data structure that stores information arranged like a stack.  We have seen stacks before.
Arithmetic Expressions Infix form –operand operator operand 2+3 or a+b –Need precedence rules –May use parentheses 4*(3+5) or a*(b+c)
Breadth-First and Depth-First Search
Recursion B.Ramamurthy Chapter 4. Ramamurthy Introduction  Recursion is one of most powerful methods of solution available to computer scientists. 
CSC 331: Algorithm Analysis Paths in Graphs. The DFS algorithm we gave is recursive. DFS generates a search tree showing paths from one vertex to all.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
Stacks. What is a stack? A stack is a Last In, First Out (LIFO) data structure Anything added to the stack goes on the “top” of the stack Anything removed.
1 Stacks Stack Applications Evaluating Postfix Expressions Introduction to Project 2 Reading: L&C Section 3.2,
Stack: Linked List Implementation Push and pop at the head of the list New nodes should be inserted at the front of the list, so that they become the top.
) Number ) Operator ) Number (7 + (3 * (4 + 4) * 2 * 2 * (1 + 2) ) * 3) OperatorOperands Stacks Using Two Stacks to Evaluate a Simple Arithmetic Expression.
Binary Trees. Node structure Data A data field and two pointers, left and right.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
1 Chapter 18 Trees Objective To learn general trees and recursion binary trees and recursion tree traversal.
Digital Electronics Data Structures LISP
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
Graph Search Computing 2 COMP s1. P ROBLEMS ON G RAPHS What kinds of problems do we want to solve on/via graphs? Is there a simple path from A to.
OPERATOR PRECEDENCE PARSING
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 5 Prepared by İnanç TAHRALI.
Chapter 10-A Trees Modified
Computer Science Club It is easier to change the specification to fit the program than vice versa.
Topic 1Topic 2Topic 3Topic 4Topic
Data Structures and Algorithm Analysis Trees Lecturer: Jing Liu Homepage:
A grammar for arithmetic expressions involving the four basic operators and parenthesized expressions. Parenthesized expressions have the highest precedence.
EC-211 DATA STRUCTURES LECTURE 8. STACK APPLICATIONS Infix, Prefix, and Postfix Expressions Example – Infix: A+B – Prefix: +AB – Postfix: AB+
Procedures – Generating the Code Lecture 21 Mon, Apr 4, 2005.
For more notes and topics VISIT: IMPLEMENTATION OF STACKS eITnotes.com.
Basic Data Structures Stacks. A collection of objects Objects can be inserted into or removed from the collection at one end (top) First-in-last-out.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Where’s the title? You gotta search for it!. PotW Solution String s = new Scanner(System.in).next(); int[] prev = new int[s.length() * 2 + 2]; Arrays.fill(prev,
AL-HUSEEN BIN TALAL UNIVERSITY College of Engineering Department of Computer Engineering Algorithms and Data Structures Binary Tree Course No.:
1 Trees General Trees  Nonrecursive definition: a tree consists of a set of nodes and a set of directed edges that connect pairs of nodes.
Stacks Linear list. One end is called top. Other end is called bottom. Additions to and removals from the top end only.
1 Trees General Trees  Nonrecursive definition: a tree consists of a set of nodes and a set of directed edges that connect pairs of nodes.
Review Graph Directed Graph Undirected Graph Sub-Graph Spanning Sub-Graph Degree of a Vertex Weighted Graph Elementary and Simple Path Link List Representation.
MEMORY REPRESENTATION OF STACKS
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Data Structures Interview / VIVA Questions and Answers
STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures.
Visit for more Learning Resources
PART II STACK APPLICATIONS
CSC 172– Data Structures and Algorithms
COMPUTER 2430 Object Oriented Programming and Data Structures I
Depth First Search—Backtracking
CS212: Data Structures and Algorithms
Stacks, Queues, and Deques
Binary Tree Traversals
COMPUTER 2430 Object Oriented Programming and Data Structures I
Data Structures and Algorithm Analysis Trees
Stack Applications Lecture 29 Thu, Apr 5, /23/2019
Queue Applications Lecture 31 Mon, Apr 9, 2007.
Stacks.
Milestone 3: Finding Routes
Stack Applications Lecture 29 Thu, Apr 1, /29/2019 Stacks.
105-1 Data Structure Homework 1
Queues Lecture 30 Fri, Apr 2, /3/2019 Queues.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
Trees Trees are a very useful data structure. Many different kinds of trees are used in Computer Science. We shall study just a few of these.
OPERATOR GRAMMAR No Ɛ-transition. No two adjacent non-terminals. Eg.
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

L YNBROOK C OMPUTER S CIENCE Member Meeting, November 3, 2008

U PCOMING C OMPETITIONS Thursday: TopCoder Single Round Match Fri-Mon (11/7-11/10): USACO November

S ILICON V ALLEY C ODE C AMP 117 different sessions Lots of different topics Java,.NET, UI Design, Web Programming, AJAX This Saturday-Sunday, at Foothill College Free! siliconvalley-codecamp.com

P ASTURE W ALK (F ROM USACO Q UAL.) 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) (distance from 2 to 1 is 2) (distance from 2 to 1 is 2) (distance from 1 to 4 is 3) 1 2 (query: distance from 1 to 2?) 3 2 (query: distance from 3 to 2?)

D EPTH -F IRST S EARCH 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 4 Pasture 3

P SEUDO - CODE int query(int from, int dest, int source = -1) { for each path connected to pasture[start] { if (path.to == source) continue; // dont 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; // cant reach goal with this path return dist + path.length; } return -1; // no valid path from this node }

ACSL P RACTICE 1. Evaluate the following: OR AND Consider the stack operations at the right. What is the result of the next pop? 3. is a binary operator whose value is the larger of its operands. Evaluate the prefix expression: push a push c push 's' push 'l' pop push 'u' pop push 's' push 'a' pop

P ROBLEM OR = AND = Answer: 11010

P ROBLEM 2 STEP push a push c push 's' push 'l' pop push 'u' pop push 's' push 'a' 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

P ROBLEM = 2 5 = = = 8 Answer: 8