CMPUT175-Lab 3 Exercises
The solutions to these exercises have to be shown to your TA in your assigned Lab before the end of
your lab time.
The exercises are about building the game of Tic Tac Toe. Tic Tac Toe is a game for two players who
take turns to f

import random
print("Enter a guess between (1-20)")
number=random.randint(1,20)
i=0
while i<4:
guess = input("what is the number?")
guess=int(guess)
#print("the correct number is ",number)
if guess > number:
print("it is too high")
i=i+1
elif guess < numb

class Double_Node:
def _init_(self, data):
self.data = data
self.next = None
self.prev = None
class Doubly_Linked_List:
# creates a new doubly linked list
# head and tail are initialized to None
def _init_(self):
self.head = None
self.tail = None
# adds a

CMPUT175-Lab 2 Exercises
The solutions to these exercises have to be shown to your TA in your assigned Lab before the end of
your lab time.
To get full marks for this lab, you must complete Exercise 1 and either exercise 2 or 3 (choose one).
1.
Write a pr

#Chen Lingyu(1406354)
import random
class TicTacToe:
def _init_(self):
# "board" is a list of 10 strings representing the board (ignore index
0)
self.board = [" "]*10
self.board[0]="#"
def drawBoard(self):
# This method prints out the board with current p

Exercise 2 Methods #2
Exercise 3
Exercise 3 User Input Example
Add, Serve, or Exit:
The lineup is already empty.
Add, Serve, or Exit:
Enter the name of the person to add:
Add, Serve, or Exit:
Enter the name of the person to add:
Add, Serve, or Exit:
Enter

