... ArrayList, and
Collection classes to the Stack and Queue classes and to the HashTable and
the SortedList classes. The datastructuresandalgorithms student can now see
how to use a data structure ... 20:59
Preface
The study of datastructuresandalgorithms is critical to the development
of the professional programmer. There are many, many books written on
data structuresand algorithms, but these ... Introduction to
Collections, Generics,
and the Timing Class
T
his book discusses the development and implementation of data structures
andalgorithms using C#. The datastructures we use in this book...
... (cont.)
<ErrorCode> Push (val DataIn <DataType>)
Pushes new data into the stack.
Pre DataIn contains data to be pushed.
Post If stack is not full, DataIn has been pushed in;
otherwise, ...
calling List’s operations.
Ex.:
<ErrorCode> Push (val DataIn <DataType>)
// Call List::InsertHead(DataIn)
or
// Call List::Insert(DataIn, 0) // 0: insert to the 1
st
position
end Push
<ErrorCode> ... Algorithm (cont.)
<ErrorCode> Push (val DataIn <DataType>)
// For Linked Stack
1. Allocate pNew
2. If (allocation was successful)
1. pNew-> ;data = DataIn
2. pNew->link = top
3. top =...
... of data, and
which data need to be
push into the stack?
Goal Seeking (cont.)
Tasks depend on each goal seeking problem:
Determine what kind of data included in graph (format for nodes and ... or all solutions, if exists.
Two of 92 solutions of Eight Queens Problem
36
What kind of data, and which data need to be push into the stack?
Usage of an ADT’s Object
In some compilers,
- When ... consider that task: making an
object empty before it’s using and before it’s going out of the scope
by writing its default constructor and destructor.
4
In our later pseudocode, in order
to use...
... 2008
Cao Hoang Tru
CSE Faculty - HCMUT
Pseudorandom
Pseudorandom
Number Generator
Key
Random
Number
Modulo
Division
Address
y = ax + c
For maximum efficiency, a and c should be prime numbers
40
01 December ... 560010 → 66
Spreading the data more evenly across the address space
32
01 December 2008
Cao Hoang Tru
CSE Faculty - HCMUT
Collision Resolution
ã Secondary clustering: data become grouped
along ... list resolution
ã Bucket hashing
27
01 December 2008
Cao Hoang Tru
CSE Faculty - HCMUT
Pseudorandom
ã Example:
Key = 121267 a = 17 c = 7 listSize = 307
Address = ((17*121267 + 7) MOD 307 + 1
=...
... Science and Engineering – HCMUT
0
count
head
After
list
list.count = 0
DataStructuresandAlgorithms –
C++ Implementation
Ho Chi Minh City University of Technology
Faculty of Computer Science and ... NULL;
}
Node(
ItemType
data) {
Slide 14Faculty of Computer Science and Engineering – HCMUT
Node(
ItemType
data) {
this-> ;data = data;
this->next = NULL;
}
ItemType data;
Node<ItemType> *next;
};
Nodes – ... Science and Engineering – HCMUT
a b c
head
a b
Result:
Insert Node Algorithm
Algorithm insertNode (ref list <metadata>,
val pPre <node pointer>,
val dataIn <dataType>)
Inserts data...
... Subprogram implementation
Recursion
Designing recursive algorithms
Recursion removal
Backtracking
Examples of backtracking and recursive algorithms:
Factorial
Fibonacci
The towers of ... same
calculations over and over.
The amount of time used by the recursive function to
calculate F
n
grows exponentially with n.
Simple iteractive program: starts at 0 and keep only three
variables, ... must look at the big picture and leave the detailed
computations to the computer.
28
Subprogram implementation
5
Print List in Reverse
19
Recursion
14
Tree and Stack frames of function...
... (heap is not full) AND (more data in listOfData)
1. listOfData.Retrieve(count, newData)
2. data[ count] = newData
3. ReheapUp( count)
4. count = count + 1
3. if (count < listOfData.Size() )
1. ... current_position is exists) AND
(parent.key > DataIn .key)
1. data[ current_position] = parent
2. current_position = position of parent
3. data[ current_position] = DataIn
4. count = count + ... <int>)
Reestablishes heap by moving data in position up to its correct location.
Pre All data in the heap above this position satisfy key value order of a heap,
except the data in position.
Post Data in position...
... entry into a node by shifting nodes to make room.
Pre node is pointer to node to contain data.
newEntry contains data to be inserted.
entryNdx is index to location for new data.
Post data have been ... Trees
ã Each node has m - 1 data entries and m subtree
pointers.
ã The key values in a subtree such that
:
>= the key of the left data entry
– < the key of the right data entry.
K
1
K
2
K
3
keys ... Pseudo code of algorithms for B-Tree Insertion
4
17 November 2008
Cao Hoang Tru
CSE Faculty - HCMUT
M-Way Node Structure
key data
num
entries
entry
key <key type>
data < ;data type>
rightPtr...
... of.
http://www.ourstillwaters.org/stillwaters/csteaching/DataStructuresAndAlgorithms/mf1201.htm (36 of 37) [1.7.2001 18:58:23]
DataStructuresand Algorithms: CHAPTER 1: Design and Analysis of Algorithms
"pointed to" by cursors, never by ...
http://www.ourstillwaters.org/stillwaters/csteaching/DataStructuresAndAlgorithms/mf1202.htm (2 of 40) [1.7.2001 18:58:59]
DataStructuresand Algorithms: Table of Contents
Data Structuresand Algorithms
Alfred V. Aho, ... possible.
http://www.ourstillwaters.org/stillwaters/csteaching/DataStructuresAndAlgorithms/mf1201.htm (14 of 37) [1.7.2001 18:58:22]
DataStructuresand Algorithms: CHAPTER 1: Design and Analysis of Algorithms
w of newclr and examine the...
... For example, Dr. Goodrich has taught data structures
andalgorithms courses, including DataStructures as a freshman-sophomore level
course and Introduction to Algorithms as an upper-level course. ... both the Data
Structuresand the Algorithms courses at the University of Maryland since 1985.
He has won a number of teaching awards from Purdue University, the University of
Maryland, and the ... examples of data structure and algorithm analysi
s.
ã We enhanced consistency with the C++ Standard Template Library (STL).
ã We incorporated STL datastructures into many of our data structures.
ã...
...
L
a
n
g
s
a
m
,
A
u
g
e
n
s
t
e
i
n
,
T
e
n
e
n
b
a
u
m
[
P
r
e
n
t
i
c
e
H
a
l
l
]
Data Structuresand
Algorithm Analysis in C
By Mark Allen Weiss
[Addison Wesley]
DataStructuresand Algorithms
City Univ of HK / Dept of CS / Helena ... source code and test case.
Any problem in this course?
I may contact you by email.
If you prefer NOT to receive my email, please inform me as soon as
possible.
DataStructuresand Algorithms
City ... approaching to success.
DataStructuresand Algorithms
City Univ of HK / Dept of CS / Helena Wong
0. Course Introduction - 3
http://www.cs.cityu.edu.hk/~helena
Programming Language and Tools
ã
We will...