# Prolog Assessed Exercise

Save this PDF as:

Size: px
Start display at page:

## Transcription

2 explanatory comment to each. Note that you will implement the mergelists/3 predicate in the next step of the assessed exercise. msorttriples([],[]). msorttriples([a],[a]). msorttriples([a,b Rest],S) :- divide([a,b Rest],L1,L2), msorttriples(l1,s1), msorttriples(l2,s2), mergelists(s1,s2,s). divide([],[],[]). divide([a],[a],[]). divide([a,b R], [A Ra], [B Rb]) :- divide(r,ra,rb). 2.3 Merge sort s list merging predicate Write a predicate mergelists(+x,+y,-z) that takes two lists of triples that have already been sorted, X and Y, and unifies Z with a list that selects all of the elements from X and Y such that Z is also sorted. Include some test cases for the mergelists/3 predicate. Show that your predicate can generate values of Z as well as check that provided values are correct. Now that you have defined mergelists/3, you should include some test cases for the msorttriples/2 predicates in your source file also. 2.4 List replacement We return to the triples discussed at the beginning of this document. As the Bellman-Ford algorithm runs, we store triples for the node distances that we know about. Any node not included in the triple list is unreachable (i.e. has an infinite shortest path cost). When we find a new minimum distance to a node, we want to lower the known distance to it, or to add it to the triple list if that node is not yet present. Write a predicate addreplace(+find,+replace,+inlist,-outlist) that tries to unify Find with each element of InList. If it succeeds, it replaces the corresponding element in OutList with Replace. If no elements of InList unify with Find, then OutList should be unified with a list containing all of the elements of InList, as well as a new element Replace. It can be assumed that only one replacement needs to be made. 3 Representing Graphs We shall encode the graph that we wish to analyse as a list of edges. Each edge consists of a compound term Src-Dest-Dist where Src is the source node, Dest is the destination node and Dist is the edge cost between the nodes. Write a predicate graph(example,-list) which unifies List with the list that represents the graph in figure 1. We use the additional argument example to allow us to run our program with different graphs later. You may assume that in any graph there is at most one edge between any two particular nodes. 2

3 Figure 1: An example graph 3.1 Start Nodes Write a rule nodes(+graph,-nodes) that unifies Nodes with a list that contains the name of each node in the graph once. Remember that a node can be at the start or the end of an edge in your graph representation. One approach to do this is to construct the nodes/2 predicate from these auxiliary rules: unroll, which builds a list (containing duplicates) of all the nodes in the graph; unique, which removes duplicates from a list. Hint: use negation, and the built-in member(e,l) function which is true if E is an element of L. Now write a rule node(+graph,-node) that unifies Node with a node in the graph. This rule should iterate through all nodes in the graph when backtracking but should only return each node once. 4 The Bellman-Ford algorithm The Bellman-Ford algorithm for finding shortest paths from a single node is described in detail in the Algorithms II course. Students might also choose to consult Wikipedia 2, and decide to view the various Java applet visualisers available on the web 3. Here we show most of a basic implementation in Prolog. Copy this code into your source file and add comments to explain the purpose and operation of each predicate. [Aside: Note that some of the predicates below have very similar structure to each other. As in functional languages, a fold left predicate can be defined and used to factor out this sort of similarity, but you are not required or expected to do so.] bellmanford_inner(graph,initialvertexdata,mindists):- nodes(graph,[_ Vs]), relaxedgesrepeatedly(vs,graph,initialvertexdata,mindists). relaxedgesrepeatedly([],_,vdata,vdata). relaxedgesrepeatedly([_ Vs],Edges,VData,NewVData):- relaxedges(edges,vdata,nextvdata), relaxedgesrepeatedly(vs,edges,nextvdata,newvdata) e.g. 3

