COMP-200: Intro to Computer Systems
Assignment 3
mo khan - 3431709
Choose ONE exercise each from Chapters 6, 7, and 8
Chapter 6:
- Write a complete assembly language program (including all necessary pseudo-ops) that reads in a series of integers, one at a time, and outputs the largest and smallest values. The input will consist of a list of integer values
!include assignments/3/max_min.s
Chapter 7:
- Given the following diagram, where the numbers represent the time delays across a link:
a. How many simple paths (those that do not repeat a node) are there from node A to G?
A<->B: 5
A<->D: 6
A<->F: 3
B<->C: 4
B<->E: 2
C<->D: 3
C<->E: 1
C<->G: 2
D<->E: 1
F<->G: 8
There are 7 simple paths
| Path |
| ---- |
| a,b,c,g |
| a,b,e,c,g |
| a,b,e,d,c,g |
| a,d,c,g |
| a,d,e,b,c,g |
| a,d,e,c,g |
| a,f,g |
b. What is the shortest path from node A to node G? What is the overall delay?
The shortest path has a distance of 10.
The overall delay is 11 (((11 + 10 + 13 + 11 + 15 + 10 + 11)/7) = 11).
| Path | Total Distance |
| ---- | -------------- |
| a,b,c,g | 5+4+2 = 11 |
| a,b,e,c,g | 5+2+1+2 = 10 |
| a,b,e,d,c,g | 5+2+1+3+2 = 13 |
| a,d,c,g | 6+3+2 = 11 |
| a,d,e,b,c,g | 6+1+2+4+2 = 15 |
| a,d,e,c,g | 6+1+1+2 = 10 |
| a,f,g | 3+8 = 11 |
c. If node E fails, does that change the shortest path? If so, what is the new shortest path?
Yes, if node E fails then there are 3 simple paths remaining with the shortest path having a distance of 11.
A<->B: 5
A<->D: 6
A<->F: 3
B<->C: 4
C<->D: 3
C<->G: 2
F<->G: 8
| Path | Total Distance |
| ---- | -------------- |
| a,b,c,g | 5+4+2 = 11 |
| a,d,c,g | 6+3+2 = 11 |
| a,f,g | 3+8 = 11 |
The following code can be used to prove these results:
!include assignments/3/graph.rb
Chapter 8:
- Using a Caesar cipher with s = 5, decode the received message RTAJ TZY FY IF
The following code can be used to decipher the Caesar cipher.
!include assignments/3/caesar.rb
The plaintext is MOVE OUT AT DAWN.
$ ruby caesar.rb
# Caesar Cipher
| --------------- | --------------------------------------------------- |
| Plain Alphabet | A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z |
| Cipher Alphabet | F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A,B,C,D,E |
| --------------- | --------------------------------------------------- |
| Key | 5 |
| Ciphertext | RTAJ TZY FY IFBS |
| Plaintext | MOVE OUT AT DAWN |
References: