10 Pages

rmi

Course: CS 6580, Fall 2009
School: CSU Mont. Bay
Rating:
 
 
 
 
 

Word Count: 1192

Document Preview

EXAMPLE Product.java ------------ import PRODUCT java.rmi.*; public interface Product extends Remote { String getDescription() throws RemoteException; } ProductClient.java ------------------ import java.rmi.*; import java.rmi.server.*; public class ProductClient { public static void main(String[] args) { System.setSecurityManager(new RMISecurityManager()); String ur1 =...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> CSU Mont. Bay >> CS 6580

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.
EXAMPLE Product.java ------------ import PRODUCT java.rmi.*; public interface Product extends Remote { String getDescription() throws RemoteException; } ProductClient.java ------------------ import java.rmi.*; import java.rmi.server.*; public class ProductClient { public static void main(String[] args) { System.setSecurityManager(new RMISecurityManager()); String ur1 = "rmi://localhost/"; try { Product c1 = (Product)Naming.lookup(ur1 + "toaster"); Product c2 = (Product)Naming.lookup(ur1 + "microwave"); System.out.println(c1.getDescription()); System.out.println(c2.getDescription()); } catch(Exception e) { System.out.println("Error " + e); } System.exit(0); } } ProductImpl.java ---------------- import java.rmi.*; import java.rmi.server.*; public class ProductImpl extends UnicastRemoteObject implements Product { public ProductImpl (String n) throws RemoteException { name = n; } public String getDescription() throws RemoteException { return "I am a " + name + ". Buy me!"; } private String name; } ProductServer.java ------------------ import java.rmi.*; import java.rmi.server.*; import sun.applet.*; public class ProductServer { public static void main(String args[]) { try { System.out.println ("Constructing server implementations..."); ProductImpl p1 = new ProductImpl("Blackwell Toaster"); ProductImpl p2 = new ProductImpl("ZapXpress Microwave Oven"); System.out.println ("Binding server implementations to registry..."); Naming.rebind("toaster", p1); Naming.rebind("microwave", p2); System.out.println ("Waiting for invocations from clients..."); } catch (Exception e) { System.out.println("Error: " + e); } } } client.policy ------------- grant { permission java.net.SocketPermission "*:1024-65535", "connect"; }; Product Program Compile and Run =============================== Script started on Mon Jul 21 20:02:57 2003 palazzo% javac *.java palazzo% rmic ProductImpl palazzo% ls Product.class ProductImpl.class ProductServer.class Product.java ProductImpl.java ProductServer.java ProductClient.class ProductImpl_Skel.class client.policy ProductClient.java ProductImpl_Stub.class product.run palazzo% rmiregistry& [1] 19350 palazzo% java ProductServer& [2] 19351 palazzo% Constructing server implementations... Binding server implementations to registry... Waiting for invocations from clients... palazzo% java -Djava.security.policy=client.policy ProductClient I am a Blackwell Toaster. Buy me! I am a ZapXpress Microwave Oven. Buy me! palazzo% date Mon Jul 21 20:05:18 PDT 2003 palazzo% script done on Mon Jul 21 20:05:28 2003 --------------------------------------------------------------------------- PRODUCER-CONSUMER MESSAGE EXAMPLE MessageQueue.java ----------------- import java.util.*; import java.rmi.*; public interface MessageQueue extends java.rmi.Remote { public void send (Object item) throws java.rmi.RemoteException; public Object receive() throws java.rmi.RemoteException; } MessageQueueImpl.java --------------------- import java.util.*; import java.rmi.*; public class MessageQueueImpl extends java.rmi.server.UnicastRemoteObject implements MessageQueue { public MessageQueueImpl() throws RemoteException { queue = new Vector(); } public synchronized void send(Object item) throws RemoteException { queue.addElement(item); System.out.println("Producer entered " + item + " size = " + queue.size()); } public synchronized Object receive() throws RemoteException { Object item; if (queue.size() == 0) return null; else { item = queue.firstElement(); queue.removeElementAt(0); System.out.println("Consumer removed " + item + " size = " + queue.size()); return item; } } public static void main (String args[]) { try { MessageQueue server = new MessageQueueImpl(); Naming.rebind("MessageServer", server); System.out.println("Server Bound"); } catch(Exception e) { System.err.println(e); } } private Vector queue; } Factory.java ------------ import java.util.*; import java.rmi.*; public class Factory { public Factory() { // remote object MessageQueue mailBox; System.setSecurityManager(new RMISecurityManager()); try { mailBox = (MessageQueue)Naming.lookup ("rmi://127.0.0.1/MessageServer"); Producer ProducerThread = new Producer(mailBox); Consumer ConsumerThread = new Consumer(mailBox); ProducerThread.start(); ConsumerThread.start(); } catch (Exception e) { System.err.println(e); } } public static void napping() { int sleepTime = (int)(NAP_TIME * Math.random()); try { Thread.sleep(sleepTime*1000); } catch (InterruptedException e) { } } public static void main(String args[]) { Factory client = new Factory(); } private static final int NAP_TIME = 5; } Producer.java ------------- import java.util.*; class Producer extends Thread { public Producer(MessageQueue m) { mbox = m; } public void run() { Date message; while (true) { Factory.napping(); message = new Date(); try { mbox.send(message); } catch (Exception e) { System.err.println(e); } } } private MessageQueue mbox; } Consumer.java ------------- import java.util.*; class Consumer extends Thread { public Consumer(MessageQueue m) { mbox = m; } public void run() { Date message; while (true) { Factory.napping(); try { message = (Date)mbox.receive(); if (message != null) { // consume the item ; } } catch (Exception e) { System.err.println(e); } } private } MessageQueue mbox; } client.policy ------------- grant { permission java.net.SocketPermission "*:1024-65535", "connect"; }; ---------------------------------------------------------------------------------- Message Program Compile and Run =============================== palazzo% javac *.java Consumer.class MessageQueueImpl.java Consumer.java MessageQueueImpl_Skel.class Factory.class MessageQueueImpl_Stub.class Factory.java Producer.class MessageQueue.class Producer.java MessageQueue.java show.run MessageQueueImpl.class palazzo% palazzo% rmic MessageQueueImpl palazzo% rmiregistry & [1] 11774 palazzo% java -Djava.security.policy=client.policy MessageQueueImpl& [2] 11782 palazzo% Server Bound palazzo% java -Djava.security.policy=client.policy Factory Producer entered Sat Feb 10 15:53:13 PST 2001 size = 1 Consumer removed Sat Feb 10 15:53:13 PST 2001 size = 0 Producer entered Sat Feb 10 15:53:16 PST 2001 size = 1 Consumer removed Sat Feb 10 15:53:16 PST 2001 size = 0 Producer entered Sat Feb 10 15:53:17 PST 2001 size = 1 ^Cpalazzo% palazzo% -------------------------------------------------------------------------- Bank ATM Example ---------------- // // ATM.java // import java.lang.*; import java.rmi.*; public interface ATM extends Remote { boolean searchpw (String pw) throws RemoteException; double deposit(int acc, double amount) throws RemoteException; double withdraw(int acc, double amount) throws RemoteException; double balance(int acc) throws RemoteException; } // // Server.java // import java.lang.*; import java.io.*; import java.net.*; import java.util.*; import java.rmi.*; import java.rmi.server.*; public class Server extends UnicastRemoteObject implements ATM { public static final int N=10; private boolean found; private String pw; private double accArr[]; private int i; public static void main(String [] args) { // System.setSecurityManager(new RMISecurityManager()); try { Server server=new Server(); Naming.rebind("ATM", server); System.out.println("ATM is ready..."); } catch (RemoteException re) { ... } catch (MalformedURLException me) { ... } public Server() throws RemoteException { super(); pw="888"; accArr=new double[N]; for(i=0; i<N; i++) accArr[i]=0; } public boolean searchpw (String pw) throws RemoteException { if(pw.equals(this.pw)) found=true; return found; } public synchronized double deposit(int accNum, double amount) throws RemoteException { System.out.println("Deposit "+amount+" to ACC: "+accNum); for(i=0; i<N; i++) { if(accNum>0&&accNum<11) { accArr[accNum-1]+=amount; System.out.println("ACC: "+accNum+"\tNew Bal: " + accArr[accNum-1]); System.out.println(); return accArr[accNum-1]; } } return -1; } public synchronized double withdraw(int accNum, double amount) throws RemoteException { .. } } // // Client.java // import java.lang.*; import java.io.*; import java.util.*; import java.rmi.*; import java.net.*; public class Client { private ATM atm; private String pw; private int acc1; private int acc2; private double amount; private double result1; private double result2; private boolean found; private char c; public static void main(String [] args) { System.setSecurityManager(new RMISecurityManager()); String stemp; if (args.length>0) stemp=args[0]; else stemp="localhost"; Client client=new Client(stemp); client.service(); } public Client(String server) { connect(server); } public void connect(String server) { try { String stemp; if (server.indexOf("//")>=0) stemp=server; else stemp="rmi://"+server+"/ATM"; atm=(ATM)Naming.lookup(stemp); } catch (RemoteException re) { System.err.println(re.getMessage()); } catch (NotBoundException ne) { System.err.println(ne.getMessage()); } catch (IOException ie) { System.err.println(ie.getMessage()); } } public void service() { try { BufferedReader stdin=new BufferedReader ( new InputStreamReader (System.in)); do { System.out.print("Please enter password: "); pw=stdin.readLine().trim(); found=atm.searchpw(pw); if(found) { while(true) { System.out.println("Transaction Types: D = Deposit\n" +"\t\t W = Withdraw\n" +"\t\t T = Transfer\n" +"\t\t B = Balance\n" +"\t\t Q = Quit"); System.out.println("Please enter your transaction:"); c=stdin.readLine().charAt(0); System.out.flush(); switch(c) { case 'D': System.out.print("Enter ACCNUM: "); acc1=Integer.parseInt(stdin.readLine().trim()); System.out.print("Enter amount: "); amount=Double.parseDouble(stdin.readLine().trim()); result1=atm.deposit(acc1, amount); if(result1>=0) System.out.println("ACC: "+acc1 +"\t\tNew Bal: "+result1); else System.out.println("ACC not found."); break; .... } } `} } while(!found); } catch (Exception e) {} } } client.policy file ------------------ grant { permission java.security.AllPermission; };
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:

CSU Mont. Bay - CS - 6580
PRODUCT EXAMPLEProduct.java-import java.rmi.*;public interface Product extends Remote{ String getDescription() throws RemoteException;}ProductClient.java-import java.rmi.*;import java.rmi.server.*;public class ProductClient{
CSU Mont. Bay - CS - 6580
/HelloInterface.javaimport java.rmi.Remote;public interface HelloInterface extends java.rmi.Remote { public void sayHello( String from ) throws java.rmi.RemoteException;}/HelloImpl.javaimport javax.rmi.PortableRemoteObject;public class
CSU Mont. Bay - CS - 6580
date.x-program DATE_PROG { version DATE_VERS { long BIN_DATE (void) = 1; string STR_DATE(long) =2; } = 1;} = 0x31234999;~client.c-#include &lt;stdio.h&gt;#include &lt;rpc/rpc.h&gt;#include
CSU Mont. Bay - CS - 6580
date.x-program DATE_PROG { version DATE_VERS { long BIN_DATE (void) = 1; string STR_DATE(long) =2; } = 1;} = 0x31234999;~client.c-#include &lt;stdio.h&gt;#include &lt;rpc/rpc.h&gt;#include
CSU Mont. Bay - CS - 6580
SERVER PROGRAM/* server.c - code for example server program that uses TCP */#ifndef unix#define WIN32#include &lt;windows.h&gt;#include &lt;winsock.h&gt;#else#define closesocket close#include &lt;sys/types.h&gt;#include &lt;sys/socket.h&gt;#include &lt;netinet/
CSU Mont. Bay - CS - 6580
DISTRIBUTED SYSTEMS Principles and ParadigmsSecond Edition ANDREW S. TANENBAUM MAARTEN VAN STEENChapter 6 SynchronizationTanenbaum &amp; Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved.
CSU Mont. Bay - CS - 6580
Distributed Systems: SynchronizationPart IGian Pietro PiccoDipartimento di Elettronica e Informazione Politecnico di Milano, Italypicco@elet.polimi.it http:/www.elet.polimi.it/~picco Presented by:Luca Mottolamottola@elet.polimi.itPolitecnico
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
UNIVERSITY OF WISCONSIN-STEVENS POINTClinical Field Experience ReportStudent_\)}517jJlL_Y;_?CJfi~4:_. Cooperating Teacher-11!~pJ-,Z2 ~Ul.[1l?1?:Z.-SChOOI/City-'J~bG'~.Y~'=~-/In; L!L~'pIijED11;J1I~L/J'1I; ;f5t711{elP~Subject/Grade LeveL
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
UNIVERSITY OF WISCONSIN STEVENS POINT Observation &amp; Proactive Evaluation Report-1 'I -lntern -Practicum -Total Practicum Hours Student eacher ~arne ;Tos~hC;ch;d/dDate 5#mbL? 17: 200,Cooperating Teacfpr-rSubjectIGrade Level N a m e of Work Wisce
Wisc Stevens Point - JSCHI - 388
University of Wisconsin - Stevens Point Student Tqching Summary Evaluation Report Teacher Candidate: Joseph J. Shielka Cooperating Teacher: Roger SchmidekeGrade/Subjeets Taught: Grades 7-11Severe Learning Disabilities, EmotionaVBehavid Disabilities
Wisc Stevens Point - JSCHI - 388
FILE NUMBm.72 MIDDLE CHILDHOOD to EAR73 EARLY ADOLESCEThe holder must be successfully 8RAL .DJSABILITIESofessional Development Plan as
Wisc Stevens Point - JSCHI - 388
Wisc Stevens Point - JSCHI - 388
Unlverslty of Wisconsin-Stevens PointCollege of Professional Studies School of Education - Graduate AdvisingStevens Point, WI 54481-3897 (7 15) 346-4403 FAX ( 7 1 5) 346-4846Education ' Health Promotion 8. Human Development Communicative Disorders
Wisc Stevens Point - JSCHI - 388
University of Wisconsin-Stevens PointCollege of Professional Studies School of EducationStevens Point,W 54481-3897 I(7 15) 346-4430 FAX (7 15) 346-4846Education Health Promotion &amp; Human Dwelopment Communicative Disorders Medical Technology He
Wisc Stevens Point - JSCHI - 388
UPenn - CIS - 610
Math 602, Fall 2002, HW 5, due 12/10/2002Part A AI) (Vector bundles) As usual, TOP is the category of topological spaces and k will be either the real or complex numbers. All vector spaces are to be finite dimensional. A vector space family over X,
University of Texas - I - 382
Intellectual PropertyISchool 2004 SciTech Reference Sources Nature of PropertyProperty can be bought, sold, rented, willed, inherited, or otherwise possessed. It can also be lost, found, stolen, or taxed. Property ownership entails many p
University of Texas - I - 382
Gray &amp; Proprietary LiteratureISchool 2004 Definition: Gray Lit Frankly, gray literature is an abstract concept because for every generalization there are exceptions. Most reference people just know it when they see it! After this lectur
University of Texas - I - 382
Standards and Specifications and Product InformationISchool 2004 Bit of vocabStandards SpecificationsCodes Regulations Rules Used interchangably Standards are where:All aspects of GovernmentIndustry/manufacturing Societypeople
Michigan State University - MURPH - 250
Alison M. Murphymurph250@msu.edu 327 Chesterfield Pkwy East Lansing, Mi 48823 60 Merwood Dr. Battle Creek, MI 49017Professional Goals: I hope to one day be a secondary physics and mathematics teacher. Education: 2006 Michigan State University, Eas
UPenn - V - 000411
UNIVERSITY of PENNSYLVANIATuesday, April 11, 2000 Volume 46 Number 28 www.upenn.edu/almanac/Drew Faust: Dean of Radcliffe Institute for Advanced StudyDr. Drew Gilpin Faust, the Annenberg Professor of History, has been named the first Dean of the
Wisc Stevens Point - EBRUH - 731
Pre-Evaluation LetterErinn Bruhnp. 1 of 6To the Parent/Guardian of DaisyI have been observing your daughter Daisy, a kindergartener in the local elementary school. In her classroom, there are twenty-two other students. The classroom is warm an
Wisc Stevens Point - EDU - 731
Title One ReadingErinn Bruhn Education 205 Spring 2006What is Title One Reading? Definition Who does this help?Where Did This Program Come From? Elementary and Secondary Act (ESEA)How Is This Program Funded? Congress SchoolsEvidence
SCAD - CA - 301
float wave_height(float direction, phase, freq, amplitude){return sin(direction + phase) * 2 * PI * freq) * amplitude;}displacement ren_wave1(float Km = 0.1, freq = 1.0, phase = 0){floathump = 0;pointn = normalize(N);if (s &gt; 0.3) &amp; (s &lt; 0.7)h
SCAD - CA - 301
float wave_height(float direction, phase, freq, amplitude){return sin(direction + phase) * 2 * PI * freq) * amplitude;}displacement ren_wave2(float Km = 0.1, freq = 1.0, phase = 0){floathump = 0;pointn = normalize(N);if (s &gt; 0.5 &amp; t &lt; 0.5) | (s
SCAD - CA - 301
float wave_height(float direction, phase, freq, amplitude){return sin(direction + phase) * 2 * PI * freq) * amplitude;}displacement ren_wave3(float Km = 0.1, freq = 1.0, phase = 0){floathump = 0;pointn = normalize(N);float rounding = 0.05;float ra
SCAD - CA - 301
float wave_height(float direction, phase, freq, amplitude){return sin(direction + phase) * 2 * PI * freq) * amplitude;}displacement ren_wave4(float Km = 0.1, freq = 1.0, phase = 0){floathump = 0;pointn = normalize(N);float rounding = 0.05;float ra
SCAD - CA - 301
displacement disp_shader_s1(float Km = 0.1){floathump = 0, i;pointn;n = normalize(N);for (i = 0.0; i &lt; 1.0; i = i + 0.1) {if (t &gt; i &amp; t &lt;= (i + 0.1) {hump = i;}}P = P - n * hump * Km;N = calculatenormal(P);}
SCAD - CA - 301
displacement disp_shader_s1(float Km = 0.1){floathump = 0;pointn;n = normalize(N);if (t &lt; 0.5) hump = t;else hump = 1 - t;P = P - n * hump * Km;N = calculatenormal(P);}
SCAD - CA - 301
displacement disp_shader_s1(float Km = 0.1){floathump = 0;pointn;n = normalize(N);if (s + t) &lt; 1.0) hump = 1.0;P = P - n * hump * Km;N = calculatenormal(P);}
SCAD - CA - 301
displacement disp_shader_s1(float Km = 0.1){floathump = 0, a;pointn;n = normalize(N);a = s + t;if (a &lt; 0.7 | a &gt; 1.3) hump = 1.0;P = P - n * hump * Km;N = calculatenormal(P);}
UPenn - STAT - 111
Day 17: Comparing Two MeansLast Time: We relaxed the assumption that we know the population standard deviation and looked at hypothesis tests and confidence intervals for the (unknown) mean of a population with unknown standard deviation. We saw th
UPenn - STAT - 111
1. In each situation below, is it reasonable to use a binomial distribution for the random variable X? Give reasons for your answer in each case. If X does have a binomial distribution, identify the parameters n and p if you can do so. (a) Roulette i
SCAD - VSFX - 319
Option &quot;searchpath&quot; &quot;shader&quot; &quot;@:H:/vsfx319/shaders&quot;Option &quot;searchpath&quot; &quot;texture&quot; &quot;H:/vsfx319/textures&quot;Display &quot;untitled&quot; &quot;it&quot; &quot;rgb&quot;Format 954 480 1#Format 427 240 1DepthOfField 5 1 7 #camera1,2##DepthOfField 11 .5 11 #camera3##DepthOfField 1
SCAD - VSFX - 319
Option &quot;searchpath&quot; &quot;shader&quot; &quot;@:H:/vsfx319/shaders&quot;Option &quot;searchpath&quot; &quot;texture&quot; &quot;H:/vsfx319/textures&quot;Display &quot;Quadrics&quot; &quot;framebuffer&quot; &quot;rgb&quot;Projection &quot;perspective&quot; &quot;fov&quot; 60Format 954 480 1DepthOfField 2.4 1 12# f-stop, constant 1, focal dista
Rutgers - CS - 107
CS107 Page 1Practice Questions for Final name _CS 107 Computing for Math and SciencePractice Questions for Final - Answers1 Sorting2 Suppose we are in the middle of doing a selection sort and the situation is as pictured below: | ==&gt; ignore
Rutgers - CS - 107
CS107 Page 1Exam 2 name _CS 107 Computing for Math and Science Spring, 2007Practice Exam 2 Do not sit near anyone you studied with. Do not start until everyone has an exam and the instructor tells you to begin. There are 4 pages in this e
Rutgers - CS - 107
CS107 Page 1Exam 2 name _CS 107 Computing for Math and Science Spring, 2007Practice Exam 2 with Answers Do not sit near anyone you studied with. Do not start until everyone has an exam and the instructor tells you to begin. There are 4 pa
Rutgers - CS - 107
CS107 Page 1Exam 2 name _CS 107 Computing for Math and Science Spring, 2007More Practice for Exam 21 The following code checks to see if any number in a vector is 0. If there is a 0, it sets the variable found0 to 1 (true), otherwise false. f
Rutgers - CS - 107
CS107 Page 1Exam 2 name _CS 107 Computing for Math and Science Spring, 2007More Practice for Exam 21 The following code checks to see if any number in a vector is 0. If there is a 0, it sets the variable found0 to 1 (true), otherwise false. f
Rutgers - CS - 107
CS107 Page 1Practice Exam 1 name _CS 107 Computing for Math and Science Spring 2007Practice Exam 1 Do not start until everyone has an exam and the instructor tells you to begin. There are 5 pages in this exam, including this one. Make sure
Rutgers - CS - 107
CS107 Page 1Practice Exam 1 name _CS 107 Computing for Math and Science Spring, 2007Practice Exam 1 with answersDo not start until everyone has an exam and the instructor tells you to begin. There are 5 pages in this exam, including this one.
SCAD - VSFX - 319
/* Shader description goes here */surfacemaya_pattern(floatKfb = 1,inv_circle_size = .03,black_circle_size = .01,repeats = 7,left_right = .5,up_down = .5;color stripe = color(0,0,1),background_color = color
Rutgers - CS - 107
CS107: Computing for Math and ScienceInstructor:Prof. Louis Steinberg office: Hill 401 email: lou@cs.rutgers.edu Office hours: by appointmentTAs: Tzvi Chumash Lu HanCS107, Prof. Steinberg, f06Lecture 011CS107: Computing for Math
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 04: Strings, indexing Means-endsCS107, Prof. Steinberg, S07 Lecture 041Assignment 1 Due Thursday Don't leave it for the last minuteCS107, Prof. Steinberg, S07Lecture 042FunctionsFunctio
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 05: booleans ifsCS107, Prof. Steinberg, S07 Lecture 051Assig. 2PostedCS107, Prof. Steinberg, S07Lecture 052Vectors of Numbers Sequence is called a &quot;vector&quot; [22+3 1 32] Square brackets,
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 06: IF and Nested IFCS107, Prof. Steinberg, S07Lecture 061Exam in one week First exam one week from tonight Normal class time NOT this classroom - room to be announced Topic list, practice
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 07: Boolean vectors Matrices LoopsCS107, Prof. Steinberg, f06 Lecture 071Exam I100 80 60 40 20 01 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39CS107, Prof. Steinberg, f06Lecture 0721
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 08: LoopsCS107, Prof. Steinberg, S07Lecture 081LoopsTo repeat the same lines of code over and over, use a for statementfor j = [1:5] disp(j) endCS107, Prof. Steinberg, S07Lecture 082Lo
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 09: Loops Proving programs correctCS107, Prof. Steinberg, s07 Lecture 0911+2+3+.+n1 4 5 2 3 5 3 2 5 4 1 5= n*(n+1)1 + 2 + . + n =n*(n+1)/2CS107, Prof. Steinberg, s07Lecture 092While Loop
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 10: Proving programs correctCS107, Prof. Steinberg, s07Lecture 101ExampleFind first character in line that is a vowel place = 1; while (place &lt;= length(line) &amp; line(place) ~=`a' &amp; line(place) ~=`
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 11: Functions as args &amp; values recursionCS107, Prof. Steinberg, S07 Lecture 111Using vectorsTo store data for later use, e.g. find all numbers above average The indices are not intrinsically mean
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 13: Multiple Recursive Calls Abstract Speed of AlgorithmsCS107, Prof. Steinberg, S07 Lecture 131Functions with Multiple Callsfunction foo fie1( ) fie2( ) fie3( )CS107, Prof. Steinberg, S07Lectur
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 14: SortingCS107, Prof. Steinberg, S07Lecture 141Review:Asymptotic ComplexityWe would like to make general statements about one algorithm being faster than another binary search is faster than
Rutgers - CS - 107
CS107: Computing for Math and ScienceLecture 15: Real NumbersCS107, Prof. Steinberg, f06Lecture 171Midterm statistics Max: 147 Min: 30 Average: 112.705 median 120CS107, Prof. Steinberg, f06Lecture 172Midterm StatisticCS107, Pr