diff --git a/Schrick-Noah_CS-6643_Lab-8.R b/Schrick-Noah_CS-6643_Lab-8.R index 81825cc..d49fc9c 100644 --- a/Schrick-Noah_CS-6643_Lab-8.R +++ b/Schrick-Noah_CS-6643_Lab-8.R @@ -47,5 +47,32 @@ h1n1.Bris.aa.sortedtable <-h1n1.Bris.aa.table[order(h1n1.Bris.aa.table)] names(h1n1.Bris.aa.sortedtable)<-aaa(names(h1n1.Bris.aa.sortedtable)) dotchart(h1n1.Bris.aa.sortedtable) paste(h1n1.Bris.aa.vec,collapse="",sep="") -# + + +#### Part B: Loop Recursion Warmup +calc.num.paths <- function(n,m){ + path_matrix <- matrix(1, nrow=m+1, ncol=n+1) + for (i in seq(2,m+1)){ + for (j in seq(2, n+1)){ + path_matrix[i,j] <- path_matrix[i-1,j] + path_matrix[i,j-1] + } + } + path_matrix[m+1,n+1] +} + +m <- 5 # row edges +n <- 5 # col edges +calc.num.paths(n,m) +factorial(n+m)/(factorial(n)*factorial(m)) + +m <- 5 # row edges +n <- 6 # col edges +calc.num.paths(n,m) +factorial(n+m)/(factorial(n)*factorial(m)) + +m <- 10 # row edges +n <- 10 # col edges +calc.num.paths(n,m) +factorial(n+m)/(factorial(n)*factorial(m)) + diff --git a/Schrick-Noah_CS-6643_Lab-8.doc b/Schrick-Noah_CS-6643_Lab-8.doc index f2d1236..548acc2 100644 Binary files a/Schrick-Noah_CS-6643_Lab-8.doc and b/Schrick-Noah_CS-6643_Lab-8.doc differ