CS 284 Algorithms Summer semester 2010 Lab 3 Lab objectives: - Understand the heap properties. - Implements Heap sort using different techniques. Related chapter(s): 6. Lab instructions (steps): 1. Write the following program and run it.
#include <time.h>
CS 1901441: Algorithms
Module 3: Quicksort
1
Quicksort
Sorts in place
Sorts O(n lg n) in the average case
Sorts O(n2) in the worst case
But in practice, its quick
And the worst case doesnt happen often (but more
on this later)
2
Quicksort
Another divide
CS 1901441: Algorithms
Module 2: Heapsort
1
Sorting Revisited
2
Heaps
A heap can be seen as a complete binary tree:
16
14
10
8
2
7
4
9
3
1
A complete binary tree has all leave nodes at the
same level and all internal nodes have degree 2.
3
Heaps
A heap
CS 1901441: Algorithms
Module 4 - Binary Search Trees
1
Review: Binary Search Trees
Binary Search Trees (BSTs) are an important
data structure
Elements have:
key: an identifying field inducing a total ordering
left: pointer to a left child (may be NUL
CS 1901441: Algorithms
Module 1:
Introduction
Proof By Induction
Asymptotic notation
Divide and Conquer paradigm
Recurrences
The Course
Purpose: a rigorous introduction to the design
and analysis of algorithms
Not a lab or programming course
Not a math
CS 1901441: Theory of
Algorithms
Module 0: Growth of Functions
Runtime Analysis
Elementary operation:
An operation whose execution time can be bounded above by a
constant depending on implementation used.
Assume all elementary operations can be executed
CS 1901715: Algorithms
Module 8: NP Completeness
1
Dynamic Programming
When applicable:
Optimal substructure: optimal solution to problem
consists of optimal solutions to subproblems
Overlapping subproblems: few subproblems in
total, many recurring ins
CS 1901441: Algorithms
Module 5: Red-Black Trees
Red-Black Trees
Red-black trees:
Binary search trees augmented with node color
Operations designed to guarantee that the height
h = O(lg n)
Red-Black Properties
The red-black properties:
1. Every node i
CS 1901715: Algorithms
Module 6: Introduction to Hashing
1
Review: Red-Black Trees
Red-black trees:
Binary search trees augmented with node color
Operations designed to guarantee that the height
h = O(lg n)
We described the properties of red-black tre
CS 1901715: Algorithms
Module 9: B-Tree
1
B-Trees
2
Motivation for B-Trees
So far we have assumed that we can store an
entire data structure in main memory
What if we have so much data that it wont fit?
We will have to use disk storage but when this
happ
CS 284 Algorithms Summer semester 2010 Lab 2 Lab objectives: - Understand how the recurrence relations work. - Understand the recurrence relations having order ( n log(n) ) solutions. Related chapter(s): 4. Lab instructions (steps): 1. Write the following
CS 284 Algorithms Summer semester 2010 Lab 7 Lab objectives: - Understand and implement the graph searching algorithms. Related chapter(s): 22. Lab instructions (steps): 1. Write the following program and run it.
#include <iostream> #include <ctime> #incl
CS 215 Project T he manager of the Diner by the JUST campus deli plans to have a computer available for students to place their orders when they enter t he campus center. They have a limited menu selection available that i nclude sandwiches and drinks. Th
Programming the Basic Computer
Chapter 6 Programming the Basic Computer
Computer Organization
1
Programming the Basic Computer
PROGRAMMING THE BASIC COMPUTER
Introduction
Machine Language
Assembly Language Assembler
Program Loops
Programming Arithmetic an
Microprogrammed Control
MICROPROGRAMMED CONTROL
Control Memory Sequencing Microinstructions Microprogram Example Microinstruction Format Design of Control Unit
1
Microprogrammed Control
Implementation of Control Unit
COMPARISON OF CONTROL UNIT IMPLEMENTA
Central Processing Unit
CENTRAL PROCESSING UNIT
Introduction General Register Organization Stack Organization Instruction Formats Addressing Modes Data Transfer and Manipulation Program Control
1
Central Processing Unit
Introduction
MAJOR COMPONENTS OF C
Memory Organization
MEMORY ORGANIZATION
Memory Hierarchy Main Memory
1
Memory Organization
Memory Hierarchy
MEMORY HIERARCHY
Memory Hierarchy is to obtain the highest possible access speed while minimizing the total cost of the memory system
Auxiliary me
CS 284 Algorithms Some Sample Final Exam Questions 1) During a breadth-first search, the status of a gray vertex is: a) It has been completely processed. b) It is in the FIFO queue. c) It is in the priority queue. d) It is undiscovered. 2) The number of e
CS 284 Algorithms Summer semester 2010 Lab 4 Lab objectives: - Understand the three different partition techniques used in quick sort used in chapter 7. - Compare the performance of these techniques. Related chapter(s): 7. Lab instructions (steps): 1. Wri
CS 1901441: Algorithms
Module 7: Graph Algorithms
1
Graphs
A graph G = (V, E)
V = set of vertices
E = set of edges = subset of V V
Thus |E| = O(|V|2)
2
Graphs Terminology
3
Graphs Terminology
4
Graphs Terminology
5
Graphs Terminology
6
Graphs Terminol