Introduction to Data Structure

Slides:



Advertisements
Similar presentations
Chapter 1: INTRODUCTION TO DATA STRUCTURE
Advertisements

Chapter 24 Lists, Stacks, and Queues
Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
Data Structures.
Overview of Data Structures and Algorithms
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L11 (Chapter 20) Lists, Stacks,
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Data Structures Introduction. What is data? (Latin) Plural of datum = something given.
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Odds and Ends Strings (from Chapter 9) StringTokenizer.
C++ fundamentals.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Object Oriented Data Structures
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Grade 12 Computer Studies HG
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Computer Science Department Data Structures and Algorithms Lecture 1.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Data Design and Implementation. Definitions of Java TYPES Atomic or primitive type A data type whose elements are single, non-decomposable data items.
Pointers OVERVIEW.
Data structures Abstract data types Java classes for Data structures and ADTs.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
REEM ALMOTIRI Information Technology Department Majmaah University.
ISBN Chapter 12 Support for Object-Oriented Programming.
CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
9/27/2016IT 1791 Abstraction A tool (concept) to manage complexity Hide irrelevant details; focus on the features needed Primitive date types are already.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Advanced Data Structures Lecture 1
Introduction toData structures and Algorithms
Course Developer/Writer: A. J. Ikuomola
September 29 – Stacks and queues
Data Structure Interview Question and Answers
Chapter 6: Data Types Lectures # 10.
GC211Data Structure Lecture2 Sara Alhajjam.
Abstraction A tool (concept) to manage complexity
Data Structures Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective.
Data Structures Interview / VIVA Questions and Answers
11.1 The Concept of Abstraction
Cinda Heeren / Geoffrey Tien
Lecture 2 of Computer Science II
Queues Chapter 8 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved
Introduction to Data Structure
Chapter 17 Object-Oriented Data Structures
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
Abstract Data Types and Encapsulation Concepts
structures and their relationships." - Linus Torvalds
Chapter 3 Introduction to Classes, Objects Methods and Strings
Further Data Structures
Introduction to Data Structures
Object-Oriented Programming
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Introduction to Data Structures
Focus of the Course Object-Oriented Software Development
By Yogesh Neopaney Assistant Professor Department of Computer Science
CS2013 Lecture 7 John Hurley Cal State LA.
(1 - 2) Introduction to C Data Structures & Abstract Data Types
structures and their relationships." - Linus Torvalds
A type is a collection of values
Presentation transcript:

Introduction to Data Structure Chapter 1 Introduction to Data Structure

What is Data  computers run programs  data is the ‘raw material’ that computer programs process  there must be some way to store the data so that they could be processed

How to store /organize data in a program? Single Variables Data Structure

Understand program execution & data INPUT OUTPUT PROCESS var 1 data 1 data2 data3 data4 (from keyboard / files / other input devices) (to screen / files / other output devices) var 2 PROGRAM var 3 var 4 In a simple program - Data is stored in simple variables

Types of data  Most programming language requires variables to be declared by relating them with the type of data that it contains  eg. float number;  There are many primitive data types (lowest data representation) in a language: int, float, char, double etc  Depending on the type:  different operations allowed on the data  different internal representation

Introduction to Data Type In Java programming, all variables are required to have a data type. Java Data Types can be divided into: Fundamental /Primitive /Base Type Abstract Data Type

Fundamental /Primitive /Base Type A variable of the fundamental type simply store a value of that type (one value at a time). 8 fundamental types int : 32-bit signed two’s complement integer float :32-bit floating-point number double : 64-bit floating-point number long :64-bit signed two’s complement integer short :16-bit signed two’s complement integer char :16-bit unicode character boolean:boolean value – true or false byte :8-bit signed two’s complement integer

Abstract Data Type (ADT) Definition: A set of data values and associated operations that are precisely specified independent of any particular implementation. Paul E. Black (2004)

Abstract Data Type (ADT) A data type that specifies the logical properties without the implementation details An ADT is presented as a class type and treated as a single entity that encapsulates its data together with its method An ADT provide information hiding ADT kept the implementation details of the operations and the data from the users of ADT The user of ADT can use the operations on an ADT without knowing how the operation is implemented

Abstract Data Type (ADT) ADT is used to describe the characteristics of a data structure An ADT has A set of values (data) A set of operations (methods) The data representation and actual algorithms for the operations are unspecified Classes are used to represent objects in Object Oriented Programming (OOP) approach. OOP uses classes to encapsulate data (attributes) and methods (behaviors). Encapsulate enables objects to hide their implementation from other objects.

Abstract Data Type (ADT) User is interested in ADT, given as interfaces, while developer focuses on data structures, namely classes. We have Java collections framework’s interfaces E.g: List interface – one of the classes that implement that interface is LinkedList (user’s view of List as an ADT)

