EE2331 Data Structures and
Algorithms:
Analysis of Algorithms
1
The Story
Once upon a time in a country,
a warrior won a crucial battle
and saved the country
The King was very happy and
gave a trunk of golden coins to
the hero
The warrior said: the tru
EE2331 Data Structures and
Algorithms:
Analysis of Algorithms
1
The Story
Once upon a time in a country,
a warrior won a crucial battle
and saved the country
The King was very happy and
gave a trunk of golden coins to
the hero
The warrior said: the tru
EE2331 Data Structures and
Algorithms
Introduction
1
Intended Learning Outcomes
Students should be able to
apply structural programming approach to solve more
complex computation problems;
demonstrate applications of standard data structures
such as li
CITY UNIVERSITY OF HONG KONG
Course Code & Title: EE2331 Data Structures and Algorithms
Session: Semester B, 200910
Time Allowed: Two hours
This paper has 7 pages (including this cover page).
Answer ALL questions in this paper.
Material, aids & instrument
CITY UNIVERSITY OF HONG KONG
& title. : EE233 1 Data Structures and Algorithms
Semester B, 20 1 3/14

>d : Two hours
Las FOUR pages (including this cover page)
apex consists of 4 questions.
2r AI.I. questions in this paper
eldbook examination.
Question 1: Given the following queue q represented by a circular array with
front 6 and rear 2
b
99
lleleelllllatlll
a Gill:
(:1) Draw the array, with front and rear and show the output after a dequeue operation is
done to q. 1 H
a?
W WWWWWWWWWWWWWWWWWWWW W
WW WWWWW WW W
WWW WWWWWW
5
H
WWW
WWWWWWWWWWWW WWW WWWWW W WWWW
WWWWWWWWWWW WWWWWWWWW WW WW
W WWWWWWWWWWWWWWWWWW
r;
E
?:
B <
2
Attempt al
City University of Hong Kong
Course Code & Title: EE2331 Data Structures and Algorithms
Semester/year: Semester A, 2010] 1
Time Allowed: Two hours
This paper has 10 pages (including this cover page)
Answer ALL questions in this paper.
Material, aids
City University of Hong Kong
Course Code & Title: EE2331 Data Structures and Algorithms
Semester/year: Semester B, 200809
Time Allowed: Two hours
This paper has 6 pages (including this cover page)
Answer ALL questions in this paper.
Material, aids & instr
EE2331 Data Structures and Algorithms
Assignment 2 Word Puzzle Solver
A word puzzle grid is a square grid of letters. Real games usually use a 4x4 or 5x5 grid,
but 2x2 and up are possible. The goal of the game is to find as many words as possible in
the g
EE2331 Data Structures and Algorithms
Assignment 1
You are a member of the SW team developing a program to store records of CityU long jump
competition. Your job is to implement a data structure, called record, to store jumper data. Each
record holds the
EE2331 (B) Data Structures and Algorithms
Tutorial 5.
1. Task 1. What does the following function do and what is the asymptotic time consumption given
in O notation.
void myFunction(int A[], int n, int& value)
cfw_
int maxCount = 0;
for (int i = 0; i < n;
EE2331 Data Structures and
Algorithms
Stacks and Queues
1
Abstract Data Type (ADT)
To manage the complexity of problems and the problemsolving
process, computer scientists use abstractions to allow them to focus
on the big picture without getting lost in
EE2331 Data Structures and
Algorithms
Introduction
1
Intended Learning Outcomes
Students should be able to
apply structural programming approach to solve more
complex computation problems;
demonstrate applications of standard data structures
such as li
EE2331 Data Structures and
Algorithms
Stacks and Queues
1
Abstract Data Type (ADT)
To manage the complexity of problems and the problemsolving
process, computer scientists use abstractions to allow them to focus
on the big picture without getting lost in
EE2331 Data Structures and
Algorithms
Trees
1
Remember?
How does a computer evaluate mathematical
expressions?
e.g. (4 + 5) * (7  2)
Use postfix expressions (4 5 + 7 2  *)
May we transform it to tree representation?
*
Tree representation
+
4

5
7
2
2
S
EE2331 Data Structures and
Algorithms
Recursion
1
Towers of Hanoi
A
B
C
The initial setup of the Towers of Hanoi
2
Towers of Hanoi
Three pegs, named as A, B, and C.
n disks each with different diameters, stacked in
order of diameter.
Disk with larger d
EE2331 Data Structures and
Algorithms
Trees
1
Remember?
How does a computer evaluate mathematical
expressions?
e.g. (4 + 5) * (7  2)
Use postfix expressions (4 5 + 7 2  *)
May we transform it to tree representation?
*
Tree representation
+
4

5
7
2
2
S
EE2331 Data Structures and
Algorithms
C+ Programming Review
1
Outline
Standard Libraries
Basic Data Types
Arithmetic, Bitwise, Logical Operators
Control Structures
Pointers
Arrays
Composite Structures
Parameter Passing in Functions
Standard I/O
Pseudo Cod
EE2331 Data Structures and
Algorithms
Linked Lists
1
Linear List
Each element in the list has a unique predecessor and
successor.
Unordered/Random list
There is no ordering of the data.
Ordered list
The data are arranged according to a key. A key is one o
EE2331 Data Structures and
Algorithms:
ObjectOriented C+ Review
1
Outline
Classes and Objects
Functions/Operators Overloading
Friend Function
NULL Pointer, Void Pointer and Function Pointer
Dynamic Memory Allocation
Templates
Inheritance
Virtual Function
EE2331 Data Structures and
Algorithms
Introduction
1
Intended Learning Outcomes
Students should be able to
apply structural programming approach to solve more
complex computation problems;
demonstrate applications of standard data structures
such as linke
EE2331 Data Structures and
Algorithms:
Analysis of Algorithms
1
The Story
Once upon a time in a country,
a warrior won a crucial battle
and saved the country
The King was very happy and
gave a trunk of golden coins to
the hero
The warrior said: the trunk
EE2331 (B) Data Structures and Algorithms
Tutorial 5.
1. Task 1. What does the following function do and what is the asymptotic time consumption given
in O notation.
void myFunction(int A[], int n, int& value)
cfw_
int maxCount = 0;
for (int i = 0; i < n;
TIE20106
1
TIE20106
1 Complexity notations
1.1 Asymptotic notations
This chapter discusses the notations used to describe the
asymptotic behaviour of algorithms.
2
The equation for the running time was simplied earlier
signicantly:
only the highest ord
EE2331 Data Structures and
Algorithms
Hashing
1
Outline
Introduction
Hash Operations
Search, insert, delete
Collisions Resolution
Chaining buckets
Linear probing
Quadratic probing
Double hashing
Design of Hash Function
Summary
2
Indexing
What i