{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

100_lecture23

# 100_lecture23 - Introduction to Computation and Problem...

This preview shows pages 1–6. Sign up to view the full content.

1 Introduction to Computation and Problem Solving Prof. Steven R. Lerman and Dr. V. Judson Harward Class 23: Class 23: Introduction to Data Introduction to Data Structures: Stacks and Queues Structures: Stacks and Queues 2 Algorithms, Data Structures, and Patterns An algorithm is a precise but not necessarily formal description of how to solve a class of computational problem. Examples: insertion sort, Newton's method, A data structure is a general method of storing and accessing data that optimizes or organizes one or more aspects of data access, e.g., speed, ordering, etc. Examples: arrays, ArrayList A pattern is a strategy for solving a problem, specific enough to be recognizable, but general enough so that the programmer will customize it for each case. Examples: next lecture! 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3 Data Structures queued in Java: the event queue. What makes a queue a queue? A good example is a queue. We encounter queues all the time in every day life. You have already encountered a very important 4 Queues A queue new items at one end and remove old items from the other. n+1 n n-2 n-1 ... 2 3 4 1 Add items here Remove items here is a data structure to which you add 2
5 Queue Operations Add an item: Add a 3 rd item: 1 2 1 3 2 1 tail Add another item: head 6 Queue Operations, 2 Remove an item: Remove another item: 3 2 tail 3 2 tail 4 3 tail 4 1 2 Add another item: head head head 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
7 Queue Interface public interface Queue { public boolean isEmpty(); public void add( Object o ); public Object remove() throws NoSuchElementException; public void clear(); } 8 the data structure abstract data type (ADT), and provides a concrete data type (CDT) . Example: The List interface and the classes ArrayList and LinkedList . Abstract vs Concrete Data Types The “data structure” actually combines two object- oriented concepts: interface , which defines an a particular implementation of that interface that 4
9 Uses for Queues transfer. information at independent rates. The Java event queue is a good example.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 16

100_lecture23 - Introduction to Computation and Problem...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online