CSE 2123
Collections: Sets and Iterators
(Hash functions and Trees)
Jeremy Morris
1
Collections - Set
What is a Set?
A Set is an unordered sequence of data with no
duplicates
Not like a List where you know where in the collection
you can find a data eleme
CSE 2123
Java Review
Jeremy Morris
1
Outline
Programming and Java
Program Structure
Programming Review
Variables & Expressions
Flow Control & Methods
Arrays
File I/O
2
Programming and Java
What is a computer program?
Can be trivial
Series of instructions
CSE 2321 Homework 3
Due Monday, September 26 at the beginning of class. All work should be done neatly on
separate paper (not on this page of problems). You should use standard size (8.5 by 11) plain or
lined paper (Do not use graph paper). Staple your pa
CSE 2321 Homework 1: Solutions
1. Use a truth table to determine if the exclusive-or operator is associative. That is, does
(p q) r = p (q r) for all values of p, q, and r?
(5 pts)
Solution:
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
F
F
T
r
T
F
F
T
T
T
F
F
pq
F
F
T
T
CSE 2321 Homework 2 Grading Rubric
.
1. Determine if the following proposition is a tautology, contingency or a contradiction in two
different ways: (i) By using a truth table and (ii) by using logical equivalences.
(4 pts each part
(p q) (q p)
Solution (
CSE 2123
Course Introduction
Len Madrid
1
Topic Outline
Basic Information
Course Description
Course Syllabus, Grades, Policies
Course Approach
Quick review
2
Basic Information
Lecturer: Len Madrid
Office: Caldwell Labs 417
Office Hours: Mo 3:00-4:30pm or
Karl S Jayawan
CSE 2123
Homework #7
public class Homework7 cfw_
public static Queue<Integer> filterOnMax(Queue<Integer> input, int max)cfw_
Queue<Integer> q1 = new LinkedList<Integer>();
for(int i = 0; i< input.size(); i+)cfw_
int x = input.remove();
if(x
CSE 2123
ArrayLists
Jeremy Morris
1
A programming problem
Consider the following task:
You have a file containing a list of purchases
Maybe from an online ordering system
You are writing an application that needs to be
able to compute:
The median dollar a
CSE 2123
Search
Jeremy Morris
1
Problem Specification: Search
Given a list of values and an element k, find
the index of k in the list
Output not found if k is not in list
2
Problem Specification: Search
For our lecture examples, we will make a few
assump
CSE 2123
Sorting
Jeremy Morris
1
Problem Specification: Sorting
Given a list of values, put them in some kind
of sorted order
Need to know:
Which order?
Increasing?
Decreasing?
What does sorted order mean?
integers, doubles numerical order
Strings, charac
CSE 2123
Object-oriented Programming:
Objects & Classes
Jeremy Morris
1
Object-oriented programming
Youve all heard this buzzword before
If nowhere else, you heard it the first day of class!
What do we mean by it?
A form of programming based around viewin
CSE 2123
Object-oriented Programming:
Interfaces
Jeremy Morris
1
Interfaces
Recall: The public interface is the methods
that a class presents to the world to use
The Java language has a related idea as a
language construct the interface
An interface speci
CSE 2123:
Collections: Queues and Stacks
Jeremy Morris
1
Collections - Queue
A queue is a specific type of collection
Imagine a line for a bank teller or a checkout
lane at a store
Contains many people
But only the one at the head of the queue (line)
will
CSE 2123:
Collections: Maps
Jeremy Morris
1
Collections - Map
A map is another kind of collection
Different from previously discussed examples
Lists, Queues, Stacks are all linear collections
Sets are unordered collections
Some meaning to the underlying o
CSE 2123:
Collections: Priority Queues
Jeremy Morris
1
Collections Priority Queue
Recall: A queue is a specific type of collection
Keeps elements in a particular order
Weve seen two examples
FIFO queues
Stacks (LIFO queues)
What if we want to keep things
CSE 2123
Recursion
Jeremy Morris
1
Past Few Weeks
For the past few weeks we have been
focusing on data structures
Classes & Object-oriented programming
Collections Lists, Sets, Maps, etc.
Now we turn our attention to algorithms
Algorithm: specific process