Computer Science I
Dr. Tom Hicks - Trinity University - CSCI 1320  -  Spring 2021 - Tentative Schedule - 9:55 TT

All Labs/Assignments Are Due The Next Class Period Unless Specified Otherwise!

# Topic(s) Reading Assignments
 & Handouts
Laboratory Assignment


# 1

1/26

TU


 Introduction To Class
Discuss Course Outline

Chapter 1

Computer Science
Computer Programming
Designing, Writing, Testing Debugging, Maintaining
CS Salaries
CS - Young Science
Charles Babbage
Ada Lovelace
Alan Turing - Turing Award
Alonzo Church - Lamda Calculus
Eniac
Software
BIOS Software
Operating Systems
Hardware
Motherboard, Processor, Cooling Fan,
Machine Language
Processor Cycles
Binary Digits (0,1) - Bit
Processor Instruction Set
Voltage
Transistors
von Neumann Architecture
Memory
Bus
 Machine Language
Processor Cycles
Binary Digits (0,1) - Bit
Processor Instruction Set
Voltage
Transistors
von Neumann Architecture
Memory
Bus
Assembly Language
Assembler
Compilers
High-Level Languages
Scala
Interpreter
Scala - Java Virtual Machine
Scala Portability
Scala Multiplatform
Martin Odersky - Creator Scala
Scala - open source
Programming Paradigms
Imperative Paradigm
Functional Paradigm
Object Oriented Paradigm
Scala - Hybrid Language
Basic Integer Operations
Integer Division
math.pow(2,3) - Exponentiation
Int - Integer Variables
Double - Double Variables
Order Of Operations - Correct
Modulus
REPL - Read-Evaluate-Print-Loop
Numeric Literal - 0,5,3
res0 - result0
Strings - String Variables
Line Comments //
Block Comments /*   */
val vs. var ??
String Concatenation +
print & println
Int - +/- 2 billion - 4 bytes
var - variable - can be changed
val - constant - no change
Double - decimal numbers
double - float - not exact

 Course Outline

PCS1-Ch-1A-Intro-Scala-Slides

Read Chapter 1

Transferring-Files-Into-My-Mars-DropBox-From-Linux.pdf

Transferring-Files-Into-My-Mars-DropBox-From-Win.pdf

Transferring-Files-Into-My-Mars-DropBox-From-Mac.pdf

CH-1A-Intro-To-CS-Scala-HW.zip


# 2

1/28

TH


Chapter 2

Machine Language
Processor Cycles
Binary Digits (0,1) - Bit
Processor Instruction Set
Voltage
Transistors
von Neumann Architecture
Memory
Bus
Assembly Language
Assembler
Compilers
High-Level Languages
Scala
Interpreter
Scala - Java Virtual Machine
Scala Portability
Scala Multiplatform
Martin Odersky - Creator Scala
Scala - open source
Programming Paradigms
Imperative Paradigm
Functional Paradigm
Object Oriented Paradigm
Scala - Hybrid Language
Basic Integer Operations
Integer Division
math.pow(2,3) - Exponentiation
Int - Integer Variables
Double - Double Variables
Order Of Operations - Correct
Modulus
REPL - Read-Evaluate-Print-Loop
Numeric Literal - 0,5,3
res0 - result0
Strings - String Variables
Line Comments //
Block Comments /*   */
val vs. var ??
String Concatenation +
print & println
Int - +/- 2 billion - 4 bytes
var - variable - can be changed
val - constant - no change
Double - decimal numbers
double - float - not exact

 

PCS1-Ch-2A-Intro-Linux-Slides


Read At Least The First Half Of Chapter 2
PCS1-Ch-2A-Linux-HW.zip

# 3

2/2

TU

  

Chapter 2B
Basics & Scripts
 
Byte - 8 bits
Short - 2 bytes - 16 bits
Int - 4 bytes - 32 bits
Long - 8 bytes - 64 bits
Char - 8 bits - single quotes
String - double quotes - \n
String - \\ - \' - \"
Boolean - true = false
Float - 4 bytes - 32 bits
Double - 4 bytes - 32 bits
.toString Conversion
.toInt Conversion
.toByte Conversion
.toLong Conversion
.toFloat Conversion
.toDoubleConversion
6 Logical Operators
<, <=,  >, >=, ==, !=
AND &&, OR || , NOT !
String Concatenation
String Repeat
Tuples ( , , )
2-tuple 5 -> 9
readInt
readDouble
readLine
Interactive Program
Scripts vs Applications
Scripts -> no scalac
shortcuts & abbreviations

   