#Assignment1 t1
#Chen Lingyu
import math
customerfile = open('customers.txt','r')
fileref = customerfile.readlines()
#Creat Customer Dictionary -> key is the phone number
customerdict=cfw_
numlist=[]
for i in fileref:
Data = i.strip()
Data= Data.split(';'

CMPUT 175 Sp16 - INTRO TO FNDTNS OF CMPUT II Combined LAB LEC Sp16
Lab #2
Lab 2 Exercises
The purpose of this lab is to give you practice writing ADTs and using the Stack ADT, as well as analyzing your own algorithms.
Your task is to complete the followin

class TicTacToe:
def _init_(self):
# "board" is a list of 10 strings representing the board (ignore index
0)
self.board = [" "]*10
self.board[0]="#"
def drawBoard(self):
# This method prints out the board with current plays
with index.
print(' ' + self.bo

# Lingyu Chen #
# Collaberate with YiMin Yan #
import random
import math
class OceanTreasures: # Worked by YiMin Yan
def _init_(self):
self._boardlist = []
for i in range(0, 15):
self._boardlist.append(list("~"*60) # Creating a mutable list of
lists which

CMPUT 175: Foundations of Computing
Term Exam 1: Wednesday February 10, 2016
Instructor : Dr. Osmar Zaane or Dr. Anup Basu
Student Name
:_
Student ID
:_
Do not open this exam until you are instructed to do so. Read the instructions.
The duration of the ex

CMPUT 175: Foundations of Computing
Term Exam 1: Wednesday February 13th, 2013
Instructor : Osmar Zaane
Student Name
:_
Student ID
:_
Do not open this exam until you are instructed to do so. Read the instructions.
The duration of the exam is 50 minutes.
T

CMPUT 175
Lab 7: Doubly linked list
Lab 7 Exercises
Keep in mind that all class variables must be
private.
Test your code by using the corresponding test
function in the files given to you
For the doubly linked list you can see the
slides on eclass or

# Student Name: Lingyu Chen
# Collaborate with Yimin Yan
# Caution: We accidentally employed y as the vertical-axis; x as the horizontalaxis in the BattleshipGame class
# However, it won't affect the user_input. If the user enters x as vertical
cordinate,

# Student Name: Lingyu Chen
# Collaborate with: YiMin Yan
# #
# An Breif Introduction:
# The computer will first hunt around ramdonly untill it finds a target.
# Then, the computer will fire at the cells which are around the target(FYI, the
order would be

#Name: Wendi Bao
#Section: CMPUT 175 Fa14
#Assignment#2 Problem#3
Part_a
Function: For the item in my_list. the stack append every item and then the new_list append those items from the stack by reverse direction. For example, if my_list is [1,2,3,4,5], t

CMPUT 175
Introduction to Foundations
of Computing
Trees
March 23, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
Study a non-linear container called a Tree.
Understand what a tree data structure is and
what it is used for.
Learn about a specia

CMPUT 175
Introduction to Foundations
of Computing
Recursion
Dr. Zaiane, updates Dr. Basu
March 09, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
Introduce the concept of recursion
Understand how recursion works
Learn how recursion can be use

CMPUT 175
Introduction to Foundations
of Computing
Hash Tables
March 30, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
Understand how dictionaries could be
implemented
Introduce the concept of hash tables and
hash functions
Understand how coll

f= open('rainfall.txt','r') # open the file
string = f.read() # read the file
list_of_string = string.split() # split the string
rainfall = cfw_ # create an empty dict of the data given the region as keys
for index in range(0,len(list_of_string)/2):
index

CMPUT 175
Introduction to Foundations
of Computing
Searching
Dr. Osmar R. Zaiaine, Ualberta
Updates: Dr. A. Basu
March 2, 2016
1
Objectives
Introduce two techniques for searching
for an element in a collection
Learn sequential search algorithm.
Learn the

CMPUT 175
Introduction to Foundations
of Computing
Sorting
Dr. Zaiane, minor updates by
Dr. Basu
Osmar R. Zaane : University of Alberta
1
Objectives
Introduce the problem of sorting
collections
Learn how to sort using different strategies
Evaluate the c

CMPUT 175
Introduction to Foundations
of Computing
Simple enciphering and
Hangman Word Game
Design and
Implementation with
Python
January 09, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
Revision of Programming concepts learned in
CMPUT 174
R

CMPUT 175
Introduction to Foundations
of Computing
Reverse Polish Notation-based Calculator
Osmar R. Zaane : University of Alberta
In collaboration with Li-Yan Yuan
1
Objectives
Combining the previous two lectures in a
concrete example
Seeing an example

CMPUT 175
Introduction to Foundations
of Computing
Crash course on Python
Quick revision of CMPUT 174 material
January 7, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
Revision of Programming concepts learned in
CMPUT 174
Review of Basic Pytho

CMPUT 175
Introduction to Foundations
of Computing
Queue, bounded Queue, Circular Queue
February 6, 2015
Osmar R. Zaane : University of Alberta
1
Objectives
In this lecture we will learn about another
linear structure called Queue.
We will learn about ho

CMPUT 175 A1: Final exam
Instructor: Marianne Kerolus
Percentage: 40%
Date: December 18, 2015
Name:
ID:
Grade:
_ / 100
This final exam has 5 questions, and a total of 8 pages.
This is a closed book exam (except for a total of 6 pages of cheat sheets prepa

CMPUT 175 A2: Final exam
Instructor: Marianne Kerolus
Percentage: 35%
Date: December 15, 2014
Name:
ID:
Grade:
_ / 80
SOLUTIONS
Question 1:
(20 marks)
Time-complexity: Thoroughly compare the time complexities of Bubble sort and Selection sort in each of
t

f = open('accounts.txt','r') # open the file
string = f.read() # read the file
list_of_strings = string.split('\n') # create a list of string
pairs = [] # initialize a list of pairs
for character in list_of_strings: # check for each character in list_of_s

from Stack import Stack
#
- #
# set the Home Page
HomePage = 'www.cs.ualberta.ca'
#
- #
# initialize all the stacks
# push the Home Page to the current page
CurrentPage = Stack()
CurrentPage.push(HomePage)
PreviousPage = Stack()
#
- #
# print the message

import random
class TicTacToe:
def _init_(self):
# "board" is a list of 10 strings representing the board (ignore index
0)
self.board = [" "]*10
self.board[0]="#"
def drawBoard(self):
# This method prints out the board with current plays adjacent to a boa