Computer Science I
Dr. Tom Hicks - Trinity University - CSCI 1320-  Fall 2020

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


P
R
E
-
S
E
M
E
S
T
E
R




Maybe Prepare Your Computer
Before Semester Begins?

 

Install vdi.trinity.edu

Install ZOOM

How o Upload Files To Mars DropBox
(VMWare Installation Directions Included)

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

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

Transferring-Files-Into-My-Mars-DropBox-From-Linux.pdf
# Topic(s) Reading Assignments
 & Handouts
Laboratory Assignment

#1

8/25

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

 

 

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

 


# 2

8/27

TH


Chapter 2
Linux & Tools

GUI
Valid Directory Names
Command Line Interface
Putty - Free!
clear - clear console window
Bit - binary digit
Byte 8 bits - 1 char
Directory/Folder
Text File
ASCII
Binary File - Executable
ls - list files
Linux File Permissions
Hidden Files (start with.)
Wild Cards (*)
mkdir - create directory
cat - display ascii-text files
cd - Change Directory
cp - Copy Files
rmdir - Delete Empty Directory
rm - Delete File Or Directory
mv - Move Files
chmod - Change File Permissions
rwx - binary -421
exit - close terminal window
man - help system man pages
compile a scala program
redirect output >
less - cycle through file
whoami - linux groups
ping
rsh - remote shell disabled
telnet - disabled
df - disk free
find - display a list of files
grep - search files for text
head - top of file
tail - bottom of file
who - logged in?

vi command line  editor
why use
2 modes
i - enter input mode
ESC - enter command mode
ESC:wq - save & exit
ESC:w - save & stay
ESC:q! - exit & discard changes
a - input after cursor
arrow keys - command mode
:50 - go to line 50
I - input mode at beginning of line
A - input mode at end of line
x - delete char
dd - delete line
yy - yank to clipboard
P - paste before cursor line
p - paste after cursor line
J - join cursor line with following line
/tom - search for tom
- repeat last command
u - undo
:r a.scala - read file into editor



Ch-2A-Intro-Linux-Slides

Read Chapter 2

Ch-2A-Linux-HW.zip


# 3

9/1

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.pdf PCS1-Ch-2B-Scala-Basics-HW.zip

# 4

9/3

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

9/8

TU

 

Install Scala

Practice

 


Practice 2A, 2B, & 2C

# 6

9/10

TH


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

Installing-Java-Scala-On-Windows-10.pdf

Installing-Java-Scala-On-A-Mac.pdf

 

 

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


# 7

9/15

TU

 
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


  

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

Read Chapter 3



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

# 8

9/17

TH

 

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-4A-Functions-1-Slides.pdf

Read Chapter 4


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


# 9

9/22

TU

 

GetInt Function

Creating A Complex Function
In Stages

Read Chapter 4


Study For Exam

# 10

9/24

TH

   Exam I  


Read Chapter 4

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

# 11

9/29

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-4C-Functions-3-Slides.pdf

Read Chapter 4
PCS1-Ch-4C-Functions-3.zip
Due 10/6

# 12

10/1

TH



Chapter 5
Introduction To Recursion

Basics Of Recursion
Optional Arguments
Right To Left
Overloading 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) =



PCS1-Ch-5-Recursion-Slides.pdf

Read Chapter 5
PCS1-Ch-5-Recursion.zip
Due 10/6

# 13

10/6

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



 

 


# 14

10/8

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
PCS1-Ch-6A-Array-Utilities-Slides.pdf

PCS1-Ch-6A-Array-Utilities-HW.zip
Do Diagnostic Levels 1-12 By 10/15

# 15

10/13

TU

More Array Processing

PCS1-Ch-6A-Array-Utilities-Slides.pdf
PCS1-Ch-6A-Array-Utilities-HW.zip
Do Diagnostic Levels 1-12 By 10/15

# 16

10/15

TH

 
Chapter 6-B
Built In Array & List Functions

System.nanoTime
arr.drop(n)
arr.init
arr.head
arr.last
arr.slice(f,l)
arr.splitAt(n)
arr.take(n)
arr,tajeRight(n)
arr.contains(n)
arr.isEmpty
arr.nonEmpty
arr.startsWith(arr)
srr.indexOf(n)
arr.diff(arr1)
arr.reverse
 

   
PCS1-Ch-6B-Array-Sequential-Bubble-Slides.pdf


PCS1-Ch-6B-Array-Sequential-Bubble-HW.zip
Do Diagnostic Levels 1-16 By 10/15


# 17

10/20

TU


Binary Search
Sequential Search
val x = Array.range(1, 10)
val x = Array.range(0, 10, 2)
val x = Array.fill(3)("foo")
val x = Array.tabulate(5)(n => n * n)
val x = "Hello".toArray
val xs = Array.tabulate(5)(_ * 2)
Recordings/Help-Session-1.mp4



   
Work On Non-Recursive
Binary Search


# 18

10/22

TH

EventLoop
Menu Processing



Recordings/Help-Session-2.mp4
   

PCS1-Ch-6C.zip


# 19

10/27

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

 

 




Recordings/Help-Session-3.mp4


PCS1-Ch-6-D-Lists-Slides


Make Changes In Program

When The Array Is Sorted, Make arr(0) Negative
You will have to change several functions to use absolute value of arr(0)
When Sorting, change to negative

Write Function InsertIntArray which Appends when unsorted &
efficiently places it in place properly if sorted.
Write testcode for the function


Write Some Test Code for deleteIntArray(arr, oldRecNo)
which efficiently deletes the item from the array; maintain
the sorted status if sorted.
Write testcode for the function




# 20

10/29

TH


Finish Lists

Review for Exam 

PCS1-Ch-6E-Lists-Slides.pdf

Listen To Help Session Videos
Study For Exam
Work On Menu Program

PCS1-Ch-6D-Array-Insertion-Menu-2-HW.zip
Due 11/5


# 21

11/3

TU

 
Exam II









PCS1-Ch-6D-Array-Insertion-Menu-2-HW.zip
Due 11/5


# 22

11/5

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

 


PCS1-Ch-7A-2-Dim-Arrays-Vectors-Slides.pdf
   
Read Chapter 7
PCS1-Ch-7A-2-Dim-Arrays-Vectors-HW.zip

# 23

11/10

TU


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.pdf


Read Chapter 9
Read Chapter 9

Go Through The First 50 Slides
Make Sure You Have Written & Examined
All Of The Code & All Of The File Functions
Either In Class Or On Your Own.
Save Your Code.

# 24

11/12

TH

   

Chapter 9 -Text Files

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.pdf




PCS1-Ch-9A-Text-File-Basics-HW.zip

# 25

11/17

TU


Introduction to  Classes


 
 

# 26

11/19

TH



Stacks
Push, Pop, Empty
Display



PCS1-Final-Project-HW.zip
Due 12/8


# 27

11/24

TU


THANKSGIVING

   

  PCS1-Ch-11A-ScalaFX-HW.zip
Due 12/1

# 28

11/26

TH

THANKSGIVING

   

#29

12/1

TU

Exam III    

#30

12/3

TU

   Exam III 

   

#31

12/8

TH

 

   




RD

12/9

M




READING DAY





    READING DAY





    READING DAY



RD

12/10

TU



    READING DAY




    READING DAY




    READING DAY


+

No Assignments Will Be Accepted After Noon on 12/9