4 Figure 2: A graph with negative edge weights relaxedges([],x,x). relaxedges([e Es],VData,NewVData):- relax(e,vdata,nextvdata), relaxedges(es,nextvdata,newvdata). relax(a-b-w,vdata,nextvdata):- member(a+adist+_,vdata), RelaxedDist is ADist + W, relaxable(b,vdata,relaxeddist),!, addreplace(b+_+_,b+relaxeddist+a,vdata,nextvdata). relax(_,vdata,vdata). relaxable(b,vdata,relaxeddist):- member(b+bdist+_,vdata),!, RelaxedDist < BDist. relaxable(_,_,_). Add an additional predicate bellmanford(+graph,+start,-mindist) that calculates the minimum distances from the node Start by querying the bellmanford_inner predicate. Hint: you need to decide on a suitable value for the initial vertex data. Include a few simple tests for your implementation. You must demonstrate that the algorithm is correct when there are multiple paths to the same node; there are loops in the graph; and some nodes are unreachable from the start node. 4.1 Negative edge cycles The Bellman-Ford algorithm will correctly handle graphs that include negative edge weights, provided that they do not contain a negative cycle (i.e. a cycle whose edges weights sum is negative). However note that for graphs that have only non-negative edge weights, Dijkstra s shortest path algorithm will usually be more efficient. Encode the second example graph, as shown in figure 2 in the predicate graph(example2,-list). Note that you may need to put in extra parentheses (or equivalent) to avoid the parser becoming confused about negative weights and the - compound terms. For example, a hypothetical edge from c to d with weight -3 could use the syntax: c-d-(-3)). Copy your graph(example2,-list) predicate to an graph(example3,-list) predicate. In your example3 graph, change the edge weight b-d-8 to be b-d-2: this will create a negative cycle in the graph. Modify your bellmanford predicate so that it unifies the minimum distances term with the atom negative_cycle when it detects a negative cycle in the graph. 4

5 4.2 Reverse shortest paths Recall that the preceding node on the shortest path was recorded as part of each triple. Write a predicate rshortestpath(+graph,+startnode,+finishnode,-path) that unifies Path with the list of nodes in reverse order along the shortest path from StartNode to FinishNode. As much as possible you should make use of predicates that you have already written to perform this task. 5 Test Cases Append the following test clauses to your file: test(name,start) :- graph(name,g), node(g,start), bellmanford(g,start,l), msorttriples(l,lsorted), mincost(name,start,lsorted). test(name) :- findall(s,test(name,s),l), sort(l,lsort), graphnodes(name,lsort). mincost(example,a,[a+0+_, c+1+_, b+3+_, d+4+_, g+4+_, i+6+_, j+8+_, h+9+_, e+10+_, f+12+_]). mincost(example,b,[b+0+_, d+1+_, i+3+_, j+5+_, h+6+_, e+7+_, c+12+_]). mincost(example,c,[c+0+_, b+2+_, d+3+_, i+5+_, j+7+_, h+8+_, e+9+_]). mincost(example,d,[d+0+_, i+2+_, j+4+_, h+5+_, e+6+_, c+11+_, b+13+_]). mincost(example,e,[e+0+_, j+4+_]). mincost(example,f,[f+0+_, g+2+_, a+3+_, c+4+_, b+6+_, d+7+_, i+9+_, j+11+_, h+12+_, e+13+_]). mincost(example,g,[g+0+_, a+1+_, c+2+_, b+4+_, d+5+_, i+7+_, j+9+_, h+10+_, e+11+_, f+13+_]). mincost(example,h,[h+0+_, e+1+_, i+4+_, j+5+_, c+13+_, b+15+_, d+16+_]). mincost(example,i,[i+0+_, h+3+_, e+4+_, j+8+_, c+9+_, b+11+_, d+12+_]). mincost(example,j,[j+0+_, e+4+_]). mincost(example2,a,[e+(-2)+_,a+0+_,b+2+_,c+4+_,d+7+_]). mincost(example2,b,[e+(-4)+_,a+(-2)+_,b+0+_,c+2+_,d+5+_]). mincost(example2,c,[e+(-6)+_,a+(-4)+_,b+(-2)+_,c+0+_,d+3+_]). mincost(example2,d,[e+(-9)+_,a+(-7)+_,b+(-5)+_,c+(-3)+_,d+0+_]). mincost(example2,e,[e+0+_,a+2+_,b+4+_,c+6+_,d+9+_]). graphnodes(example,[a,b,c,d,e,f,g,h,i,j]). graphnodes(example2,[a,b,c,d,e]). :- test(example). :- test(example2). :- graph(example3,g),bellmanford(g,b,negative_cycle). Prolog will reply Yes to the test/1 predicates if the solutions returned by your implementation are correct for the chosen graph. 6 Deliverables and Deadlines You should submit a single Prolog source file named CRSID-prolog08.pl (replace CRSID with your CRSID). This file should contain all the clauses above along with appropriate tests. The file should compile 5