PCS1-Ch-2B-Scala-Basics-Slides



PCS1-Ch-2B-Scala-Basics-HW


# 4

2/4

TH


Chapter 2C
Numeration & Basics

Decimal Numeration System
Decimal Counting Numbers
Binary Numeration System
Binary Counting Numbers
Euler Process
Convert Base 10 to Base 2
Convert Base 2 to Base 10
Octal Numeration System
Octal Counting Numbers
Euler Process
Convert Base 10 to Base 8
Convert Base 8 to Base 2
Convert Base 2 to Base 8
Convert Base 8 to Base 10
Hexadecimal Numeration System
Hexadecimal Counting Numbers
Euler Process
Convert Base 16 to Base 10
Convert Base 10 to Base 162
Convert Base 16 to Base 2
Convert Base 2 to Base 16
Storage Of Positive Integers
Sign Bit - High Bit
Bits Numbered From Zero
Sign Magnitude - Negative Integers
One's Complement - Negative Integers
Two's Complement - Negative Integers
.toBinaryString
.toOctalString
.toHexString
Addition Of Base Two Numbers
Subtraction Of Base Two Numbers
Math Defaults -> Int & Double
Why Know?

 

 PCS1-Ch-2C-Numeration-Slides.pdf

PCS1-Ch-2C-Numeration-HW.zip

# 5

2/9

TU

 

Chapter 3-A
Conditional Logic
 
George Boole
Linux GUI Editor gedit&
Multiple Windows
if then
if then else
Amusement Park Program
Testing A Program
String Equivalence eq
Mathematical Order Operations
Food Cost Calculation Program
Good Error Messages
Test!
match statement


PCS1-Ch-3A-Conditional-Logic-Slides.pdf

 

Read Chapter 3

 

PCS1-Ch-3A-Conditional-Logic-HW.zip
   

# 6

2/11

TH

Work On Chapter 4  


 

# 7

2/16

TU

ICE STORM




# 8

2/18

TH


ICE STORM

   

# 9

2/23

TU

Classes Cancelled    

# 10

2/25

TH

 
Chapter 3-B - Chapter 8
Loops

