160 likes | 170 Views
This course covers advanced programming concepts, with a focus on algorithms and data structures. Topics include traversals and searches, sorting, lists, stacks, queues, and more. Students will also learn about event-oriented programming, GUI building, software design, and abstract data types.
E N D
Course Overview CS221 – Advanced Programming Fall 2007 : Ray S. Babcock Computer Science Department Montana State University
Finally! Not an introductory course! • An old 1976 book had the following title: • Algorithms + Data Structures = Programs • By Nicklaus Wirth • Both Algorithms AND Data Structures should be considered equally important when solving problems using programs. • Time – Space tradeoff. • Time and space are inversely proportional. Course Overview
Time VS Space • To produce the same solution in less space (memory) an increase of computation time is necessary. • The Invoice File Sorting Problem from 1975. • Many invoices for each month during the year. • Random Access Memory was extremely limited. 64K • Yes, only 64K, and the OS took up 32K!! • Can’t load all the invoices into RAM. • Can load all the invoices on the huge 128K 8-inch Floppies. • No disk sort commands (like the Linux sort command). • How would you solve this problem? Course Overview
The Invoice File Solution • The disk (floppy) file management system had up to 16 file units. • A separate file can be “opened” on each file unit. • We opened a separate file for each month: • Opened “Jan” on file unit 1. • Opened “Feb” on file unit 2. • … • Opened “Dec” on file unit 12. • Opened “Input” on file unit 13. Course Overview
Invoice File Solution (continued) • Now for each Invoice in the input file (opened on 13) • Read one invoice into memory. • Extract the month code (1 – 12) as an integer. • Write the invoice to the “month” file unit. • Repeat. • Close all 13 file units. • One pass through the input file and it was done! • Only memory for one invoice needed! • Cool! Course Overview
Algorithms • In this course we will cover extensively • Traversals and Searches • Linear • Binary • Sorting • Selection • Bubble • Insertion • (and more lightly: Shell, Merge, Heap, and Quicksort) Course Overview
Data Structures • In this course we will cover extensively • Lists • Stacks • Queues • We will touch lightly on • Trees • Priority Queues • Graphs Course Overview
Course Title? • Advanced Programming (new) versus Data Structures (old) ? • Event-Oriented Programming. • Java AWT and SWING for GUI building. • UML (appendix B and used throughout). • Software Design. • Program Correctness and Efficiency (Big O notation). • Java Inheritance. • Java Class Hierarchies. • And last but certainly not least Abstract Data Types. Course Overview
What is a type? • What does it mean by specifying: • int • double • boolean • String • Is 2+2 calculated the same as 2.0+2.0 ? • What does memory look like? Course Overview
Segment from a CS425 program that displays a bézier curve! (obviously ) Course Overview
A Type Simply limits • The values • The operations • Helps prevent the following: • Assume I let and integer MONTH stand for the current month. (1 = Jan, 2 = Feb, … 12 = Dec). • Now I work my way through the year by using MONTH = MONTH + 1 • What happens when I use that expression when MONTH equals 12? What is month 13? • The March 0 story. Course Overview
Some In Class Examples. • Given: (ignore the – bullets!) • int a = 2; • int b = 4; • int c = 5; • double d = 1.2; • double e = 2.4; • double f = 3.6; • double g = 1.55; • double sum = 0.0; • What prints System.out.println(expression); Course Overview
Integers a=2,b=4,c=5Doubles d=1.2,e=2.4,f=3.6,g=1.55,sum=0.0 • (a/b) • 0 • (b/a) • 2 • (1/a) • 0 • c/a • 2 • a/d • 1.6666666666666667 Course Overview
Integers a=2,b=4,c=5Doubles d=1.2,e=2.4,f=3.6,g=1.55,sum=0.0 • (e/d) • 2.0 • (f/2) • 1.8 • (2147483647 + 1) • -2147483648 • Did you get them all right? • You’re playing with type and internal representation! Course Overview
What about the following? sum = 0.0; for(int i=0; i<100; i++) sum=sum+g; System.out.println(“sum=“+sum); • What Prints? • sum=155.00000000000003 • Why? Course Overview
ADT • The built-in types don’t cover all our needs. • Most modern languages allow us to define an Abstract Data Type. • We define • The type name. • The permitted values. • The permitted operations (methods) • Often, one of the first things to design for a solution are a set of Abstract Data Types. • We’ll do this often in this course. Course Overview