Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department University of Regina Fall 2010
CS340 Fall 2010
1
1. Algorithm Analysis
1. Algorithm Analysis
1.1 Mathematics Review 1.2 Introduction to Algorithm Analysis 1.
University of Regina
CS 340
Assignment #4
Written Part: Graph Algorithms [48pts]
Exercise 1: exercise 9.6 page 379 (9.6 page 437 on 4th ed.) [4pts]
What is the worst-case running time of Djikstras algorithm when implemented with d-heaps.
Exercise 2 : exer
Alex Dalusong
200304912
Exercise 1:
What is the worst-case running time of Djikstras algorithm when implemented with d-heaps.
Answer:
Every time the main loop executes, one vertex is extracted from the queue. Assuming that there are V
vertices in the grap
CS 340
Assignment 3
Total: 100pts
Dr. Malek Mouhoub
Exercise 1 : exercise 7.41 page 310 [8pts]
1. Prove that any comparison-based algorithm to sort 4 elements requires 5 comparisons.
2. Give an algorithm to sort 4 elements in 5 comparisons.
Exercise 2 : e
Alex Dalusong
200304912
Exercise 1:
What is the worst-case running time of Djikstras algorithm when implemented with d-heaps .
Answer:
Every time the main loop executes, one vertex is extracted from the queue. Assuming that there are V
vertices in the gra
Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department
University of Regina
Fall 2016
1
3. Priority Queues
3. Priority Queues
ADT Stack : LIFO.
ADT Queue : FIFO.
ADT Priority Queue : pick the element with the l
Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department
University of Regina
Fall 2016
1
5. Graphs and Networks
CS340
5. Graphs and Networks
Plan :
5.1 Introduction and definitions.
5.2 Representation of Graphs.
Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department
University of Regina
Fall 2016
1
2. Trees
2. Trees
2.1 Preliminaries
2.2 Binary trees
2.3 Binary search trees
2.4 AVL and Splay trees
2.5 B-trees
2
2.1 Prelim
Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department
University of Regina
Fall 2016
1
4. Sorting and Order-Statistics
4. Sorting and Order-Statistics
The sorting problem consists in the following :
Input : a seq
Data Structures and Algorithm Analysis
Instructor: Dr. Malek Mouhoub
Computer Science Department
University of Regina
Fall 2016
1
6. Algorithm Design Techniques
6. Algorithm Design Techniques
6.1 Greedy algorithms
6.2 Divide and conquer
6.3 Dynamic Progra
Alex Dalusong
200304912
Exercise 1
1. Prove that any comparison-based algorithm to sort 4 elements requires 5 comparisons.
2. Give an algorithm to sort 4 elements in 5 comparisons.
Answer:
log 4! = log 24 < log 32 = log (2^5) = 5 comparisons required
For
Alex Dalusong
200304912
Exercise 1
1. Prove that any comparison-based algorithm to sort 4 elements requires 5 comparisons.
2. Give an algorithm to sort 4 elements in 5 comparisons.
Answer:
log 4! = log 24 < log 32 = log (2^5) = 5 comparisons required
For
2. Trees
2. Trees
2.1 Preliminaries 2.2 Binary trees 2.3 Binary search trees 2.4 AVL and Splay trees 2.5 B-trees
CS340 Fall 2010
1
2.1 Preliminaries
2.1 Preliminaries
Root A
B
C
D
E
F
G Height=3
Leaves
H
I
J
K
L
M
N
P
Q
CS340 Fall 2010
2
2.1 Preliminaries
Binary Trees in C+
Page 1 of 10
Binary Trees in C+
(Translated from the Java Verstion, see http:/math.hws.edu/javanotes/c11/s4.html)
WE HAVE SEEN how objects can be linked into lists. When an object contains two pointers to
objects of the same type, struc
CS340 Fall 2002 FINAL EXAM
Dr Malek Mouhoub December 11 2002 Duration : 3 hours (Total : 40pts)
Exercise 1 : Short Questions [5x1=5pts]
Dene the following concepts in your own words. 1. Decision tree versus spanning tree. 2. Greedy algorithm versus dynami
October 27 2006
Malek Mouhoub
CS 340 Midterm Exam
October 27 2006 Duration : 50 min - Total : 25pts
Exercise 1 : Algorithm Analysis [6pts]
Give an analysis of the running time (Big-Oh notation) for each of the following 4 program fragments. Note that the
CS3620 SPRING 2000 MIDTERM EXAM
Malek Mouhoub (02/29/99)
Exercise 1 (6 pts)
The input is an N by N matrix of numbers that is already in memory. Each individual row is increasing from left to right. Each individual column is increasing from top to bottom.
CS340 Fall 2002 MIDTERM EXAM (SOLUTION)
Malek Mouhoub October 23 2002 Duration : 75min
Exercise 1 : Short Questions [5pts]
Dene the following concepts in your own words. 1. Abstract Data Type. 2. Binary Search Algorithm versus Binary Search Tree. 3. AVL T
MIDTERM EXAM
Dr Malek Mouhoub
CS340 Winter 2006
March 01 2006 Duration : 75 min - Total : 25pts
Exercise 1 : Algorithm Analysis [6pts]
1. Give an analysis of the running time (Big-Oh notation) for each of the following 4 program fragments. Note that the r
CmSc 250 Fundamentals of Computing III
Homework 05 SOLUTION
1. Determine the running time of mergesort for
a. Sorted input
b. Reverse-ordered input
c. Equal elements
Explain your answers.
In the three cases the running time is O(NlogN). It is computed bas
Final Exam
Dr Malek Mouhoub
CS340 Winter 2006
Wednesday April 19 2006
Duration : 3 hours
Total : 50pts
(The question paper should be handed in with the completed examination)
Exercise 1 : Algorithm Design Techniques [0.5x6+0.5x6=6pts]
When introducing the