Unit 1: Preliminaries Part 1: Course Introduction, Abstraction, and ADT s

Similar documents
Unit 1: Preliminaries Part 4: Introduction to the Standard Template Library

About this exam review

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

Objects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3

CS24 Week 3 Lecture 1

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

Programming Abstractions

Standard. Number of Correlations

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

COEN244: Class & function templates

Data Structure. Recitation VII

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

Data Structures and Algorithms. Chapter 1

Types. C Types. Floating Point. Derived. fractional part. no fractional part. Boolean Character Integer Real Imaginary Complex

Introduction to Object-Oriented Programming

CSCI-1200 Data Structures Fall 2018 Lecture 22 Hash Tables, part 2 & Priority Queues, part 1

B16 Object Oriented Programming

ENGINEERING PROBLEM SOLVING WITH C++

Fibonacci in Lisp. Computer Programming: Skills & Concepts (CP1) Programming Languages. Varieties of Programing Language

Computer Science 9608 (Notes) Chapter: 4.1 Computational thinking and problem-solving

Programming II. Modularity 2017/18

Abstract Data Types (ADT) and C++ Classes

Do not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully.

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CS113: Lecture 4. Topics: Functions. Function Activation Records

An OBJECT contains VARIABLES = PROPERTIES and METHODS = BEHAVIORS. Outline the general nature of an object.

Time : 03 Hours Maximum Marks : 75

Introduction to Programming (Java) 4/12

Unit 4: Stacks and Queues

Data structures and libraries

What is an algorithm?

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

CS300 Final Review Questions 1

Computational thinking, problem-solving and programming:

Chapter 8 Algorithms 1

PROBLEM 1 : (And the winner is...(12 points)) Assume you are considering the implementation of a priority queue that will always give you the smallest

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Babaria Institute of Technology Computer Science and Engineering Department Practical List of Object Oriented Programming with C

END TERM EXAMINATION

Absolute C++ Walter Savitch

CPSC 2380 Data Structures and Algorithms

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types

Link-Based Implementations. Chapter 4

Lecture 2: Implementing ADTs

Fast Introduction to Object Oriented Programming and C++

Objectives. Order (sort) the elements of an array Search an array for a particular item Define, use multidimensional array

ADTs, Arrays, Linked Lists

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Assignment 5: Priority Queue

Data Structures and Algorithm Analysis in C++

Introduction to Data Structures & Algorithm

Programming and Data Structures Prof. N.S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology, Madras

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade

Web Development I PRECISION EXAMS DESCRIPTION. EXAM INFORMATION Items

CS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych

Programming Assignment #4 Binary Trees in C++

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

Lecture 8 Classes and Objects Part 2. MIT AITI June 15th, 2005

More loops Ch

CS 32. Lecture 2: objects good?

COLLEGE OF THE DESERT

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Modularity. Modular program development. Language support for modularity. Step-wise refinement Interface, specification, and implementation

Hash Open Indexing. Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Inheritance and Substitution (Budd chapter 8, 10)

Chapter 3: Modules. Starting Out with Programming Logic & Design. Second Edition. by Tony Gaddis

CS 223: Data Structures and Programming Techniques. Exam 2. April 19th, 2012

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Supplementary Material: The Rotation Matrix

CS24 Week 4 Lecture 2

OOP Design Conclusions and Variations

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Computer Science 210: Data Structures

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

Abstract Data Types. Functional Programming and Reasoning. Dr Hans Georg Schaathun. University of Surrey. Spring 2010 Week 4

Algorithms & Data Structures

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

ACCESSIBILITY TIPS. Adding alternative text to images and objects in PowerPoint or Word

CSE 100 Advanced Data Structures

CSCI 253. Outline. Background. George Blankenship 1

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

Lecture 2: Stacks and Queues

DATA ABSTRACTION AND PROBLEM SOLVING WITH JAVA

The Software Design Process. CSCE 315 Programming Studio, Fall 2017 Tanzir Ahmed

Data Structure (CS301)

Algorithms. Chapter 8. Objectives After studying this chapter, students should be able to:

CSCE 110 PROGRAMMING FUNDAMENTALS

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

Standard ADTs. Lecture 19 CS2110 Summer 2009

CS2102, B11 Exam 1. Name:

Transcription:

Unit 1: Preliminaries Part 1: Course Introduction, Abstraction, and ADT s Engineering 4892: Data Structures Faculty of Engineering & Applied Science Memorial University of Newfoundland April 23, 2010 ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 1 / 12

