Algorithm
An algorithm is a set of instructions to be followed to solve a problem:
there can be more than one solution (more than one algorithm) to solve a given problem,
an algorithm can be implem
Balanced Search Trees
The height of a binary search tree is sensitive to the order of
insertions and deletions.
The height of a binary search tree is between log2(N+1) and N.
So, the worst case beh
Hashing
Spring 2016
CS202 - Fundamental Structures of Computer Science II
1
Hashing
Using balanced search trees (2-3, 2-3-4, red-black,
and AVL trees), we implement table operations in O
(logN) time
Graphs
Initially prepared by Dr. Ilyas Cicekli; improved by various Bilkent CS202 instructors.
Spring 2016
CS202 - Fundamental Structures of Computer Science II
1
Graphs
Graphs are one of the unifyin
2-3 Trees & Red-Black Trees
Initially prepared by Dr. Ilyas Cicekli; improved by various Bilkent CS202 instructors.
Spring 2016
CS202 - Fundamental Structures of Computer Science II
1
2-3 Trees
Defini
Trees
Initially prepared by Dr. Ilyas Cicekli; improved by various Bilkent CS202 instructors.
Spring 2016
CS202 - Fundamentals of Computer Science II
1
What is a Tree?
T is a tree if either
r
T has
What is a (General) Tree?
A (general) tree is a set of nodes with the following properties:
The set can be empty.
Otherwise, the set is partitioned into k+1 disjoint subsets:
a tree consists of a
Trees
03/27/14
CS202 - Fundamentals of Computer Science II
1
What is a Tree?
T is a tree if either
T has no nodes, or
r
T is of the form:
T1
T2
Tk
where r is a node and T1, T2, ., Tk are trees.
03/
Balanced Search Trees
05/04/16
CS202 - Fundamental Structures of Computer Science II
1
AVL Trees
05/04/16
CS202 - Fundamental Structures of Computer Science II
2
AVL Trees
Definition:
An AVL tree is a
Analysis of Algorithms
Spring 2016
CS202 - Fundamentals of Computer Science II
1
Algorithm
An algorithm is a set of instructions to be followed to solve a problem.
There can be more than one solutio
Sorting and Searching
Spring 2016
CS202 - Fundamentals of Computer Science II
1
Problem of the Day
Spring 2016
CS202 - Fundamentals of Computer Science II
2
Sequential Search
int sequentialSearch( con
Tables
Appropriate for problems that must manage data by value.
Some important operations of tables:
An ordinary table of cities
Inserting a data item containing the value x.
Delete a data item co
What is a (General) Tree?
A (general) tree is a set of nodes with the following properties:
The set can be empty.
Otherwise, the set is partitioned into k+1 disjoint subsets:
a tree consists of a
Trace the following sorting algorithm for sorting the array 7 1 9 2 3 5 into ascending order.
Use the array implementation as described in the textbook/lectures.
Insertion sort
719235
179235
179235
12
CS 202 Fundamental Structures of Computer Science II
Assignment 1 Algorithm Analysis, Sorting and Searching
Due Date: June 21, 2010 (Monday)
Question-1 (30 points)
Trace the following sorting algorith
Tables
Appropriate for problems that must manage data by value.
Some important operations of tables:
An ordinary table of cities
Inserting a data item containing the value x.
Delete a data item co
Sorting Examples
CS 202
Department of Computer Engineering
Bilkent University
Slides adapted from Aybar Acar
Spring 2015
Spring 2015
c
2015,
CS 202 (Bilkent University)
1 / 14
Playing Cards
Spring 201
CS 202 - Fundamental Structures of Computer Science II
Spring 2003, Section 1
Quiz #1 Solution
Question: The following items are given: 80, 60, 70, 90, 85, 50, 55, 58, 57, 56.
a. Insert them into a bi
Algorithm
An algorithm is a set of instructions to be followed to solve a problem.
There can be more than one solution (more than one algorithm) to solve a given problem.
An algorithm can be implem