Chapter 3
Data Structures
1
Data types
Encapsulaton
A programming language usually provides certain
basic data types. A data type is a set of values and a
collection of operations on those values.
e.
COMP2119 TUTORIAL 1
1
QUESTION 1 - 4
Need to submit by Sept 22 5:00pm
Hard copy to Assignment box A2 on CYC 3/F
Please write the answers clearly
2
QUESTION 5
3
SOLUTION 5
(a) Base case: n = 0, f(n) =
COMP2119
Tutorial 3
Xiang Li
March 30th, 2017
The arithmetic expression is 50+40+18*(-14)
The contents of stack:
Suppose the original stack is S, then we maintain an extra stack
M with the same num
COMP2119
Programming Assignment
Tutorial
Shuguang Hu
[email protected]
Graph
We already know graph, bfs, dfs
We are going to talk about shortest-path problem, all pairs short
est-path problem
This mig
COMP2119C Tutorial
Midterm Examination
Shuguang Hu
[email protected]
Statistics
Average: 63.88 for total 74 students
Median: 69
>=90: 11 students
>=80: 20 students
Total marks will be appeared on mo
Chapter 8
Balanced Trees
1
Balancing a search tree
w With binary search trees, average search time (with
random inserts and no deletes) is O(lg(n). However,
the worst case search time is O(n).
w Obser
CSIS1119 COMP2119 Introduction to Data Structures and Algorithms
Programming Assignment
Due Date: 7pm, 24th April 2017
Please send email to [email protected] if you have any questions about the descripti
COMP 2119A Introduction to Data Structures and Algorithms
Assignment Two
Due Date: 25 October 2016 midnight
Assignment box: A3 (also submit a scanned copy to moodle)
[Note that for the questions invol
COMP 2119A Introduction to Data Structures and Algorithms
Test 1
Date: 04 November 2016 (Friday)
Time allowed: 100 minutes (3:30pm 5:10pm)
[Note that for the questions involving algorithm design, befo
COMP 2119B/C: Solution for Assignment 2
March 16, 2018
1
(a) To reverse array of n numbers A[1,.,n], we can swap A[1] and A[n] first
and then reverse A[2,.,n-1]. The detail is as follows (algorithm 1)
Supplementary notes to 1. Analysis of Algorithms
Slide 16:
Let B = cfw_all functions f(n) s.t. $ a constant n0 1, f(n) > 100 " n n0.
e.g. f(n) = n (yes); f(n) = n/2 (yes); f(n) = 1/n (no)
Proof:
(i) f
Chapter 4
Hashing
The key is the address
1
The Dictionary ADT
A dictionary is a set data type that supports 3
operations: INSERT, DELETE, and SEARCH.
Which operation do you think is used most often?
Chapter 8
Balanced Trees
1
Balancing a search tree
With binary search trees, average search time (with
random inserts and no deletes) is O(lg(n). However,
the worst case search time is still O(n).
O
Chapter 8
Balanced Trees
1
Balancing a search tree
With binary search trees, average search time (with
random inserts and no deletes) is O(lg(n).
However, the worst case search time is O(n).
Observa
Chapter 6
Searching
1
The problem
Given a set of n elements, search for one
with a specific key.
We have studied 2 ways of searching: linear
search and hashing.
2
The problem
For linear search:
ave
Chapter 7
Binary Search Trees
1
Binary search on a list
Can we do a binary search on a linked list of
elements?
Recall that the principle of binary search is to
examine the middle element and use th
Chapter 6
Searching
1
The problem
Given a set of n elements, search for one
with a specific key.
We have studied 2 ways of searching: linear
search and hashing.
2
The problem
For linear search:
ave
Chapter 5
Trees
1
A 2-dimensional structure
A linked list is a one dimensional data
structure each element is followed by
exactly one other element (except for the
last).
2
A 2-dimensional structure
Chapter 5
Trees
1
A 2-dimensional structure
A linked list is a one dimensional data
structure each element is followed by
exactly one other element (except for the
last).
2
A 2-dimensional structure
COMP 2119A Introduction to Data Structures and Algorithms
Assignment One
Due Date: 04 October 2016 5:00pm
Assignment box: A3 (also submit a scanned copy to moodle)
[Note that for the questions involvi
COMP 2119A Introduction to Data Structures and Algorithms
Test 2
Date: 01 December 2016 (Thursday)
Time allowed: 100 minutes (2:30pm 4:10pm)
[Note that for the questions involving algorithm design, be
COMP 2119A: Solution for Assignment 1
1.
a) Answer:false.
Assume that 100n2 + 20n = (1000n), then c1 , c2 , n0 > 0, such that n n0 ,c1 (1000n) 100n2 +
20n c2 (1000n).
1
Then, we have c1 n + 50
c2 .
1
Algorithms
An algorithm is the (programming) language independent
and machine independent strategy that a program uses.
Algorithms are to programs like plots are to novels.
We can consider an algori
Outcome (2): Introduction to data structures
An Introduction to Data Structure
Terms: Data Types, Data Structures, Abstract Data Type (ADT)
Data Types
- provided by a programming language
- a set of v