1 Introduction What is this course about? Course outline Course notes 2 Abstraction 2 Modularity 2 Abstract Data Types (ADTs) Choosing between ADTs ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 2 / 12

What is this course about? Data structures...but what s a data structure? A data structure is a particular way of organizing computer memory to record some data e.g. an array The way in which data is organized can have a big impact on the efficiency of any operations on that data e.g. searching for a card in a sorted vs. unsorted deck The analysis of algorithms We can analyze an algorithm to predict how fast it will run as compared to another algorithm Recursion A recursive function is one which calls itself Can be very useful for solving certain problems ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 3 / 12

Course outline Preliminaries Abstraction Specification Review of pointers in C++ The Standard Template Library Complexity analysis Linked lists Stacks and queues Recursion Sorting Trees Graphs Hash tables ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 4 / 12

Course notes These notes will be posted to the course website. Some material will be presented on the blackboard and not provided in electronic format. It is your responsibility to take these notes down. Usually this will be clearly indicated in the electronic notes as follows: COVERED ON THE BOARD Sometimes, however, there will be other material presented in class, but not on the blackboard. Again, it is your responsibility to record this material. ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 5 / 12

Abstraction When we think about a topic, we usually consider it at one particular level of abstraction, e.g. to cross the street we think about the velocities of the cars and how to time our movement We abstract away the details of how the cars internal combustion engines and braking systems lead to their current velocities This process, called abstraction, allows us to deal with complex situations by abstracting away the details until the situation appears simple. When developing software, abstraction usually implies a separation between how a piece of software is used, and how it is implemented. In other words, abstraction means that we separate the interface from the implementation.

Consider the following function definition: // Returns the c h a r a c t e r f o l l o w i n g i n w i t h i n the // f i r s t 128 ASCII c h a r a c t e r s ( with wrap around ). char rotate ( char in ) ; The interface of a function includes the name, return type, and arguments, plus the specification of what that function does (i.e. the comments). Here is the function s implementation: char rotate ( char in ) { char out = ( in + 1) % 1 28; return out ; } In C++ we usually separate interface from implementation by putting the interface in a header file (.h file) and the implementation in another file (.cpp file). ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 7 / 12

Modularity Abstraction ties in with with the concept of modularity. Modularity means that the solution is broken up into modules or components. Modularity is crucial in software development. Why? Division of labour: Designing, implementing, testing and maintaining of components can be assigned to various individuals or groups Reuse and sale: The same components can be reused in multiple software systems; Components can be sold to other software developers When we have abstraction and modularity together, we separate the role of modules (given by their interfaces), from the details of their implementation. ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 8 / 12

Abstract Data Types (ADTs) A data type is a software component that stores some data and provides operations on that data. C++ captures this idea in its built-in data types (e.g. int, char, float,...) and in its classes. When the implementation of a data type is hidden from its user, we have an abstract data type or ADT. An ADT provides data abstraction. The separation between the use of an ADT and its implementation can be pictured as a wall:

Ultimately, the ADT is implemented using some data structure (e.g. a sorted array). However, the particular data structure used is hidden from the program that uses the ADT (a.k.a. client or user). Thus, data structures and ADT s are not the same thing! The ADT is the combination of the interface to the data and the data structure itself. What is the main mechanism for hiding implementation in C++ classes? private The user of an ADT interacts with it only through its interface, which in C++ is composed of a class s public members, as well as the specification for what those members do. Note: We may not actually hide the implementation. However, it is good practise to at least inform the user about the division between the interface and the implementation. ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 10 / 12

Consider the following two classes: class Complex1 { private : double magnitude, theta ; // t h e t a i n r a d i a n s. public : Complex1 operator +(Complex1 ) ; //... And so on... // } ; class Complex2 { private : double real, imaginary ; public : Complex2 operator +(Complex2 ) ; //... And so on... // } ; The implementation of Complex1 uses a polar representation, while Complex2 uses a cartesian representation. These classes have the same interface the public methods are all the same but they differ in their implementation.

Choosing between ADTs If you have two ADTs that differ only in implementation, how do you choose between them? Efficiency (a.k.a complexity) Time: The speed of the operations Space: The amount of space required in memory Cost of design and implementation (one time) Cost of maintanence (ongoing) Accuracy and predictability of representation: e.g. With either representation of Complex, it is unlikely that the complex number 1/3 is perfectly representable. ENGI 4892 (MUN) Unit 1, Part 1 April 23, 2010 12 / 12