Tokenization and parsing
We have implemented a small calculator. We can enter an expression, the calculator prints the value of the expression. How does the calculator get from the expression (which is just a string) to the value? This process is a very s
Stacks
A stack is an abstract data type based on the principle of Last In First Out (LIFO). Just think about a stack of books or dishes. A stack supports the following operations: Push something on the top. Look at the top. Pop something off the top of th
Searching and Sorting
Searching
An important use of computers is for looking up datahow often have you turned on your computer just to google for something? The process of looking up data is called searching. Common examples would be to look up a person i
References
Java distinguishes two kinds of variables. Variables of primitive type store a value directly. Primitive types are: byte short int long float double char boolean 8-bit integer 16-bit integer 32-bit integer 64-bit integer 32-bit oating-point 64-
Recursion
Recursion means to dene something in terms of itself. It is a powerful problem-solving technique. Example: Printing a number in any base What is the number 83790 in base 8. Yes, the answer is 2435168 . And how did you nd it? Its easy to nd the l
The Rank Tree
We introduce a data structure called the rank tree to solve the Josephus problem efficiently. The Josephus Problem n players, numbered 1 to n, are sitting in a circle; starting at player 1, a hot potato is passed; after m passes, the player
Quiz #1 Sep. 28, 2009 Student ID: Name:
A stack must provide the following operations. We make use of an interface in Java. public interface Stack<AnyType> cfw_ void clear(); boolean isEmpty(); AnyType top(); AnyType pop(); void push(AnyType x); We will
Programming a simulation
Simulation is an area where object-oriented programming really helps. This is because in a simulation, we typically have several things (objects) that interact with each other. We can model each thing by a Java class. Our project
Maps Maps
Let's add variables to our simple calculator. A variable should store a number.
>A => >3 => =7 A=7 * (A + 5) 5) 36
Building Building a concordance
How How to print the map
The Map interface allows to return all the key values in the map in a Set
Linked Lists
Linked lists can contain elements of the specified type. They are contained in nodes, and nodes are connected via links so that they have an ordering, see Fig. 1.
head .
Figure 1: A linked list At first we are going to deal with singly-linked
Java 1
Code Conventions for Java Programming Language
2008-07-03
1
Sun Microsystems Inc. Code Conventions for the Java Programming Language
( http:/java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html)
1 .4
1.1 (Code Conventions) .4
2 .5
2.1 (File Suffi
Implementing flood fill
Paint programs often offer a flood fill function. When you click a point, the entire region around the point is painted with your selected color. How does this work? Bitmaps A bitmap is a two-dimensional array, where each entry cor
Hash function - Wikipedia, the free encyclopedia
1 / 9
Hash function
From Wikipedia, the free encyclopedia
A hash function is any well-defined procedure or mathematical function which converts a large, possibly variable-sized amount of data into a small
B-tree
From Wikipedia, the free encyclopedia
In computer science, a B-tree is a tree data structure that keeps data sorted and allows searches, insertions, and deletions in logarithmic amortized time. It is most commonly used in databases and filesystems.
Wikipedia is sustained Binary search tree by people like you. Please donate today.
From Wikipedia, the free encyclopedia
In computer science, a binary search tree (BST) is a binary tree data structure which has the following properties: each node (item in
B+ tree - Wikipedia, the free encyclopedia
1 / 4
B+ tree
From Wikipedia, the free encyclopedia
In computer science, a B+ tree (BplusTree) is a type of tree which represents sorted data in a way that allows for efficient insertion, retrieval and removal o
Binary Trees Definition: A binary tree t is either empty or consists of an item, called the root item, and two ry disjoint binary trees, called left subtree and right subtree of t. t
The binary tree
is different from the binar y tree
A subtree of a binary
M Binary heapake a donation to Wikipedia and give the gift of knowledge!
From Wikipedia, the free encyclopedia
A binary heap is a heap data structure created using a binary tree. It can be seen as a binary tree with two additional constraints: The shape p
CS 61B: Lecture 25 Wednesday, October 25, 2006 Today's reading: Goodrich & Tamassia, Sections 8.1-8.3.
PRIORITY QUEUES = A priority queue, like a dictionary, contains _entries_ that each consist of a key and an associated value. However, whereas a diction
AVL tree
Make a donation to Wikipedia and give the gift of knowledge!
From Wikipedia, the free encyclopedia
In computer science, an AVL tree is a self-balancing binary search tree, and it is the first such data structure to be invented.[1] In an AVL tree,
Autoboxing and unboxing
Java type parameters can only be instantiated with object types, but not with primitive types. This is because the compiler can think about a type parameter simply as a reference to "something", without having to know what the some
Algorithm Analysis
Algorithm
An algorithm is a finite set of well-defined instructions that takes some set of values as input and produces some set of values as output to solve a problem. An algorithm is thus a sequence of computational steps that transfo
Abstract Data Types
An abstract data type (ADT) is a specication of the set of operations that can be performed on the data stored by the ADT. An ADT is abstract in the sense that it is independent of a concrete implementation. In Java, an abstract data t
CS 61B: Lecture 27 Monday, October 30, 2006 2-3-4 TREES = A 2-3-4 tree is a perfectly balanced tree. It has a big advantage over regular binary search trees: because the tree is perfectly balanced, find, insert, and remove operations take O(log n) time, e
Disjoint-set data structure - Wikipedia, the free encyclopedia
1 / 4
Disjoint-set data structure
From Wikipedia, the free encyclopedia
Given a set of elements, it is often useful to break them up or partition them into a number of separate, nonoverlappin