Abstract Data Type (ADT) ADT is also referred to as an object. ADT contains more than one fundamental data types. ADT also contains the methods as an interface to manipulate the data. Each ADT is an encapsulation of data and methods. In Java, ADT or object is defined using Class. Eg: class Computer { private int code; private String brand; private double price; public Computer () { } public Computer (int c, String b, double p) {…} public int getCode () { return code; } public String getBr () { return brand; } public double getPr() { return price; }; }

Data Structure is a particular way of storing and organizing data in a computer so it can be used efficiently. is a systematic way of organizing a collection of data. is a representation of data and the operations allowed on the data. is known as a collection of related data items. Every data structure needs a variety of algorithms for processing the data in it (insertion, deletion, retrieval, etc) Algorithms are used to manipulate the data contained in these data structures as in searching and sorting. Different kinds of data structures are suited to different kinds of applications.

Data Structure Example of Data Structure Arrays Lists Queues Stacks Trees Indexes The choice on which data structure to be used for a system will affect the system design and contribute to the effectiveness of that system. The correct choice of data structure allows major improvement in program efficiency 2 types: Static – fix size (array, record) Dynamic – grow and shrink at runtime (list, queue, stack, binary tree)

Data Structure Static VS Dynamic Data Structure Besides time and space efficiency another important criterion for choosing a data structure is whether the number of data items it is able to store can adjust to our needs or is bounded. This distinction leads to the notions of dynamic data structures vs. static data structures. Dynamic data structures grow or shrink during run-time to fit current requirements e.g., a structure used in modeling traffic flow. Static data structures are fixed at the time of creation. e.g., a structure used to store a postcode or credit card number (which have a fixed format).

Data Structure Advantages of Static Data Structure ease of specification Programming languages usually provide an easy way to create static data structures of almost arbitrary size no memory allocation overhead Since static data structures are fixed in size, there are no operations that can be used to extend static structures; such operations would need to allocate additional memory for the structure (which takes time)

Data Structure Disadvantages of Static Data Structure must make sure there is enough capacity the number of data items we can store in a static data structure is fixed, once it is created, we have to make sure that this number is large enough for all our needs more elements? (errors), fewer elements? (waste) However, when our program tries to store more data items in a static data structure than it allows, this will result in an error (e.g. ArrayIndexOutOfBoundsException) On the other hand, if fewer data items are stored, then parts of the static data structure remain empty, but the memory has been allocated and cannot be used to store other data.

Data Structure Advantages of Dynamic Data Structure There is no requirement to know the exact number of data items Since dynamic data structures can shrink and grow to fit exactly the right number of data items, there is no need to know how many data items we will need to store Efficient use of memory space if we only extend a dynamic data structure in size whenever we need to add data items have exactly the right size and no memory space is wasted

Data Structure Disadvantages of Dynamic Data Structure Memory allocation/de-allocation overhead Whenever a dynamic data structure grows or shrinks, then memory space allocated to the data structure has to be added or removed (which requires time)

Data Structure A good approach to determine which data structure that best suit your application is to study the strengths and weaknesses of each of the data structure available.

Data Structure Application Array A data structure that holds a collection of data in sequential order Is the simplest data structure and easy to use Can be 1 dimensional and multi-dimensional 2 limitations: Once an array is created its size cannot be altered An array does not provide adequate support for insertion and deletion operation

Data Structure Application List A dynamic data structure where size can be changed A list is a collection of data stored sequentially It supports insertion and deletion anywhere in the list Two types of list : Sequential list (array list) – arrays that store data in a contiguous memory (elements next to each other) Linked list – a linked structure that store data where one element refers to another, anywhere in memory

Data Structure Application Stack A stack can be perceived as a special type of list where insertions and deletions take place only one end, refererred to as top of the stack Known as LIFO (Last in First Out) Example: Stack of plates

Data Structure Application Queue A queue represent a waiting list, where insertions take place at the back of the queue Adding at the back and deleting in front Known as FIFO (First In First Out) Example: queuing for the bus, taxi, etc

Data Structure Application Binary tree A binary tree is a data structure that supports searching, sorting, inserting and deleting data efficiently Data in a hierarchical relationship

ADT & Data Structure ADT consist of a collection of values, together with collection of operations on those values. Using Java, a user of a class can: Create an instance of that class (value) Invoke the public methods of the class However, classes have additional properties (inheritance and polymorphism) not normally associated with ADTs

ADT & Data Structure A Data Structure is the implementation of an abstract data type. In OO languages, a developer implements an interface with class. In another word is as following association : General term Object Oriented Term Abstract Data Type interface Data Structure class

ADT & Data Structure ADT is the logical picture of the data and the operations to manipulate the component elements of the data Data structure is the actual representation of the data during the implementation and the algorithms to manipulate the data elements ADT is the logical level and data structure is in the implementation level Conclusion: Data structure is how we implement the data in an abstract data type.