csci 1112 data structures algorithms i
play

CSCI 1112 Data Structures & Algorithms I Mona Diab Lecture 1 - PowerPoint PPT Presentation

CSCI 1112 Data Structures & Algorithms I Mona Diab Lecture 1 RoadMap Class Logistics Brief Introduction Survey Class Logistics Instructor: Mona Diab Lab TA: Tianyi Song Grading TA: Hanan AlDarmaki Class: TH


  1. CSCI 1112 Data Structures & Algorithms I Mona Diab Lecture 1

  2. RoadMap • Class Logistics • Brief Introduction • Survey

  3. Class Logistics • Instructor: Mona Diab • Lab TA: Tianyi Song • Grading TA: Hanan AlDarmaki • Class: TH 2:20-3:35pm • Lab: M 9:00-10:50am, W 11:10-1:00pm • URL for class • http://www.seas.gwu.edu/~mtdiab/Courses/ CS1112/index.htm • THIS IS YOUR KEY RESOURCE … it will be updated frequently, make sure to check it often

  4. Course Logistics • Textbook (not required but recommended) – Data Structures & Other Objects Using Java, 2012, 4 th Edition, Michael Main • All course material for reading and assignments is provided from the course website • Supplementary material for reading will be pointed out from both the course website and the book ahead of class • You MUST read the material before class

  5. Course Mechanics • Class and Lab attendance is mandatory • Occasionally, we will have in-class assignments that need to be worked on in class • Typically, I would be lecturing for half the class and then we do hands on application of the different concepts learned and possibly an in-class exercise • The in-class assignments are due right after class within 1 hr.

  6. Grading 30% in class assignments (15%), attendance (5%), participation (5%), lab attendance and participation (5%) 40% HW (25%) and Lab exercises (15%) 30% Midterm (15%), final (15%)

  7. Assignment Submission • Assignments will be submitted as tarred zipped encrypted files either via BB or on the unix SEAS “shell.seas.gwu.edu” server • In-class assignment submissions can’t be late • HW can be late but 20% of the grade will be shaved off for every 24hrs after due date (calendar days) • We determine submission by the file date on the crypt file.

  8. Important Assignment Considerations • Pseudocode for the algorithm • Proper indentation and coding style • Sufficient documentation with comments and readable/expressive variable names • Correctness • Robustness • Efficiency • Modularity

  9. Other important considerations • Email policy – Do not send debugging questions over email, always check with TAs first – I will be checking emails at a slower pace than the class – Questions about course material should happen in my office hours, labs, over email and on Piazza (be sure to log onto the class) • Academic integrity – I expect the work to be yours alone (in class assignments can be worked on in pairs)

  10. What is this course about • Data structures: arrays, lists, queues, stacks, trees. • Memory models of these data structures. • Problem-solving: recursion, using data structures. • Software skills: harder programs, trickier code, debugging. • Algorithm analysis: reasoning about program execution time.

  11. What will we learn • We will learn how fundamental data structures work, how they are used, and how to build them ourselves. • We will learn why they work, for example, why one is faster/better than another. • We will learn how data structures are represented in memory. • We will strengthen our programming skills and learn more about Java to be able to implement data structures. • Along the way, we will also learn about problem-solving and recursion.

  12. Course Outline • Introduction to basic overall concepts • Unidimensional & Multidimensional Arrays • Sorting, Recursion, Objects, Sets, Lists • Analysis of Algorithms Performance • Stacks, Queues, Abstract Data Types (ADT) • Recursion (again) • Trees & Hashtables

  13. Objectives • Organizing the data for processing is a computer program is a critical step in the solution of a problem. • Selecting the data organization strongly affect the performance of the computer program solution • Most programming languages offer a set of primitive (basic) data types and ways to build complex data types.

  14. Computer Programs in CS • Use a computer to efficiently solve a problem: – Understand the requirements of the problem – Implementing these requirements with a computer program – Computer programs consist of the following: • Algorithm + Data Structure(s)

  15. Data Structure • A means of storing a collection of data • It is the requirement of the elements of the structure, the relationships between them, and the operations that may be performed on them • The choice of a data structure can affect the performance of a solution: slow vs. fast

  16. Data Structure Taxonomy • Linear and non-linear data structures • Homogenous and non-homogenous data structures • Primitive and non-primitive data structures

  17. Linear and Non-linear Data Structures • Linear Data Structures – Data elements are arranged in a linear sequence • Examples: Array, Linked List, Queue, Stack • Non-linear Data Structures: – Data elements are not stored in a sequence – Examples: Tree, Graph, Forest

  18. Primitive and Non-primitive Data Structures • Primitive Data Structures primitive (basic) types: Integer, float • Non-primitive Data Structures – Composite data structures: Array, records

  19. Homogeneous and Non- homogeneous Data Structures • Homogenous Data Structures: – Data elements are of the same type • Example: Array • Non-homogenous Data Structures: – Data elements are of different types • Examples: Records or Structure

  20. Basic Definitions A data type is a set of values and a set of operations defined on those values – Values • For example, the values of the primitive data type int are integers between -2 31 and 2 31 – Operations • The operations of int are the basic arithmetic and logical operations.

  21. Basic Data Types • Byte: an 8-bit signed twos complement integer • Boolean: True or False • Short: a 16-bit signed twos complement • Int: a 32-bit signed twos complement • Long: a 64-bit signed twos complement • Float: a single-precision 32-bit IEEE 754 floating point • Double: a double-precision 64-bit IEEE 754 floating point • Char: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive)

  22. Algorithm • To implement the business logic of the problem • It is a concise list of steps to solve a problem • There are more than one algorithm for a problem • How to choose an efficient algorithm • How to choose the best algorithm • What are criteria for performance analysis

  23. How to develop applications? • Preconditions and Postconditions – Increase the reliability of your application. – They are a method of specifying what a function accomplishes. – Frequently a programmer must communicate precisely what a function accomplishes, without any indication of how the function does its work.

  24. Precondition Statement • Indicates what must be true before the function is called. • The programmer who calls the function is responsible for ensuring that the precondition is valid when the function is called.

  25. Postcondition Statement • Indicates what will be true when the function finishes its work. • The programmer who writes the function counts on the precondition being valid, and ensures that the postcondition becomes true at the function’s end.

  26. Example • bool is_vowel( char letter ) //Precondition: letter is an uppercase or lowercase letter (in the range 'A' ... 'Z' or 'a' ... 'z') . //Postcondition: The value returned by the function is true if Letter is a vowel; otherwise the value returned by the function is false. What values will be returned by these function calls? is_vowel( 'A' ); is_vowel(' Z' ); is_vowel( '?' );

  27. Testing & Debugging • Is Compile-Run-Generate-Outputs enough? – Required Testing!!! – Which test data? • You must know which output a correct program should produce for each test data. • The test inputs should include those inputs that are most likely to cause errors. • Tips for Test data: – Boundary values – Fully Exercising Code: make sure each line of your code is executed. – Values of variables: negative, zero, positive – Expecting numbers or strings, etc.

  28. Java • Programming in Java is largely based on doing so with data types known as reference types. • Java has eight primitive data types: boolean, byte, char, double, float, int, long, and short.

  29. Basic Concepts in Java //Comment1 public class SyntaxExample1 { //Comment2 public static void main (String[] argv) { //Comment 3 } }

  30. Basic concepts in Java public class HelloWorld { public static void main (String[] argv) { System.out.println ("Hello World!"); }} • The main syntactic elements are: – Java reserved words such as: public, class, static, void. – Method (procedure or function) names: main, println. – Names of variables and objects, such as System, String, HelloWorld, argv and out. – Delimiters for the class, and the method main. – An end-of-statement symbol, the semicolon. – Parentheses for enclosing method parameters (arguments). – A string literal, Hello World!. – Array brackets []

  31. Survey • Name • Level • Major • Have you taken CSCI 1111? • Have you coded in Java before? (Yes/No) • What other CS languages are you familiar with? • Are you familiar with unix? • Are you familiar with Eclipse?

Recommend


More recommend