### Homework 2 Solutions

CS3510 Design & Analysis of Algorithms Section A Homework 2 Solutions Released: 3pm, Friday, Oct 13, 2017 This homework has a total of 4 problems on 3 pages. Solutions should be submitted to GradeScope

### Chapter 6. Predefined Predicates

Advanced Logic Programming https://sewiki.iai.uni-bonn.de/teaching/lectures/alp/2017/ Chapter 6. Predefined Predicates Updated: 12 June, 2017 Reorganized entire chapter Input and output Exception handling

### CS350: Data Structures Dijkstra s Shortest Path Alg.

Dijkstra s Shortest Path Alg. James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Shortest Path Algorithms Several different shortest path algorithms exist

### Data Structure and Algorithm Homework #5 Due: 2:00pm, Thursday, May 31, 2012 TA === Homework submission instructions ===

Data Structure and Algorithm Homework #5 Due: 2:00pm, Thursday, May 1, 2012 TA email: dsa1@csie.ntu.edu.tw === Homework submission instructions === For Problem 1, submit your source code, a shell script

### 3 Lists. List Operations (I)

3 Lists. List Operations (I) The list is the simplest yet the most useful Prolog structure. A list is a sequence of any number of objects. Example 3.1: L = [1, 2, 3], R = [a, b, c], T = [john, marry, tim,

### CSCI 3155: Lab Assignment 6

CSCI 3155: Lab Assignment 6 Fall 2012: Due Saturday, December 1, 2012 Unlike the last few labs, our primary focus in the lab is not new language features. Instead, we will explore some related topics that

### ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

1 Introduction CIS335, Assignment 4 Advanced Prolog Programming Geraint Wiggins November 12, 2004 This practical is the second self-assessed exercise for MSc students on the Prolog module. It is intended

### CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

CSE 250 Final Exam Fall 2013 Time: 3 hours. Dec 11, 2013 Total points: 100 14 pages Please use the space provided for each question, and the back of the page if you need to. Please do not use any extra

### CSc 451, Spring 2003 Examination #1 February 25, 2003 READ THIS FIRST

Name: CSc 451, Spring 2003 Examination #1 February 25, 2003 READ THIS FIRST Fill in your name above. Do not turn this page until you are told to begin. DO NOT use your own paper. If you run out of room,

### CS 314 Final Fall 2011

Points off 1 2A 2B 2C 3 4 5 Total off Net Score CS 314 Final Fall 2011 Your Name_ Your UTEID Instructions: 1. There are 5 questions on this test. 2. You have 3 hours to complete the test. 3. You may not

### APCS Semester #1 Final Exam Practice Problems

Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

### CSE Qualifying Exam, Spring February 2, 2008

CSE Qualifying Exam, Spring 2008 February 2, 2008 Architecture 1. You are building a system around a processor with in-order execution that runs at 1.1 GHz and has a CPI of 0.7 excluding memory accesses.

### Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 B

Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 B Last name (printed): First name (printed): Directions: a) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN. b) You have 80 minutes

### Exercises on the Fundamentals of Prolog

1 Introduction Exercises on the Fundamentals of Prolog These exercises are intended to help reinforce material taught in the lectures of CIS335 course in Prolog. They do not contribute any marks to the

### 1 Dijkstra s Algorithm