length - String
.toUpperCase
.toLowerCase
.substring(N,M)
short-cuts
+=, -=, *=, /=, %=
while - pretest loop
When To Use While Loop
Examples
do while - posttest loop
When To Use Do While Loop
Examples
for - fixed repetition loop
When To Use For Loop
Examples
formatted printf ("%5d"
formatted printf ("%5.2f"
str(N) - Returns String Character


 
Chapter 4
Functions With Explicit Returns
 

max(x,y) - Return Largest Of Two Ints
Function Format
max(x,y,z) - Return Largest Of Three Ints
areaTriangle (height, base) - Return Area
volumeTriangularPrism (triangleHeight: Double, triangleBase: Double, prismHeight: Double)
upChar - Return Capital
secondsToTimeString(totalSeconds:Int)

   

 

PCS1-Ch-3B-Basic-Loops-Slides.pdf

PCS1-Ch-4A-Functions-1-Slides.pdf



PCS1-Ch-3B-Basic-Loops-HW.zip


PCS1-Ch-4A-Functions-1.zip

# 11

3/2

TU


Chapter 4
Functions Without Explicit
Returns

Non-Funcional Functions
def Menu1( ):Unit =
def Menu2( )
def greetings(who:String)
isInteger(str:String):Boolean =

Tuple Review
Functions That Return Tuples
def squares1 (no:Int) : (Int, Int) =
def getOfficer( ): (String, String, String) =
var x = getOfficer()
var (name, rank, serialNo) = getOfficer()
getLong( )
getDouble( )
Write Good Tests
Test Functions Well
Program Decompostition
Function Naming
Top Down Design
Programming Paradigm
Imperative Paradigm
Functional Paradigm
Object Oriented Paradigm
Scala - Multi-Paradigm Language

Optional Arguments


 

 

PCS1-Ch-4B-Functions-2.zip

# 12

3/4

TH


More Functions


 

   

Put Together Utilities.scala
getString
getInt
# 13

3/9

TU

 

Exam 1 

 

   

# 14

3/11

TH

 


Chapter 5
Introduction To Recursion

Basics Of Recursion
Optional Arguments
Right To LeftOverloading A Function
Signatures
Random Numbers
util.Random.nextInt(5)
util.Random.setSeed(4)
General Case
Simpler Case
Trivial Case
def fact(n:Int):Int =
def fib(n:Int):Int =
def summation(n:Int):Int =
def countDown(n:Int):
def sumInputPositive( ):Int =
def sumCountAverage ( ): (Int, Int, Double) =
Overloading A Function


PCS1-Ch-5-Recursion-Slides.pdf

Read Chapter 5
PCS1-Ch-5-Recursion.zip

# 15

3/16

TU

Chapter 6-A
One Dimensional Arrays

import io.StdIn._
Optional Arguments
Arrays & Lists ==> containers
Scala Arrays & Lists ==> Sequences
Tuple - data may be of different types
Array/List - data of same type
 var arr = Array[Int] (7,4,6,2)
Array is contiguous block of memory
Array elements numbered from 0
arr(2) = 22
Loop To Graphically Display Array
def displayIntArray(arr:Array[int])
Arrays are Mutable
Out Of Bound Errors

   
PCS1-Ch-6A-Array-Utilities-Slides


Read Half Of Chapter 6

 

# 16

3/18

TH

Chapter 6-A
One Dimensional Arrays

import io.StdIn._
Optional Arguments
Arrays & Lists ==> containers
Scala Arrays & Lists ==> Sequences
Tuple - data may be of different types
Array/List - data of same type
 var arr = Array[Int] (7,4,6,2)
Array is contiguous block of memory
Array elements numbered from 0
arr(2) = 22
Loop To Graphically Display Array
def displayIntArray(arr:Array[int])
Arrays are Mutable
Out Of Bound Errors




   

TomH-6A-Student.zip

# 17

3/23

TU

About Sorting
Order N
Order N2
Sorting Algorithms On Internet
Our Sorting Algorithms

Bubble Sort
3 Variations




   
TomH-6B.zip

# 18

3/25

TH


About Order N
Order N
Order NLogN

Sequential Search
Binary Search





TomH-C.zip

# 19

3/30

TU


Chapter 6 - Lists & List Processing
var arr = Array.tabulate(4)(I => 0)
val arr = Array.tabulate(5)(n => 1)
val arr = Array.tabulate(10)(n => n)
val arr = Array.tabulate(11)(n => n -5)

for(item <- arr) printf ("%5d", item)
Functional Programming Uses Lists
Lists & Arrays Are Parametric Types
var lst = List (2,3,4)
var lst = List[Int] = Nil
var lst = 3 :: 4 :: 5 :: Nil
Cons ==> ::
Nil at end of list
1::(2::(3::Nil))
val names = List ("Eggen", "Myers", "Massingil", "Chang")

Create Function readInts
Evoke Function readInts
lst.indexOf(n)
lst.find(_>0)
lst.find(_==4)
lst.find(_!=4)
var lst = List.tabulate(4)(I => 0)

val lst = List.tabulate(5)(n => 1)
val lst = List.tabulate(10)(n => n)
val lst = List.tabulate(11)(n => n -5)
var lst = List.tabulate(5)(i => 2*i + 1)
var lst = List.tabulate(5)(k => k * 3 - 1)
println( lst(2) + " - " + lst(3) + " - " + lst(1) )
val lst = List.tabulate(5)(N => N * 2 + 1)
for(item <- lst) printf ("%5d", item)
lst.drop(n)
lst.init
lst.head
lst.last
lst.slice(2, 5)
lst.splitAt(3)
lst.take(3)
lst.takeRight(3)
lst.contains(5)
var l:List[Int] = Nil
l.isEmpty
l.nonEmpty lst.nonEmpty
lst.startsWith(List(1,3))
lst.indexOf(7)
lst.lastIndexOf(7)
lst.diff(List(1, 2, 3))
lst.reverse



PCS1-Ch-6E-Lists-Slides

PCS1-Ch-6E-Arrays-Lists-HW

# 20

4/1

TH


Chapter 7 - Vectors
& Two Dimensional Arrays

Option Type
find --> Some or None
arr.find(_==7)
arr.find(_==7).get
arr.find(_==7).getOrElse(-1)
Map
Create Maps
map.isEmpty
map.keys
map.values
println(map.keys)
println(map.values)
map concatenation ++
for (col <- colors1) println (col)
map.contains("red")
add key pairs to map
ascii += ('A' -> 65)
ascii.keys.foreach { i => print (i + " " )}
Iteration 1 to 5
Iteration.sum (1 to 5).sum
Iteration.product (1 to 5).product
Loop Iteration Lists/Arrays
for(elem <- lst) printf ("%5d", elem)
val V = Vector (1, 2, 3)
Vectors Immutable
val L = List (1, 2, 3)
Lists Immutable
var A = Array(1,2,3)
Arrays Mutable
val v4 = v3 :+ 4
val v5 = v3 :+ 4 :+ 5
var vec = for (i <- 1 to 6) yield 0
var vec = for (i <- 1 to 6) yield 5
var vec = for (i <- 1 to 6) yield 2 * i + 3
printf(vec(2))
for (elem <- vec) printf ("%5d", elem)
Vectors --> Better Parallel Processing
Multiple Generators
for ( i <- 1 to 5; c <- 'A' to 'C' ) println ( i + " " + c )
Multidimensional Arrays
var matrix1 = Array ( Array(1,2,3), Array(4,5,6) )
var noCols = matrix1.length
var noCols = matrix1 (0).length
def displayMatrix(arr:Array[Array[Int]], message:String="")
Adding Matricies
Subtraction Matricies
Multiplying Matricies
 
Chapter 7 Not On Exam

PCS1-Ch-7A-2-Dim-Arrays-Vectors-Slides

   
Optional Help Session
Monday 8:30-9:20
PCS1-Ch-7A-2-Dim-Arrays-Vectors-HW
Due 4/8

# 21

4/6

TU

EXAM 2

   
PCS1-Ch-7A-2-Dim-Arrays-Vectors-HW
Due 4/8

4/7

W

Wed Classes Cancelled


   

 


# 22

4/8

TH

   
Chapter 9 -Text Files

Why Use Text Files
Package
import scala.io.Source
Create Data Files
fp = Source.fromFile ("filename")
fp.close
Read Entire File Into Buffer
var fData = fp.mkString
Form Small Files
Iterator Position When File Open
Iterator Position After mkString
fp.isEmpty
Reading File Character By Character
fp.hasNext
fp.Next
Passing Arguments Into Scala
args.mkString("", ", ", ".")
args(0)
for (arg <- args) println (arg)
for (arg <- args) printf ("%10s", arg)
ASCII Value 10 - Line Feed
ASCII Vlue 13 - Carriage Return
fp.reset
Reading Files Line By Line
for(line <- Source.fromFile("DataFile1.txt").getLines)
fp.length
  fData.split("+ ")
 fData.split(", ")
Applications for Split
Revies Array Initializations
Review Array Filling
Review Two Dimensional Arrays
Map function
  arr = Array (1,2,3,4,5,6,7,8,9,10)
arr.map(s => s * 5)
PCS1-Ch-9A-Text-File-Basics-Slides TomH-9.zip

# 23

4/13

TU


Chapter 10
Introduction to Classes

Try-Catch Exceptions
Arithmetic Exceptions
File Exceptions
file Not Found Exception
IO Exception
Try-Catch-Finally
import java.io._
var fp = Source.fromFile (fileName)

while (fp.hasNext)
var ch = fp.next

fp.close
Dual Try-Catch To Close Files
OOP
Object Oriented Programming
Intro To Classes
Methods/Member Functions
Member Data
Public & Private Member Data
Scala Containers
Array/List/Vector Tuple Class
Develop Class Student
id, first, & last
Class Constructor With Arguments
Default/Optional Arguments
display Method
set Method
get Method
Accessor/Mutator Methods
Array of Class Objects
Encapsulation
Bundle Data & Functions
Data Hiding

Introduction to Case Classes
case class Book
:load CaseClasses.scala
case class Color
case class Student
Create Case Class Objects
Functions With Case Class Objects
immutable/mutable options
case class data members may be List or Array
Using Case Class Objects
Case Class Copy Method
  Mutable Case Class Objects
PCS1-Ch-10-A-Classes-Slides


PCS1-Ch-10-A-Classes-Slides

   Read Chapter 10

 

PCS1-Ch-10-Classes-HW

# 24

4/15

TH

Classes Cancelled


   

 


# 25

4/20

TU






   
 

# 26

4/22

TH

No Class
Work Independently On Project
 
 

# 27

4/27

TU











# 28

4/29

TH


   

# 29

5/4

TU

     EXAM 3





 


# 30

5/6

TU

     





 


R1

 

5/10

M





    READING DAY






    READING DAY






    READING DAY



R2

5/11

TU





    READING DAY






    READING DAY






    READING DAY


+

No Assignments Will Be Accepted After Noon on 12/7