Linked Lists and Generics
Written by J.J. Shepherd
Data Structures
Data structures are used to organize and store
data.
All the data structures are used to group
together like data with some defined
CSCE 146 Exam 1 Review
Part 1 Java Review
This part went over the basics of Java, and the focus was mostly on arrays. There will be no questions
that involve reading from and writing to files.
Short A
CSCE 146 Exam 2 Review
Part 6 Searching, Sorting, Asymptotics
1. Sort these Big O times in bounding order. IE One given can be bounded by the next one, then the
next one, etc.
O(n)
O(n2)
O(nlg(n)
O(n3
CSCE 146 Exam 1 Review
Part 1 Java Review
This part went over the basics of Java, and the focus was mostly on arrays. There will be no questions
that involve reading from and writing to files.
Short A
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">
/*
* Linked list with an iterator. One node is the "current node."
*
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">
public class Person
cfw_
private String name;
public Person( )
cfw_
n
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">
/*
* Linked list with an iterator. One node is the "current node."
*
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">import java.util.Scanner;
public class GenLinkedListTester
cfw_
public
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">/*
* Written by JJ Shepherd
* Used to draw a random fractal line by su
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">/*
* Written by JJ Shepherd
* Used to draw an example of Sierpenski Ca
<html><head></head><body data-pinterest-extension-installed="sa1.37.01"><pre style="wordwrap: break-word; white-space: pre-wrap;">
public class Student extends Person
cfw_
private int studentNumber;
p
Graphs
By JJ Shepherd
Introduction
Graphs are simply trees
with looser restrictions
You can have cycles
Historically hard to deal
with in computers than
trees
Following a graph could be
open ended
Heaps
By JJ Shepherd
Introduction
Heaps are another
type of binary tree
Each node has to
have some
comparable value
Think of each of
these values as a
priority
Introduction
Is always balanced as
e
Trees Part 2!
By JJ Shepherd
Binary Search Tree
A tree structure where each
node has a comparable key
If a nodes value is larger
than its parents it goes to
the right subtree
If a nodes value is sm
Lab Report Template
Problem
State the given problem clearly in ones own words.
Proposed Solution
Give a hypothesized algorithm to solve the problem. This description must be a detailed and
high-level
CSCE 146: Algorithmic Design II
1. Course number and name: CSCE 146: Algorithmic Design II
2. Credit: 4-hrs; Contact: 2 lectures of 75 minutes each; 1 lab of 1 hour, 55 minutes each per
week
3. Instru
Lecture 11
Doubly Linked Lists
& Array of Linked Lists
In this lecture
Doubly linked lists
Array of Linked Lists
Creating an Array of Linked Lists
Representing a Sparse Matrix
Defining a Node for a Sp
java04.frm Page 171 Saturday, August 26, 2000 6:03 PM
171
Linked Lists
The simplest way to interrelate or link a set of elements is
to line them up in a single list . . . For, in this case, only a
sin
Linked Lists and Generics
Part 2
Written by J.J. Shepherd
Last Time
Linked Lists!
Set up
Adding
Iterating
Removing
Linked List
Has nodes that contain
Data
Links to other nodes
Resizable
But
Reverse Polish Notation
Written by J.J. Shepherd
Reverse Polish Notation
Most math expressions you have seen were
written in in-fix notation
Example:
3+5
However there is another notation called po
Queues
Written by J.J. Shepherd
Queues
This data structure works on the principle first
in first out (FIFO)
Waiting in a line is a great example
Steam updates
In a line waiting for chicken fingers
Stacks
Written by J.J. Shepherd
Stacks
This data structure works on the principle last
in first out (LIFO)
Any kind of pile is a good way to think of a
stack
A stack of games
Pile of exams
Stacks
Search Algorithms
Written by J.J. Shepherd
Sequential Search
Examines each element one at a time until the
item searched for is found or not found
Simplest search algorithm!
Example!
Binary Search
Trees
By JJ Shepherd
Introduction
Last time we discussed searching and sorting
in a more efficient way
Divide and Conquer
Binary Search
Merge Sort
Quick Sort
Lets look at a data structure that u
Quad Trees
By JJ Shepherd
Introduction
So far weve only used binary trees to solve
problems
Sort data
Search data
Confuse students
Trees are not just limited to having two
children
Introduction
Homework 01
Due 01/22/2015 11:55pm
Tic Tac Toe Tourney
Objective:
Write a program where a user plays a games of Tic Tac Toe against the computer, and tries to remains
undefeated for as long as possibl
Homework 06
Due 03/25/2015 11:55pm
Shape Tree
Objective:
Write a program which creates a binary search tree of different shapes from a file.
The comparison is based on the shapes area
There are 3 sh
Lab 08
Array Tree of Integers!
Objective:
This seems strangely familiar. Create a binary search tree but with an array implementation. The data
contained in this tree is positive integers, so it may h