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
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
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]
2/9/17
Lecture 6: Analysis of Algorithms and Recurrence
Equations
Analysis of Iterative Algorithms
o Nested for loop : (n^2)
o While loop: (logn)
Recursive Algorithms
o To preform a running time analysis of a recursive algorithm
Define base case: cost is
Lecture 5: Asymptotic Behavior
Running time analysis
o For each algorithm we want to classify the asymptotic behavior of its work
o Find the best case and the worst case
Asymptotic Notation O (upper bound)
o You can use
F(n) = O(g(n)
You read it f(n) is
1/26/17
Lecture 2: Sorting Problem
Expressing algorithms
o We express algorithms in whatever way is the clearest and most concise. English
is sometimes the best way.
o To make algorithms perfectly clear, we will use pseudocode
o In the lab, you will trans
1/24/17
Lecture 1
Writing a program
o Understand the requirements of the program
o Structure the raw data of the problem in a informative way
o Design algorithms that use the structure data to solve to problem
o Implementing data structures and algorithms
2/2/17
Lecture 4: Mergesort
Mergesort: a sorting algorithm based on divide and conquer. Its worst-case running time
has a lower order of growth than insertion sort
o Because we are dealing with subproblems, we state each subproblem as sorting
a subarray A
1/31/17
Lecture 3: Divide and Conquer
Divide and Conquer
o Sometimes, the best way to solve a problem is by solving a smaller version of the
exact same problem first
o (Divide) solving a smaller problem of the same type
o (Conquer) using the solution to t
1/24/2017
Lecture 1
Cutello
CSCI 1112 | Prof.
Data Structures Intro
Data Structures A logical way of storing a collection of raw data
o This should allow to represent the relationships between elements of the data them, and
facilitate the operations that
CSCI 1112
Data Structures &
Algorithms
Hash Tables
Overview
Many applications require a dynamic set that
supports only the dictionary operations INSERT,
SEARCH, and DELETE.
Example: a symbol table in a compiler.
A hash table is effective for implementi
CSCI 1112
Data Structures &
Algorithms
Still About BST
BST definition
For every node, the value at that node is bigger (or not
smaller) than the value at its left child, and smaller (or not
bigger) than the value at its right child.
Some basic Java code
CSCI 1112
Data Structures &
Algorithms
Heap and Heapsort
V. Cutello
1
GWU: Spring 2017
Overview
q We define the ADT Heap
q Methods to build and maintain a heap
q Heapsort
q Priority Queues
V. Cutello
2
GWU: Spring 2017
Array as binary tree
qAn array A[1n]
CSCI 1112
Data Structures &
Algorithms
QUICKsort
Divide and conquer
qMerge sort: A sorting algorithm based on divide and conquer.
Its worst-case running time has a lower order of growth than
insertion sort.
qBecause we are dealing with subproblems, we sta
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
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
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
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
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
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
Java and Object-Oriented Design Review
01/28/2015
Software Development is the development of a software product.
Software Development Process
Requirements Analysis
Design
Implementation
Programming
Testing
Documentation
Training and Support
Maintenance
Ea