Lecture 11 Dijkstra s Algorithm Scribes: Himanshu Bhandoh (2015), Virginia Williams, and Date: November 1, 2017 Anthony Kim (2016), G. Valiant (2017), M. Wootters (2017) (Adapted from Virginia Williams

### Assignment 1. Due Tuesday October 11 at 11pm. No late assignments will be accepted. What to do

University of Toronto Mississauga CSC 324 - Principles of Programming Languages, Fall 2016 Assignment 1 Due Tuesday October 11 at 11pm. No late assignments will be accepted. What to do The questions below

### Lecture 19 Shortest Path vs Spanning Tree Max-Flow Problem. October 25, 2009

Shortest Path vs Spanning Tree Max-Flow Problem October 25, 2009 Outline Lecture 19 Undirected Network Illustration of the difference between the shortest path tree and the spanning tree Modeling Dilemma:

### Logic Programming and Resolution Lecture notes for INF3170/4171

Logic Programming and Resolution Lecture notes for INF3170/4171 Leif Harald Karlsen Autumn 2015 1 Introduction This note will explain the connection between logic and computer programming using Horn Clauses

### Project 5 - The Meta-Circular Evaluator

MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring Semester, 2005 Project 5 - The Meta-Circular

### CSCI 3155: Lab Assignment 6

CSCI 3155: Lab Assignment 6 Fall 2015: due Saturday, December 5, 2015 Unlike the last few labs, our primary focus in the lab is not new language features. Instead, we will explore some related topics that

### CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator Due on Thursday, 05 March, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI 187 / Spring 2015

### Project 5 - The Meta-Circular Evaluator

MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 2005 Project 5 - The Meta-Circular

### 2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

1. T F: Consider a directed graph G = (V, E) and a vertex s V. Suppose that for all v V, there exists a directed path in G from s to v. Suppose that a DFS is run on G, starting from s. Then, true or false:

### CS 360: Programming Languages Lecture 10: Logic Programming with Prolog

CS 360: Programming Languages Lecture 10: Logic Programming with Prolog Geoffrey Mainland Drexel University Section 1 Administrivia Midterm Tuesday Midterm is Tuesday, February 14! Study guide is on the

### Combining Lists & Built-in Predicates

Combining Lists & Built-in Predicates Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 6 11/10/04 11/10/04 AIPP Lecture 6: Built-in Predicates 1 Collecting Results Last time we

### CSc 372, Fall 2006; Quiz 1 Time: 3:00; Value: 2 points. 1. What is a fundamental difference between the if-then-else constructs in Java (or C) and ML?

CSc 372, Fall 2006; Quiz 1 Time: 3:00; Value: 2 points 1. What is a fundamental difference between the if-then-else constructs in Java (or C) and ML? 2. True or false: The val declaration is used to create

### Lecture 2: Routing algorithms

DD490 p4 0 Lecture : Routing algorithms Shortest path, Widest path, and constrained routing Olof Hagsand KTH CSC This lecture contains new material for 0. Graphs vs networks Algorithms are usually defined

### CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14

CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14 1 Depth first search 1.1 The Algorithm Besides breadth first search, which we saw in class in relation to Dijkstra s algorithm, there is one

### Routing Protocols and the IP Layer

Routing Protocols and the IP Layer CS244A Review Session 2/0/08 Ben Nham Derived from slides by: Paul Tarjan Martin Casado Ari Greenberg Functions of a router Forwarding Determine the correct egress port

### 6.006 Introduction to Algorithms Spring 2008

MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Introduction to Algorithms:

### Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 A

Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 A Last name (printed): First name (printed): Directions: a) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN. b) You have 80 minutes

### Problem Set 4: Streams and Lazy Evaluation

Due Friday, March 24 Computer Science (1)21b (Spring Term, 2017) Structure and Interpretation of Computer Programs Problem Set 4: Streams and Lazy Evaluation Reading Assignment: Chapter 3, Section 3.5.

### Programming in C. Lecture 9: Tooling. Dr Neel Krishnaswami. Michaelmas Term

Programming in C Lecture 9: Tooling Dr Neel Krishnaswami Michaelmas Term 2017-2018 1 / 24 Undefined and Unspecified Behaviour 2 / 24 Undefined and Unspecified Behaviour We have seen that C is an unsafe

### Laboratory Assignment #3. Extending scull, a char pseudo-device

Laboratory Assignment #3 Extending scull, a char pseudo-device Value: (See the Grading section of the Syllabus.) Due Date and Time: (See the Course Calendar.) Summary: This is your first exercise that

### COMP 303 MIPS Processor Design Project 3: Simple Execution Loop

COMP 303 MIPS Processor Design Project 3: Simple Execution Loop Due date: November 20, 23:59 Overview: In the first three projects for COMP 303, you will design and implement a subset of the MIPS32 architecture

### 2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION In the previous chapter, we introduced binary numbers and binary arithmetic. As you saw in binary arithmetic and in the handling of floating-point numbers, there is

### Shortest Path Problem

Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths

### CS261: Problem Set #2

CS261: Problem Set #2 Due by 11:59 PM on Tuesday, February 9, 2016 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. (2) Submission instructions:

### Computer lab information. TAOP24, Advanced course on optimization

Linkping University April 26, 2017 Department of Mathematics Division of Optimization Oleg Burdakov Computer lab information TAOP24, Advanced course on optimization 1 General information Three computer

### Topological Sort. Here a topological sort would label A with 1, B and C with 2 and 3, and D with 4.

