The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 1112 Algorithms and Data Structures
Spring 2014 Project 3
Due Date: April 22, 2014
Instructor: A. Bellaachia
Dictionary BST Using Dynamic Linked
Linked Lists Structures
Motivation:
o Insertion & Deletion in an ordered array require moving
elements up or down (left or right).
o Manipulating ordered lists of varying sizes
Example:
a
a
a
b
b
b
d Delete(d) =>
f
f
f
m Insert(k) =>
k
m
m
Solution:
o
Recursion
Definition:
o A procedure or function that calls itself, directly or indirectly, is
said to be recursive.
Why recursion?
o For many problems, the recursion solution is more natural than
the alternative non-recursive or iterative solution
o It
Stacks
Definitions:
o It is an LIFO ADT
o It is a list of elements where a new element is inserted or
pushed and deleted or popped only at the top of the list.
o Only the element at the top of the list is accessed
Example:
Operations:
o isEmpty: checks
Tree Structures
Definitions:
o A tree is a connected acyclic graph.
o A disconnected acyclic graph is called a forest
o A tree is a connected digraph with these properties:
There is exactly one node (Root) with in-degree=0
All other nodes have in-degre
Graphs
Motivations:
o Networks
o Social networks
o Program testing
o Job Assignment
Examples:
o Code graph:
S1
S1: int x
S2: If x > 0 then
S3:
Else
S4:
S2
X = x + 2;
S3
S4
X =x -1;
End if
S5
S5: While x > 1 do
S6:
Print x;
S7:
X = x -1;
End while
CSci 1
CS 1112: Algorithms and Data Structures
Syllabus
Fall 2016
Course and Contact Information
Course and Contact Information
Course: Department of Computer Science, Algorithms and Data Structures, CSCI 1112, section 10
Semester: Fall Semester, 2016
M
CSCI 1112
Data Structures &
Algorithms
Extending BST
Extending the BSTNode
qIn deciding if balancing, using rotations, and to
answer order-statistic queries, such as: can you give me
the 10th element of the tree ?, we extend the definition
of the node, to
CSCI 1112
Algorithms & Data Structures
Lecture 8
Recurrence equations
GWU: fall 2016!
V. Cutello!
Recursive Algorithms
q To perform a running time analysis of a recursive algorithm
Define base case : cost is costant
Compute the cost of dividing the inpu
Priority Queues
Definitions:
o A priority queue is a restricted form of a list, where items are
arranged according to their priorities (or keys). The key assigned to
an item may not be unique.
o The item with highest priority is removed in O(1).
o Each n
Queues
Objectives:
o Real life examples
Waiting in line
Waiting on hold for tech support
o Applications related to Computer Science
Threads
Job scheduling
Definition:
o It is an FIFO ADT
o A new element is added or inserted to the end of the list
o
The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 1112 Algorithms and Data Structures
Spring 2014 Project 4
Due Date: April 29, 2014 Midnight -Instructor: A. Bellaachia
Sorting
Description:
In c
The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 1112 Algorithms and Data Structures
Spring 2014 Project 2
Due Date: April 3, 2014
Instructor: A. Bellaachia
Polynomial Operations
Description
Yo
The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 1112 Algorithms and Data Structures
Spring 2014 Project 1
Due Date: March 18, 2014
Instructor: A. Bellaachia
Description:
In this project, you a
Sample Questions
Csci 1112
A. Bellaachia
Important Series :
N
S ( N ) 1 2 N i N (1 N ) / 2
i 1
o Sum of squares:
N
N ( N 1)(2 N 1) N 3
for large N
i2
6
3
i 1
o Sum of exponents:
N
N k 1
for large N and k -1
ik
| k 1|
i 1
o Geometric series:
N i AN 1 1
Abstraction and Abstract Data Types
Abstraction:
o Whatever is visible to the user?
Examples: Variable names & real numbers.
o How real numbers are implemented?
o How arrays are implemented?
The abstraction is rectangular arrays
The implementation is
Arrays, Vectors, Matrices
Goal:
o Scientific Eng.
o Numerical computations
o Array are very efficient way of organizing data since accessing
array elements requires O(1).
Characteristics of an array:
o Arrays are one the main data organization
o Arrays
Performance Analysis
Motivation:
o Estimation of required resources such as memory space, computational
time, and communication bandwidth.
o Comparison of algorithms
Model of implementation:
o One-processor RAM (random-access machine) model.
o Single op
Course Summary
Performance Analysis
o Estimation of required resources such as memory space, computational
time, and communication bandwidth.
o Comparison of algorithms
o Common time functions:
If F is:
Say that F is:
If F is:
Say that F is:
O(nr), 1<r<2
Hashing
Goal:
o Perform insertions, deletions, and search in constant
time: O(1).
o Example:
Many compilers use Hashing to implement their symbol
tables
Hash Tables:
o A hash table is an ADT where insertion, deletion, and search
take a constant time: O
CSCI 1112
Data Structures &
Algorithms
Heap and Heapsort
GWU: Fall 2016!
1
V. Cutello!
Overview
q We define the ADT Heap
q Methods to build and maintain a heap
q Heapsort
q Priority Queues
GWU: Fall 2016
2
V. Cutello
Array as binary tree
q An array A[1n]