CSI 2110
Computer Science
Fall 2014
University of Ottawa
Assignment #1 SOLUTION
1. (4 points) Suppose that a given algorithm takes 500ms in the worst case to process an input
of size N . How much time will it take to process an input with twice this size,

CSI2110B Notes
Slide 1: Introduction
What are Data Structures?
Example: Electronic Phone book. It contains different DATA such as names, phone numbers,
and addresses. It also has to be able to perform certain operations: add, delete, look for a
phone numb

CSI 2110
Computer Science
Fall 2013
University of Ottawa
Assignment #1 (100 points, weight 5%)
Due: Wednesday October 2, at 13:00
The assignment must be uploaded on Virtual Campus by October 2, 13:00
Late assignments are accepted for a maximum of 24 hours

CSI 2110
Summary
Fall 2012
CSI 2110 Summary, Fall 2012
Analysis of Algorithms
Algorithm - a step by step procedure for solving a problem in a finite amount of time. Analyzing an
algorithm means determining its efficiency.
Primitive operations - low-level

[Question 1] (6 marks)
Fill the blanks with the best possible big-oh complexity: & P M 4
(1) n4 (1+2nyn2 + n3 is 0( n’i)
(2)n3+10gg2" - 12:14 is 0( in“)
(3) n3+zi=m.ll.n i(f0rn> [0} is OM 6/
lQuestion 2| (9 marks)
The given pseudo-code below takes an a

CSI 2110
Computer Science
Fall 2014
University of Ottawa
Assignment #1 (100 points, weight 5%)
Due: Wednesday October 1, at 11:59PM
The assignment must be uploaded on Virtual Campus by October 1, 11:59PM
Late assignments are accepted for a maximum of 24 h

Analysis of Algorithms
Note*: Midterm October 30th, 3:00pm-5:00pm
Algorithm: Step-by-step procedure for solving a problem in a finite amount of time.
To Analyze an Algorithm, you are determining its efficiency.
Running Time
Depends on the input size
Depen

Binary Search Trees
Trees
A graph G = (V,E) consists of a set V of vertices and a set E of edges with E = cfw_(u,v): u,v E V, u != v
A tree is a type of graph, connected with no cycles
Rooted Trees
Consists of a root (dominant value in hierarchy)
o Parent

CSI2110A/B Data Structures and Algorithms
Final Examination
Length of Examination: 3 hours
December 11th , 2006, 14:00
Professors: P. Flocchini, J. Lang
Page 1 of 9
Page
Family Name:
Other Names:
Student Number:
Section:
Signature:
Closed Book. No calcula

Question 1 [1 point]
What is the running time complexity of the following Algorithm (in big-Oh notation) ?
Algorithm Hello(A).
Let A be an array of size n.
for (int i = 0; i < n2; i+) cfw_
for (int j = 0; j < i; j+) cfw_
sum = sum + 2*j;
for (int k = 0; k

Question 1 [1 point]
What is the running time complexity of the following Algorithm (in big-Oh notation) ?
Algorithm Hello(A).
Let A be an array of size n.
for (int i = 0; i < n2; i+) cfw_
for (int j = 0; j < i; j+) cfw_
sum = sum + 2*j;
for (int k = 0; k

For all multiple choice questions, select only one anwser: the best one possible.
In all question Where a logo appears, it is meant to be logi2 it.
Question 1 [1 point] What is the running,r time complexity of the algorithm in the following
pseudocode fra

/*
* A simple node class for a singly-linked list. Each node has a
* reference to a stored element and a next node.
* This class is based on the <code>DNode</code> class by Roberto Tamassia.
*
* @author Jochen Lang
*/
public class DNode cfw_
private Objec

Abstract Data Types
Abstract Data Type
An abstraction of data structures
The ADT specifies
o What can be stored in the ADT
o What operations can be done on/by the ADT
Stacks, Queues and Deques
ADT Stack
Implementation with
o Arrays
o Singly Linked List
AD

Maps and Sorted Maps
Map ADT
A map is an ADT to efficiently store and retrieve values (key)
Keys are unique no repeats
o A key is mapped to a value
Main operations
The main operations of a MAP are searching, inserting and deleting items.
*Dictionary ADT i

Assignment 2 (5%)
CSI2110
sh is
ar stu
ed d
vi y re
aC s
o
ou urc
rs e
eH w
er as
o.
co
m
Due date : Saturday October 24
(submit to blackboard learn before 23h55 October 29 without late penalty)
Question 1. [10 points = 1+1+2+2+4]
Consider the following t

Th
sh is
ar stu
ed d
vi y re
aC s
o
ou urc
rs e
eH w
er as
o.
co
m
Kalim Kassim
6782118
CSI2110 B
Assignment 1
https:/www.coursehero.com/file/13266272/Assignment1/
Th
sh is
ar stu
ed d
vi y re
aC s
o
ou urc
rs e
eH w
er as
o.
co
m
Kalim Kas

import java.util.Arrays;
import java.util.Iterator;
/*
* HuffmanTree creates and stores a Huffman tree based on Huffman nodes (an
inner class),
* It also provide a series of methods for encoding and decoding.
* It uses a BitFeedOut which allows a stream o

CSI2110
Data Structures
and Algorithms
Prof. WonSook Lee
1
Data Structures ?
Example:
Electronic Phone Book
sa
i
L
8
622-9
Contains different DATA:
- names
- phone number
- addresses
W
on
S
Jo
hn
oo
k
23
nson
o
r
B
75
112-4
433
M
ic
he
le
11
0
nk
a
B
Need

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
Trying to overcome the
limitations of Array based
Stacks and Queues
A Growable Array-Based Stack
Two strategies:
tight strategy
growth strategy
A full
Create B
B
Copy A into B
B
Reassign referenc

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
Overview
Abstract Data Types
Stack
Queue
Deque
double ended queue : pronounce deck
Abstract Data Types (ADTs)
An Abstract Data Type is an abstraction of a data structure.
The ADT specifies:

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
Algorithms
Input
Algorithm
Output
An algorithm is a step-by-step procedure for
solving a problem in a finite amount of time.
Analyze an algorithm = determine its efficiency
Analysis of Algorithms

Priority Queues
A set of elements each with a given priority
Regardless of the order inputted, elements are removed according to there
importance/relevance
Each Node contains:
o Key (Priority value)
o Element (Object being stored)
The priority Queue ADT
A

/*
* Builds a singly linked list of size 5 and prints it to the console.
*
* @author Jochen Lang
*/
class LinkList cfw_
Node llist;
LinkList( int sz ) cfw_
if ( sz <= 0 ) cfw_
llist = null;
else cfw_
/ start with list of size 1
llist = new Node( "0", nul

Monday, September 19, 2016
CSI-2110
Chapter 4 - Solutions
Arithmetic Sum:
Geometric Sum:`
Reinforcement
4.3.
"
4.8.
"
4.9.
"
4.10.
"
4.11.
"
4.16.
Creativity
4.45. Sum for all elements in the range
public static int find_missing_number (int[ ] arr)

Student name: Felix Singerman
Student number: 7970742
Question 1:
a) DFS
Order of vertex visit: cfw_1,2,3,4,5,6,8,7
Discovery edges in order of labeling: (1,2), (2,3), (3,4), (4,5), (5,6), (6,8),
Back edges in order of labeling: (3,1), (5,3), (6,3), (8,4)

CSI 2110
Fall 2015
Assignment #5 (50 points, weight 5%)
Due: Monday December 7 at 11:55 on virtual campus.
Late assignments accepted up to 24hs 30%.
You may type or write by hand legibly and scan it; always submit a single PDF le.
1. (12 points = 2+5+5) A

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
Trees
Trees
Binary Trees
Properties of Binary Trees
Traversals of Trees
Data Structures for Trees
2
a Tree
3
Trees
A graph G = (V,E) consists of an set V of VERTICES
and a set E of edges, wit

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
We learned
2
Review:
Basic Data Structures (concrete data structures)
Array
Linked Lists
For example:
l
header
trailer
3
Abstract Data Types (ADT)
ADT is an abstraction of a data structure.
ADTs s

CSI2110
Data Structures and
Algorithms
Prof. WonSook Lee
1
Priority Queues
The priority queue ADT
Implementing a priority queue with a sequence
Elementary sorting using a Priority Queue
2
Priority Queue
Queue where we can insert in any order. When we r

!1
CSI 2110C Computer Science
Fall 2016 University of Ottawa
Assignment #1 (35 points, weight 5%)
Due: Wednesday September 28, 9:30PM
The assignment is either to be uploaded on the blackboard electronically (you may
type or write by hand legibly and scan

CSI2110
Data Structures
and Algorithms
WonSook LEE
1
CSI 2110 Data Structures and Algorithms
Prof:
WonSook LEE
Office:
CBY A 509
Email:
[email protected]
Office Hours: Thursday, 13:00 - 14:00
Web site
Course Web Site:
http:/www.eecs.uottawa.ca/~wslee/cours