Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS215 Module 0 - Intro 1 MIS 215 Module 0 Intro to Data Structures.

Similar presentations


Presentation on theme: "MIS215 Module 0 - Intro 1 MIS 215 Module 0 Intro to Data Structures."— Presentation transcript:

1 MIS215 Module 0 - Intro 1 MIS 215 Module 0 Intro to Data Structures

2 MIS215 Module 0 - Intro 2 Where are we? Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners MIS215 Binary Search Search Techniques Sorting Techniques Bubblesort Basic Algorithms Fast Sorting algos (quicksort, mergesort) Hashtables Graphs, Trees Linked Lists Stacks, Queues List StructuresAdvanced structures

3 MIS215 Module 0 - Intro 3 Today’s Buzzwords Data Structures Algorithms Efficiency of algorithms Analysis of algorithms Programming = Data Structures + Algorithms Programming as a problem-solving method Elluminate

4 Nuts and Bolts of this Class Elluminate  A tool for Synchronous Online Collaboration  This course will be all about collaboration  Start by clicking the link in the Course Calendar in WebCT  Allow Elluminate to install  Do not click on the microphone while in class! (believe me – bad things will happen if you do) Dr. Java and JDK 1.5 MIS215 Module 0 - Intro 4

5 Elluminate features we will use Definitely:  Private and moderator chats  Drawing board  Polling and quizzing Possibly:  Project presentations  Out-of-class meetings  Online office hours MIS215 Module 0 - Intro 5

6 6 Introduction to Data Structures What are data structures/ruptures & algorithms good for? Overview of data structures. Overview of algorithms Some definitions OO programming S/W engineering Java Library Data Structures

7 MIS215 Module 0 - Intro 7 What’s a program? So, far, if you’ve only done CS 208/209/equivalent, what has a program been? Probably, just doing some simple data manipulation..  store some grades in an array  average the grades, find min/max  anything else??

8 MIS215 Module 0 - Intro 8 Overview of Data Structures Arrays (unordered and ordered) Stacks, Queues, Lists  why did I lump these all together? Trees (binary, red-black [?], 2-3-4 [?]) Hash table Heap

9 MIS215 Module 0 - Intro 9 Our approach to Problem Solving this quarter Dr. Java Integrated Development Environment Edit – Compile – Test – Debug Unfortunately CaTS won’t install in labs Fortunately it doesn’t take much to install Lets use Dr. Java to write our first program

10 MIS215 Module 0 - Intro 10 HelloWorld.java public class HelloWorld { public void run() { System.out.println("Hello Java World!"); } public static void main (String [] args) { HelloWorld tpo = new HelloWorld(); tpo.run(); }

11 MIS215 Module 0 - Intro 11 Dissecting HelloWorld Every program in Java is (at least) one class Each class has one or more methods. The class that runs the program is the main class, and has a main(…) method Typically, you should create an instance of a class in your main method, and call methods of that instance That’s exactly what HelloWorld Does!

12 MIS215 Module 0 - Intro 12 Lets do a little more… public class GradeCalculator { private int score = 843; // Score of the student public void run() { char letgrade = ''; //single quotes for characters // Do what is needed here to find the letter grade System.out.println("The student's letter grade is" + letgrade); } public static void main (String [] args) { GradeCalculator gc = new GradeCalculator(); gc.run(); }

13 MIS215 Module 0 - Intro 13 Dissecting GradeCalculator First finish it.. What is the logic for finding the letter grade from the numeric score? What is that “private int score;” business? What are our alternatives?

14 MIS215 Module 0 - Intro 14 The Input Class A stable class for easily receiving input from the users Documentation of this class is available at http://www.wright.edu/~arijit.sengupta/mis215/sa mples/complexity/Input.html http://www.wright.edu/~arijit.sengupta/mis215/sa mples/complexity/Input.html How do you use it?  Create an instance of the Input class  Call the appropriate method (with or without an argument) Why should you use the Input class?  Stable – includes some built-in error checks!

15 MIS215 Module 0 - Intro 15 Lets try it! Change GradeCalculator to ask the user for the numeric score Where should you create the Input class? What happens if you call the run() method multiple times? What is a better way?

16 MIS215 Module 0 - Intro 16 Going ahead – practising loops Write a program that asks the user to guess a number between 1 and 100. In a loop, let the computer make a guess, and the user says G/L/M (greater/less/match) Continue until you get a match Report the number of tries

17 MIS215 Module 0 - Intro 17 CFC – Comment-First Coding What is it? Why comments?  Descriptive  Think in English instead of the cryptic code  Will always compile!!!  Self-documenting Why comment-first? How do you fill out the comments? Lets try it!

18 MIS215 Module 0 - Intro 18 Only the run() method now.. public void run() { // Step 1. Initialization // Step 2. // Step 3. // Step 4. // Step 5. }

19 MIS215 Module 0 - Intro 19 Lets describe the steps public void run() { // Step 1. Initialization // set up the needed variables // Step 2. // Step 3. // Step 4. // Step 5. }

20 MIS215 Module 0 - Intro 20 Finally, fill in the code public void run() { // Step 1. Initialization // set up the needed variables int steps = 0, guess = 0; // any other variables? // Step 2. // Step 3. // Step 4. // Step 5. }

21 MIS215 Module 0 - Intro 21 Now what? Practice CFC – we will try to use this diligently this quarter. Every assignment you submit must have your names as comments at the top of the file, and all code must be extensively commented, preferably CFC-ed Did I just make up a verb there?

22 MIS215 Module 0 - Intro 22 Finally… Lets try to have fun as you write code Remember, programs do what we tell them to do – so we are the boss! There is nothing like “IT is not working” – IT always works – just like you tell it to – maybe you didn’t tell it to do the right thing! Practice, practice, practice… makes it perfect

23 Part 2 – Analysis of Algorithms There are many different ways to solve the same problem How do you tell if one way would be better than another? Analysis of algorithms is a method for identifying the efficiency of an algorithm MIS215 Module 0 - Intro 23

24 Order Notation (big-Oh/little-oh) For this course, we are only going to use the big Oh notation An algorithm is described to have the complexity of O(some function over n) For example, Mergesort has the complexity O(n lg n) No – that wasn’t a typo – lg(n) is log 2 (n) MIS215 Module 0 - Intro 24

25 So what does it mean? Lets first see how these functions behave: MIS215 Module 0 - Intro 25 nn2n2 lg(n)n lg(n)2n2n n! 1010043410243628800 1001000076651.26765E+309.3326E+157 100010000001099661.0715E+301#NUM! 5000250000001361439#NUM! 1000010000000014132878#NUM! 50000250000000016780483#NUM! 10000010000000000171660965#NUM!

26 So.. Can you compare now? Complexity of Bubblesort is O(n 2 ), and complexity of Mergesort is O(n lg n). Which one is more efficient? A. Bubblesort B. Mergesort C. Both are the same MIS215 Module 0 - Intro 26

27 How do you determine complexity of an algorithm? Typically involves mathematical induction For the purpose of this class, try to find the main loop of the algorithm, and determine the number of comparisons (or whichever is the most important operation is) Try to find an association between the input and the number of operations MIS215 Module 0 - Intro 27

28 The ComplexityDemo.java program Compile and run it – don’t worry too much about the source code at the moment See how the time behaves as you run the different algorithms If you feel adventurous, change the code a bit and try different input numbers (careful – some will not run for large inputs) MIS215 Module 0 - Intro 28


Download ppt "MIS215 Module 0 - Intro 1 MIS 215 Module 0 Intro to Data Structures."

Similar presentations


Ads by Google