Topological Sort The goal of a topological sort is given a list of items with dependencies, (ie. item 5 must be completed before item 3, etc.) to produce an ordering of the items that satisfies the given

### PROgramming in LOGic PROLOG Recursion, Lists & Predicates

PROgramming in LOGic PROLOG Recursion, Lists & Predicates CSC9Y4 1 Recursion Recursion in Prolog means placing in the body of a rule a call to the predicate which occurs in the head of the rule. Here is

### x-fast and y-fast Tries

x-fast and y-fast Tries Outline for Today Bitwise Tries A simple ordered dictionary for integers. x-fast Tries Tries + Hashing y-fast Tries Tries + Hashing + Subdivision + Balanced Trees + Amortization

### Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu

### Object Oriented Programming

Object Oriented Programming Java lecture (10.1) Exception Handling 1 Outline Exception Handling Mechanisms Exception handling fundamentals Exception Types Uncaught exceptions Try and catch Multiple catch

### Projects for Advanced Functional Programming 2015

Projects for Advanced Functional Programming 2015 Deadline: 11th January 2016, 23:59 General For this part of the course, you are encouraged to work in groups of two doing pair programming. Each group

### BSc Computing CSY2026 Modern Networks. Module Tutor: Signed:

Division of Computing BSc Computing CSY2026 Modern Networks Date of Issue: 17/02/2017 Date for Submission: 28/04 2017 (23:59 by e-submission) Agreed Date for late submission: Student Name: Student ID:

### CS447-Network and Data Communication Project #2 Specification, Fall 2017 Due December 5, 2017

CS447-Network and Data Communication Project #2 Specification, Fall 2017 Due December 5, 2017 1. Introduction In this project, we will develop a Sliding-Window flow-control (SWFC) simulator using C/C++

### CSE 333 Midterm Exam 2/14/14

Name There are 4 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed

### Computer Science 1 Ah

UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00

### High Institute of Computer Science & Information Technology Term : 1 st. El-Shorouk Academy Acad. Year : 2013 / Year : 2 nd

El-Shorouk Academy Acad. Year : 2013 / 2014 High Institute of Computer Science & Information Technology Term : 1 st Year : 2 nd Computer Science Department Object Oriented Programming Section (1) Arrays

### Design of Digital Circuits ( L) ETH Zürich, Spring 2017

