Lecture 2
Big-O Notation
O stands for the order of
Also called asymptotic analysis
O(N): linear to N E.g. N and N/2
O(logN): order of log N E.g. log2N and log3N
O(N) > O(logN)
Defining Running Time
We can parameterize the running time of a method by
ECE 242: Data Structures and Algorithms- Fall 2017
Project 1: FunWithWords (Arrays+ Simple Sorting+ Search)
Due Date: Deadline: see website and moodle for submission
Description
This project is intended to familiarize you with operations on arrays such as
Xueteng Qian
HW1- 242- Fall 2017
(BONUS: 5pts)
Find the big-O complexity ?
N
1
ln(n)
N^3
N^2
m*(ln(n)
How many comparisons are needed to sort this array A using insertion sort?
1+1+3+1+4+1+6+4+2=23
Lecture 14
Last Class Review
Problem: How can I efficiently locate data within a data structure
Searching for data is a fundamental function of computers
Many different search algorithms exist
The simplest ones discussed today
We evaluate search a
Lecture 12
Last Class Review
Problem: How do access all members of a list efficiently?
Iterators make it easy to repetitively access members of a list
Iterators are objects
Iterators will be important tools for sorting and searching
The use of ite
Lecture 11
Last Class Review
Size grows as needed
Data manipulation is efficient
Add, remove, etc.
Linked List implementation is more efficient than array
We will lots more implementations and
Lecture 1
Eclipse Demo
Eclipse is powerful
Check on-line resources for suggestions on use
Several different views allow for customization
Very powerful debugger
Allows for easy breakpoint setting
Allows for traces of program operation
Full view of
Lecture 8
Last Class Review
Problem: Can we implement data structures using
something other than arrays?
Individual objects can be more flexible
Use references to find neighbors
Iterators will be important tools for linked lists
Search through
Lecture 7
Exceptions
Exceptionsenableustorecovergracefullyfrom errors.
Example:
- Dividingbyzero.
- Followinganullreference
- Lookingatelement-1ofanarray.
Exception
Unusual event that occurs during the operation of a
program.
Wediscussedthislas
Lecture 6
Last Class Review
Problem: How can I use stacks
Stacks are fundamental to subroutine calls
Error recovery an important part of stack usage
Stacks: examples
Reverse characters in a string
Bracket checking
Simple card game
Building t
Lecture 4
Last Class Review
Techniques for storing large amounts of data
Stacks lots of examples in everyday life
Easy to implement in Java
Lots of fun applications
Approaches for implementing stacks
Array based implementation
Use of interfac
Lecture 3
Analyzing Loop Execution
A loop executes a certain number of times (say n)
Thus the complexity of a loop is n times the
complexity of the body of the loop
When loops are nested, the body of the outer loop
includes the complexity of the
BIG O
Sorting:
Type of sort
Worst case
Expected case
Insertion sort
Selection sort
Mergesort
Quicksort
O(n^2)
O(n^2)
O(n*logn)
O(n^2)
O(n^2)
O(n^2)
O(n*logn)
O(n*logn)
Which is faster, insertion or selection? _
Why? _
Which do people prefer, Mergesort or