Data Structures & Algorithms
Sheet #1
st
1 Year
Cairo University
Faculty of Engineering
Computer Engineering Department
Data Structures and Algorithms
Sheet #3
[1]
Write an algorithm to implement two stacks using only one array. Your stack algorithm shoul
Recursion
CS221N, Data Structures
1
Final Exam
In case anyones making travel plans now
Wednesday, December 10
12 noon 3 PM
Location: TBA
2
Recursion
Definition
A programming technique where a function calls itself
Very effective technique in programming
U
Data Structure #2: Arrays
CS202, Data Structures
1
The Array
Most commonly used data structure
Common operations
Insertion
Searching
Deletion
How do these differ for an ordered array?
How do these differ for an array which does not allow
duplicates
Stacks and Queues
CS202, Data Structures
1
New Structures
Stack
Queue
Priority Queue
Whats new?
Contrast with arrays
Usage
Access
Abstraction
2
Usage
Arrays are conducive for databases
Data which will be accessed and modified
Easy operations fo
Graphs
CS202, Data Structures
1
Graphs
Graphs are a data structure which represent relationships
between entities
Vertices represent entities
Edges represent some kind of relationship
2
Example
The graph on the previous page could be used to model San
Linked Lists
CS202, Data Structures
1
Recall Arrays
Advantages
Access is fast O(1)
Insertion is fast in an unordered array O(1)
Searching is fast in an ordered array O(log n)
Because we can apply the binary search
Disadvantages
Deletion is slow O(n
Binary Trees
(Huffman Codes)
CS202, Data Structures
1
Huffman Codes
An algorithm to compress data
Purpose:
Apply a compression algorithm to take a large file and store it as
a smaller set of data
Apply a decompression algorithm to take the smaller
com
Binary Trees
CS202, Data Structures
1
Binary Trees
A fundamental data structure
Combines advantages of arrays and linked lists
Fast search time
Fast insertion
Fast deletion
Moderately fast access time
Of course, theyre a bit more complex to impleme
Hash Tables
CS202, Data Structures
1
Hash Tables: Overview
Provide very fast insertion and searching
Both are O(1)
Is this too good to be true?
Disadvantages
Based on arrays, so the size must be known in advance
Performance degrades when the table b
M48_LIAN0807_08_SE_C48.QXD
11/19/09
7:04 AM
Page 481
CHAPTER 48
HASHING
Objectives
To know what hashing is for (48.3).
To obtain the hash code for an object and design the hash function to map a key to
an index (48.4).
To handle collisions using open addr
M47_LIAN0807_08_SE_C47.QXD
11/19/09
7:00 AM
Page 471
CHAPTER 47
RED-BLACK TREES
Objectives
To know what a red-black tree is (47.1).
To convert a red-black tree to a 2-4 tree and vice versa (47.2).
To design the RBTree class that extends the BinaryTree cla
Pseudo code Tutorial and Exercises Teachers Version
Pseudo-code is an informal way to express the design of a computer program or an algorithm in
1.45. The aim is to get the idea quickly and also easy to read without details. It is like a young child
putt
Data Structures & Algorithms
Sheet #1
1st Year
Cairo University
Faculty of Engineering
Computer Engineering Department
Data Structures and Algorithms
Sheet #1
[1]
Given two sorted (ordered) sequential lists (arrays) L1 and L2, write an efficient algorithm
Data Structures & Algorithms
1st Year
Sheet #4
Cairo University
Faculty of Engineering
Computer Engineering Department
Data Structures and Algorithms
Sheet #4
[1]
Order the following functions by growth rate:
, ,
.
,
,
log
,
log log
,
log
,
(
),
2
, 2 , 2
How to write pseudocode There are six basic computer operations 1. A computer can receive information Read (information from a file) Get (information from the keyboard) 2. A computer can put out information Write (information to a file) Display (informati
Csci 2111: Data and File
Structures
Instructor: Nathalie Japkowicz
e-mail: [email protected]
Objectives of the Course
and
Preliminaries
January 10, 2000
1
Objectives of The Course
To Provide a Solid Introduction to the Topic of
File Structures Design.
To Di