Name: Student ID: Final Examination Design of Digital Circuits (252-0028-00L) ETH Zürich, Spring 2017 Professors Onur Mutlu and Srdjan Capkun Problem 1 (70 Points): Problem 2 (50 Points): Problem 3 (40

Operating Systems Deadlocks Deadlocks Example: two processes want to scan a document, and then save it on a CD P0 down(scanner); down(cd_writer); scan_and_record(); up(cd_writer); up(scanner); P1 down(cd_writer);

### Shortest Paths. Shortest Path. Applications. CSE 680 Prof. Roger Crawfis. Given a weighted directed graph, one common problem is finding the shortest

Shortest Path Introduction to Algorithms Shortest Paths CS 60 Prof. Roger Crawfis Given a weighted directed graph, one common problem is finding the shortest path between two given vertices Recall that

### CS 360: Programming Languages Lecture 12: More Haskell

CS 360: Programming Languages Lecture 12: More Haskell Geoffrey Mainland Drexel University Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia Administrivia Homework 5 due

### CMSC 331 Final Exam Section 0201 December 18, 2000

CMSC 331 Final Exam Section 0201 December 18, 2000 Name: nswers Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points

### External Memory Algorithms and Data Structures Fall Project 3 A GIS system

External Memory Algorithms and Data Structures Fall 2003 1 Project 3 A GIS system GSB/RF November 17, 2003 1 Introduction The goal of this project is to implement a rudimentary Geographical Information

### Mathematics Masters Examination

Mathematics Masters Examination OPTION 4 March 30, 2004 COMPUTER SCIENCE 2 5 PM NOTE: Any student whose answers require clarification may be required to submit to an oral examination. Each of the fourteen

### CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,

### The Assignment is divided into preparation, practical part, and documentation.

EINTE LAB EXERCISES LAB EXERCISE #4 IGP ROUTING PURPOSE AND GOALS This lab assignment will give you a hands-on experience in configuring and managing routers and particularly in setting up IP routing protocols.

### CS251 Programming Languages Handout # 29 Prof. Lyn Turbak March 7, 2007 Wellesley College

CS5 Programming Languages Handout # 9 Prof. Lyn Turbak March, 00 Wellesley College Postfix: A Simple Stack Language Several exercises and examples in this course will involve the Postfix mini-language.

### Solution to CSE 250 Final Exam

Solution to CSE 250 Final Exam Fall 2013 Time: 3 hours. December 13, 2013 Total points: 100 14 pages Please use the space provided for each question, and the back of the page if you need to. Please do

### CSCI 3155: Lab Assignment 2

CSCI 3155: Lab Assignment 2 Fall 2017 Checkpoint due Friday, September 15, 2017 Assignment due Friday, September 22, 2017 Learning Goals. The primary learning goals of this lab are to understand the following:

### Warm-up and Memoization

CSE341 Spring 05 Due Wednesday, May 11 Assignment 4 Part I Warm-up and Memoization Warm-up As a warm-up, write the following Scheme functions: 1. Write the function foldl of the form (foldl func initial

### CHAPTER 13 GRAPH ALGORITHMS

CHAPTER 13 GRAPH ALGORITHMS SFO LAX ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 00) AND SLIDES FROM NANCY

### Comparison of Single Source Shortest Path Algorithms using C#

[214] Comparison of Single Source Shortest Path s using C# Swati Vishnoi 1, Hina Hashmi 2 1,2 CCSIT, TMU, Moradabad 1 swativishnoi1@gmail.com 2 hinahashmi17@gmail.com Abstract Many applications like transportation

### UNIVERSITY OF MANITOBA. SIGNATURE: (in ink) (I understand that cheating is a serious offense)

DATE: Nov. 21, 2013 NAME: (Print in ink) STUDENT NUMBER: SIGNATURE: (in ink) (I understand that cheating is a serious offense) INSTRUCTIONS TO STUDENTS: This is a 90 minute exam. Cearly show all necessary

### Title. Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis. Nesrine Damak. Fakultät für Informatik TU München. 20.

Title Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis Nesrine Damak Fakultät für Informatik TU München 20. September 2010 Nesrine Damak: Classical Shortest-Path Algorithms 1/ 35

### Check the entries in the home directory again with an ls command and then change to the java directory:

MODULE 1p - A Directory for Java Files FIRST TASK Log in to PWF Linux and check the files in your home directory with an ls command. Create a directory for your Java files: c207@pccl504:~> mkdir java Move

### Com S 227 Assignment Submission HOWTO

Com S 227 Assignment Submission HOWTO This document provides detailed instructions on: 1. How to submit an assignment via Canvas and check it 3. How to examine the contents of a zip file 3. How to create

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

Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2016 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.

### Prelim 2 SOLUTION. 5:30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs

Prelim 2 SOLUTION 5:30 PM, 25 April 2017 1 2 3 4 5 6 Total Question Name Short Search/ Collections Trees Graphs answer sort stuff Max 1 26 18 15 20 20 100 Score Grader 1. Name (1 point) Write your name

### LAB: WHILE LOOPS IN C++

LAB: WHILE LOOPS IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2014 VERSION 4.0 PALMS MODULE 2 LAB: WHILE LOOPS IN C++ 2 Introduction This lab will provide students with an introduction

### CS 556 Spring 2017 Project 3 Study of Cryptographic Techniques

CS 556 Spring 2017 Project 3 Study of Cryptographic Techniques Project Due Dates: Part A: Due before class on CANVAS by Thursday, March 23, 2017 Part B: Due before class on CANVAS by Thursday April 6,

### Postfix Notation is a notation in which the operator follows its operands in the expression (e.g ).

Assignment 5 Introduction For this assignment, you will write classes to evaluate arithmetic expressions represented as text. For example, the string "1 2 ( * 4)" would evaluate to 15. This process will

### The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

The Shortest Path Problem jla,jc@imm.dtu.dk Department of Management Engineering Technical University of Denmark The Shortest Path Problem Given a directed network G = (V,E,w) for which the underlying

### VERSION Lab 3: Link Layer

Lab 3: Link Layer Objective In this lab, you will investigate Ethernet and the ARP protocol. You will also prove you are a Wireshark Ninja by dissecting an unknown protocol. Knowledge from Lecture 20 and

### Introduction to the Module Management System (MMS)

Student User Guide Introduction to the Module Management System (MMS) Revised Sept 2009 (Version 4) University of St Andrews Table of Contents 1 Introduction...3 1.1 MMS...3 1.2 Accessing the system...3

### Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Module 6 Knowledge Representation and Logic (First Order Logic) 6.1 Instructional Objective Students should understand the advantages of first order logic as a knowledge representation language Students

### Remaining Enhanced Labs

Here are some announcements regarding the end of the semester, and the specifications for the last Enhanced Labs. Don t forget that you need to take the Common Final Examination on Saturday, May 5, from

### This is an individual assignment and carries 100% of the final CPS 1000 grade.

CPS 1000 Assignment This is an individual assignment and carries 100% of the final CPS 1000 grade. Important instructions (read carefully and thoroughly): The firm submission deadline is Friday 5 th February

### Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Lecture 10 February 5 th, 2016 Abstract types: sets Lecture notes: Chapter 10 What is the value of this expresssion? let f (x:bool) (y:int) : int = if x then

Table of Contents Introduction... 1-2 A Brief History of Python... 1-3 Python Versions... 1-4 Installing Python... 1-5 Environment Variables... 1-6 Executing Python from the Command Line... 1-7 IDLE...

### Dijkstra s algorithm for shortest paths when no edges have negative weight.

Lecture 14 Graph Algorithms II 14.1 Overview In this lecture we begin with one more algorithm for the shortest path problem, Dijkstra s algorithm. We then will see how the basic approach of this algorithm

### INTRODUCTION AND PREPARATIONS BEFORE THE START: The Boundaries and the Size of each required paragraph in the Submission Form:

INTRODUCTION AND PREPARATIONS BEFORE THE START: The Submission Process in the award consist of six parts for category 1 to 4 and five parts for category 5, and must be completed in order to grant that

### 8/27/2016. ECE 120: Introduction to Computing. Graphical Illustration of Modular Arithmetic. Representations Must be Unambiguous

University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Signed Integers and 2 s Complement Strategy: Use Common Hardware for Two Representations

### February 24, :52 World Scientific Book - 9in x 6in soltys alg. Chapter 3. Greedy Algorithms

Chapter 3 Greedy Algorithms Greedy algorithms are algorithms prone to instant gratification. Without looking too far ahead, at each step they make a locally optimum choice, with the hope that it will lead

### Chapter Seven: Regular Expressions

Chapter Seven: Regular Expressions Regular Expressions We have seen that DFAs and NFAs have equal definitional power. It turns out that regular expressions also have exactly that same definitional power:

### Minimum Spanning Tree

Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we

### Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Greedy Algorithms Due: Start of your next lab session

Computer Science 385 Design and Analysis of Algorithms Siena College Spring 2017 Lab 8: Greedy Algorithms Due: Start of your next lab session You will be assigned groups of size 2 or 3 for this lab. Only

### American Association for Laboratory Accreditation

R311 - Specific Requirements: Federal Risk and Authorization Management Program Page 1 of 10 R311 - Specific Requirements: Federal Risk and Authorization Management Program 2017 by A2LA. All rights reserved.

### STADS-VIP. Quick guide - Register results online at Aarhus University

STADS-VIP Quick guide - Register results online at Aarhus University Registering results in STADS-VIP - Quick guide Contents How to register results short overview... 2 Access the system... 2 Registration

### Step-by-step. Young Enterprise: Entries. Interchange. guide. Making entries for Young Enterprise qualifications via Interchange

Log into Making entries for Young Enterprise qualifications via A step-by-step for centres a h c r e t n I o t e m o c l e W 1 Log into This demonstrates how to make entries for Young Enterprise qualifications

### Assignment 1: PostgreSQL Buffer Manager

UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division Assignment 1 Prof. Joe Hellerstein Dr. Minos Garofalakis Assignment 1: PostgreSQL 8.0.3 Buffer Manager In the

### Lab 1 The Alarm Clock (Threads and Semaphores)

Exercises and Labs Lab 1 The Alarm Clock (Threads and Semaphores) Exercise session - preparation In this exercise you will design a real-time system for an alarm clock application using threads, semaphores

### These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.

CSE 591 HW Sketch Sample Solutions These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. Problem 1 (a) Any

Exam information 77 students took the exam. Scores ranged from 6 to 30, with a median of 23 and an average of 22.2. There were 42 scores between 23 and 30, 22 between 16 and 22, and 10 between 6 and 15.