1. 22.1-2 Give an adjacency-list representation for a complete binary tree on 7 vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered from 1 to 7 as in a binary heap.
1 2 4 5 6 3 7
1 2 3 4 5 6 7 / / / /
2 4 6
Computers are everywhere
Processor = computers brain and coordinates all activity (CPU=Central Processing Unit)
- Receive a new instruction (fetch)
- Make sense of the instruction (decode)
- Perform the action defined by
Wednesday, October 21st, 2015 Lecture
#Caesar Cipher practice
plain_text = input("Please enter the plaintext (a positive integer)")
shift = int(input("Enter an integer between 0 and 25")
cipher_text = "
for cur_char in plain_text:
cur_cipher = (int(cur_ch
#If you know you're drawing a square (4 sides), you can use a loop with a range
def square (side):
#a function to draw a square whose sides and lengths given by
for i in range(4):
The platform used to submit my notes to you does not allow me to submit .py files, so I am
copying and pasting the notes and programs each day to a word document.
#September 28th: Strings
> "use backslash for \
long strings that take mul
> "somewhat long string"[5:]
'hat long string'
> "some long string"[:7]
> len("some long string")
> str_var = "some long string"
> str_var = "This is a s
#This is a program to make a triangle that prints a 1 in the first row,
#1 2 in the second row, 1 2 3 in the third, etc.
num_lines = int(input("Please enter the number of lines:")
for line_num in range(1,num_lines + 1):
#assemble next line
line = "
Wednesday, 10.07 Lecture
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
> WARNING: The version of Tcl/Tk (8.5.9) in use may b
Monday, November 2nd, 2015
#Program to read a list of numbers, and print out all of the numbers in
#the list that are larger than the average of the list.
numbers = read_list()
average = lst_average(numbers)
October 28th, 2015 Lecture
#Another version of fans of squares
for i in range(4):
def fan_of_squares(n, square_side):
for i in range(n):