SlideShare a Scribd company logo
1 of 20
Download to read offline
Lecture 1




                            Introduction to Data
                                 Structures


                              Abdisalam Issa-Salwe

                               Taibah University
                  College of Computer Science & Engineering
                        Computer Science Department




Outline
1.   Choosing Data Structures
2.   Selecting Data Structure
3.   Data Structure Philosophy
4.   Abstract Data Types
5.   Logical vs. Physical Form
6.   Programs
7.   Algorithm Properties
8.   References




                                                              2




                                                                  1
Data Structures

A data structure is a scheme
for organizing data in the
memory of a computer.

Some of the more commonly
used data structures include
lists, arrays, stacks, queues,
heaps, trees, and graphs.
                                 Binary Tree




                                               3




 Data Structures

The way in which the data is
organized affects the
performance of a program
for different tasks.

Computer programmers
decide which data structures
to use based on the nature
of the data and the              Binary Tree
processes that need to be
performed on that data.
                                               4




                                                   2
The Need for Data Structures


Data structures organize data
     ⇒ more efficient programs.
More powerful computers ⇒ more complex
 applications.
More complex applications demand more
 calculations.
Complex computing tasks are unlike our
 everyday experience.
                                     5




 The Need for Data Structures


Data structures organize data
     ⇒ more efficient programs.
More powerful computers ⇒ more complex
 applications.
More complex applications demand more
 calculations.
Complex computing tasks are unlike our
 everyday experience.
                                     6




                                         3
Example: A Queue
  A queue is an example of commonly used simple data
  structure. A queue has beginning and end, called the
  front and back of the queue.




  Data enters the queue at one end and leaves at the other.
  Because of this, data exits the queue in the same order in
  which it enters the queue, like people in a checkout line at
  a supermarket.
                                                                 7




 Example: A Binary Tree

A binary tree is another
commonly used data
structure. It is organized like
an upside down tree.

Each spot on the tree, called
a node, holds an item of data
along with a left pointer and
a right pointer.                             Binary Tree




                                                                 8




                                                                     4
Example: A Binary Tree

The pointers are lined up
so that the structure forms
the upside down tree, with
a single node at the top,
called the root node, and
branches increasing on the
left and right as you go
down the tree.
                                Binary Tree




                                              9




 Choosing Data Structures

By comparing the queue with
the binary tree, you can see
how the structure of the data
affects what can be done
efficiently with the data.




                                              10




                                                   5
Choosing Data Structures

A queue is a good data structure
to use for storing things that need
to be kept in order, such as a set
of documents waiting to be
printed on a network printer.

.




                                      11




    Choosing Data Structures

The jobs will be printed in the
order in which they are received.

Most network print servers
maintain such a print queue.

.




                                      12




                                           6
Choosing Data Structures

A binary tree is a good data
structure to use for searching
sorted data.

The middle item from the list is
stored in the root node, with
lesser items to the left and greater
items to the right.




                                       13




 Choosing Data Structures

A search begins at the root. The
computer either find the data, or
moves left or right, depending on
the value for which you are
searching.

Each move down the tree cuts the
remaining data in half.




                                       14




                                            7
Choosing Data Structures

Items can be located very quickly
in a tree.
Telephone directory assistance
information is stored in a tree, so
that a name and phone number
can be found quickly.




                                       15




 Choosing Data Structures

For some applications, a queue is
the best data structure to use.
For others, a binary tree is better.
Programmers choose from
among many data structures
based on how the data will be
used by the program.




                                       16




                                            8
The Need for Data Structures

 Data structures organize data
      ⇒ more efficient programs.
 More powerful computers ⇒ more complex
  applications.
 More complex applications demand more
  calculations.
 Complex computing tasks are unlike our
  everyday experience.
                                                 17




      Selecting a Data Structure

Select a data structure as follows:
1. Analyze the problem to determine the resource
   constraints a solution must meet.
2. Determine the basic operations that must be
   supported. Quantify the resource constraints
   for each operation.
3. Select the data structure that best meets these
   requirements.

                                                 18




                                                      9
Data Structure Philosophy

Each data structure has costs and benefits.
Rarely is one data structure better than
  another in all situations.
A data structure requires:
    space for each data item it stores,
    time to perform each basic operation,
    programming effort.



                                              19




    Data Structure Philosophy
Each data structure has costs and benefits.
Rarely is one data structure better than
  another in all situations.
A data structure requires:
    space for each data item it stores,
    time to perform each basic operation,
    programming effort.



                                              20




                                                   10
Abstract Data Types

Abstract Data Type (ADT): a definition for a
 data type solely in terms of a set of values
 and a set of operations on that data type.
Each ADT operation is defined by its inputs
 and outputs.
Encapsulation: Hide implementation details.



                                                    21




    Data Structure
 A data structure is the physical implementation
 of an ADT.
    Each operation associated with the ADT is
    implemented by one or more subroutines in the
    implementation.
 In a OO language such as C++, an ADT and its
 implementation together make up a class.
 Data structure usually refers to an organization
 for data in main memory.
 File structure: an organization for data on
 peripheral storage, such as a disk drive.

                                                    22




                                                         11
Abstract data types
  we also looked at how to use an array to
  model a list
  we call a list an abstract data type
    it has defined operations
       add to the end of the list
       find an item in the list
       delete an item from the list     etc.
    it can be implemented in different ways
       array, piece of paper, tree, linked list
    the operations have the same effect no matter how
    the list is implemented
  other examples of abstract data types
    set, queue, stack, map

                                                                     23




Sets
 a set is an unordered
 group of elements
    duplicates are not
    allowed
                                               set of foods I like
    otherwise how would
    you tell them apart?                             Chips
                                              Cereal
 the set of "foods I                              Chicken
 like" contains the                        Orange Tomato
 elements                                  juice      soup
    cereal, chicken, chips,
    tomato soup, orange                        Chocolate
    juice and chocolate
                                                                     24




                                                                          12
Lists
a list is a group of elements
arranged in some order                         Things I ate today
  so we can talk about                       (in chronological order)
     the first element in the list
     the last element in the list            1. cereal
     element 3                               2. orange juice
the order could be meaningful                3. chocolate
  alphabetical
  by size                                    4. tomato soup
  by time                                    5. chocolate
or it could simply be the order the 6. chicken
elements were added                 7. chips
duplicates are allowed              8. chocolate
  they are distinguished by their position                       25




Queue




 a queue is a a group of items arranged in order of arrival
 new items can only be added to the back of the queue
 items can only be removed from the front of the queue
    shoppers at supermarket check-out
    taxis in rank
    computer processes awaiting execution
 first-in, first-out (FIFO)

                                                                 26




                                                                        13
Stacks

   a stack is a group of items
   arranged in order
   new items can only be
   added to the top of the stack
   items can only be removed
   from the top of the stack
      stack of chairs or books
      plates in cafeteria
      temporary data storage in
      CPU
   last in, first out (LIFO)

                                                              27




Maps

 A map is a collection of                     confusion
 key/element pairs                algorithm
   each element is stored in
   a position determined by
   its key
   can look up an element
   using its key
 also known as a
 dictionary                                               university

   key is the word
   element is the definition
                                                              28




                                                                       14
Data Structure


  A data structure is the physical implementation of an
  ADT.
     Each operation associated with the ADT is implemented by one
     or more subroutines in the implementation.
  In a OO language such as C++, an ADT and its
  implementation together make up a class.
  Data structure usually refers to an organization for data
  in main memory.
  File structure: an organization for data on peripheral
  storage, such as a disk drive.

                                                                29




     Labeling collections of objects


 Humans deal with complexity by assigning a
 label to an assembly of objects. An ADT
 manages complexity through abstraction.
     Hierarchies of labels

Ex1: transistors ⇒ gates ⇒ CPU.

In a program, implement an ADT, then think only
  about the ADT, not its implementation.
                                                                30




                                                                     15
Logical vs. Physical Form


Data items have both a logical and a physical
 form.
Logical form: definition of the data item within an
  ADT.
    Ex: Integers in mathematical sense: +, -

Physical form: implementation of the data item
  within a data structure.
    Ex: 16/32 bit integers, overflow.

                                                      31




                         Data Type

         ADT:
                                  Data Items:
           Type
                                   Logical Form
           Operations



         Data Structure:          Data Items:
            Storage Space          Physical Form
            Subroutines


                                                      32




                                                           16
Problems, Algorithms and Programs

 Programmers deal with:
    problems,
    algorithms and
    computer programs.




                                                    33




Problems

 Problem: a task to be performed.
    Best thought of as inputs and matching
    outputs.
    Problem definition should include constraints
    on the resources that may be consumed by
    any acceptable solution.




                                                    34




                                                         17
Problems (cont)

  Problems ⇔ mathematical functions
    A function is a matching between inputs (the
    domain) and outputs (the range).
    An input to a function may be single number,
    or a collection of information.
    The values making up an input are called the
    parameters of the function.
    A particular input must always result in the
    same output every time the function is
    computed.

                                                          35




    Algorithms and Programs

Algorithm: a method or a process followed to solve
  a problem.
    A recipe: The algorithm gives us a “recipe” for solving
    the problem by performing a series of steps, where
    each step is completely understood and doable.

An algorithm takes the input to a problem
  (function) and transforms it to the output.
    A mapping of input to output.

A problem can be solved by many algorithms.

                                                          36




                                                               18
A problem can have many algorithms

For example, the problem of sorting can be solved
  by the following algorithms:
  Insertion sort
  Bubble sort
  Selection sort
  Shell sort
  Merge sort
  Others


                                                                   37




     Algorithm Properties

An algorithm possesses the following properties:
    It must be correct.
    It must be composed of a series of concrete steps.
    There can be no ambiguity as to which step will be performed
    next.
    It must be composed of a finite number of steps.
    It must terminate.

A computer program is an instance, or concrete
  representation, for an algorithm in some
  programming language.

                                                                   38




                                                                        19
Programs

 A computer program is a concrete
 representation of an algorithm in some
 programming language.
 Naturally, there are many programs that
 are instances of the same algorithms,
 since any modern programming language
 can be used to implement any algorithm.



                                            39




References
 Michael Main, Data Structures and Other
 Objects Using Java (Third Edition)
 Abdisalam Issa-Salwe, Taibah University,
 Madinah, Saudi Arabia.




                                            40




                                                 20

More Related Content

What's hot

DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURERohit Rai
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureVivek Kumar Sinha
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureRai University
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data StructureMandavi Classes
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechniclavparmar007
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure NUPOORAWSARMOL
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
Data structure
Data structureData structure
Data structureMohd Arif
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.Education Front
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueGhaffar Khan
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithmsVinayKumarV16
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)MUHAMMAD AAMIR
 

What's hot (20)

DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data Structure
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Data structure
Data structureData structure
Data structure
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
Data struters
Data strutersData struters
Data struters
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Data structure and its types.
Data structure and its types.Data structure and its types.
Data structure and its types.
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
 
Data structures
Data structuresData structures
Data structures
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
 

Viewers also liked

Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)Arvind Devaraj
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)swajahatr
 
Data structures / C++ Program examples
Data structures / C++ Program examplesData structures / C++ Program examples
Data structures / C++ Program examplesKevin III
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...widespreadpromotion
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structureeShikshak
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 

Viewers also liked (20)

Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Linked lists
Linked listsLinked lists
Linked lists
 
Computer memory
Computer memoryComputer memory
Computer memory
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Linked List
Linked ListLinked List
Linked List
 
Data structures / C++ Program examples
Data structures / C++ Program examplesData structures / C++ Program examples
Data structures / C++ Program examples
 
Data structures
Data structuresData structures
Data structures
 
linked list
linked list linked list
linked list
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
Linked lists
Linked listsLinked lists
Linked lists
 
Computer Memory
Computer MemoryComputer Memory
Computer Memory
 
Linked list
Linked listLinked list
Linked list
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 

Similar to Lecture1 data structure(introduction)

Unit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdfUnit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdfMaryJacob24
 
Data Structures & Recursion-Introduction.pdf
Data Structures & Recursion-Introduction.pdfData Structures & Recursion-Introduction.pdf
Data Structures & Recursion-Introduction.pdfMaryJacob24
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Conceptsoudesign
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdfBahria University Islamabad, Pakistan
 
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...Bahria University Islamabad, Pakistan
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdfBahria University Islamabad, Pakistan
 

Similar to Lecture1 data structure(introduction) (20)

Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Ch1
Ch1Ch1
Ch1
 
Unit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdfUnit 1-Introduction to Data Structures-BCA.pdf
Unit 1-Introduction to Data Structures-BCA.pdf
 
Database system Handbook 4th muhammad sharif.pdf
Database system Handbook 4th muhammad sharif.pdfDatabase system Handbook 4th muhammad sharif.pdf
Database system Handbook 4th muhammad sharif.pdf
 
Database system Handbook 4th muhammad sharif.pdf
Database system Handbook 4th muhammad sharif.pdfDatabase system Handbook 4th muhammad sharif.pdf
Database system Handbook 4th muhammad sharif.pdf
 
Data Structures & Recursion-Introduction.pdf
Data Structures & Recursion-Introduction.pdfData Structures & Recursion-Introduction.pdf
Data Structures & Recursion-Introduction.pdf
 
Database systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdfDatabase systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdf
 
Database systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdfDatabase systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdf
 
Database systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdfDatabase systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdf
 
Database systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdfDatabase systems handbook dbms rdbms.pdf
Database systems handbook dbms rdbms.pdf
 
Database systems handbook.pdf
Database systems handbook.pdfDatabase systems handbook.pdf
Database systems handbook.pdf
 
Database system Handbook.docx
Database system Handbook.docxDatabase system Handbook.docx
Database system Handbook.docx
 
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
Database systems Handbook 4th  dbms by Muhammad Sharif.pdfDatabase systems Handbook 4th  dbms by Muhammad Sharif.pdf
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
 
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
Database systems Handbook 4th  dbms by Muhammad Sharif.pdfDatabase systems Handbook 4th  dbms by Muhammad Sharif.pdf
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
 
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
Database systems Handbook 4th  dbms by Muhammad Sharif.pdfDatabase systems Handbook 4th  dbms by Muhammad Sharif.pdf
Database systems Handbook 4th dbms by Muhammad Sharif.pdf
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Concepts
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
 
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
 
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdfDatabase system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
 

More from Taibah University, College of Computer Science & Engineering

More from Taibah University, College of Computer Science & Engineering (20)

Lecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdfLecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdf
 
The paper the welfare state of the somali nation - a possible solution to t...
The paper   the welfare state of the somali nation - a possible solution to t...The paper   the welfare state of the somali nation - a possible solution to t...
The paper the welfare state of the somali nation - a possible solution to t...
 
Colonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistanceColonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistance
 
Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)
 
Lecture 7 (business-level strategy and the value chain model)
Lecture 7  (business-level strategy and the value chain model)Lecture 7  (business-level strategy and the value chain model)
Lecture 7 (business-level strategy and the value chain model)
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
 
Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)
 
Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)
 
Chapter 2 modeling the process and life-cycle
Chapter 2  modeling the process and life-cycleChapter 2  modeling the process and life-cycle
Chapter 2 modeling the process and life-cycle
 
Historical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral UnityHistorical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral Unity
 
Colonial intrusion and the Somali Resistance
Colonial intrusion and the Somali ResistanceColonial intrusion and the Somali Resistance
Colonial intrusion and the Somali Resistance
 
Lecture 8 (information systems and strategy planning)
Lecture 8  (information systems and strategy planning)Lecture 8  (information systems and strategy planning)
Lecture 8 (information systems and strategy planning)
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
 
Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)
 
Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)
 
Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )
 
Lecture4 is353-ea(fea)
Lecture4 is353-ea(fea)Lecture4 is353-ea(fea)
Lecture4 is353-ea(fea)
 
Lecture3 is353-ea(togaf)
Lecture3 is353-ea(togaf)Lecture3 is353-ea(togaf)
Lecture3 is353-ea(togaf)
 
Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)
 
Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)
 

Lecture1 data structure(introduction)

  • 1. Lecture 1 Introduction to Data Structures Abdisalam Issa-Salwe Taibah University College of Computer Science & Engineering Computer Science Department Outline 1. Choosing Data Structures 2. Selecting Data Structure 3. Data Structure Philosophy 4. Abstract Data Types 5. Logical vs. Physical Form 6. Programs 7. Algorithm Properties 8. References 2 1
  • 2. Data Structures A data structure is a scheme for organizing data in the memory of a computer. Some of the more commonly used data structures include lists, arrays, stacks, queues, heaps, trees, and graphs. Binary Tree 3 Data Structures The way in which the data is organized affects the performance of a program for different tasks. Computer programmers decide which data structures to use based on the nature of the data and the Binary Tree processes that need to be performed on that data. 4 2
  • 3. The Need for Data Structures Data structures organize data ⇒ more efficient programs. More powerful computers ⇒ more complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience. 5 The Need for Data Structures Data structures organize data ⇒ more efficient programs. More powerful computers ⇒ more complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience. 6 3
  • 4. Example: A Queue A queue is an example of commonly used simple data structure. A queue has beginning and end, called the front and back of the queue. Data enters the queue at one end and leaves at the other. Because of this, data exits the queue in the same order in which it enters the queue, like people in a checkout line at a supermarket. 7 Example: A Binary Tree A binary tree is another commonly used data structure. It is organized like an upside down tree. Each spot on the tree, called a node, holds an item of data along with a left pointer and a right pointer. Binary Tree 8 4
  • 5. Example: A Binary Tree The pointers are lined up so that the structure forms the upside down tree, with a single node at the top, called the root node, and branches increasing on the left and right as you go down the tree. Binary Tree 9 Choosing Data Structures By comparing the queue with the binary tree, you can see how the structure of the data affects what can be done efficiently with the data. 10 5
  • 6. Choosing Data Structures A queue is a good data structure to use for storing things that need to be kept in order, such as a set of documents waiting to be printed on a network printer. . 11 Choosing Data Structures The jobs will be printed in the order in which they are received. Most network print servers maintain such a print queue. . 12 6
  • 7. Choosing Data Structures A binary tree is a good data structure to use for searching sorted data. The middle item from the list is stored in the root node, with lesser items to the left and greater items to the right. 13 Choosing Data Structures A search begins at the root. The computer either find the data, or moves left or right, depending on the value for which you are searching. Each move down the tree cuts the remaining data in half. 14 7
  • 8. Choosing Data Structures Items can be located very quickly in a tree. Telephone directory assistance information is stored in a tree, so that a name and phone number can be found quickly. 15 Choosing Data Structures For some applications, a queue is the best data structure to use. For others, a binary tree is better. Programmers choose from among many data structures based on how the data will be used by the program. 16 8
  • 9. The Need for Data Structures Data structures organize data ⇒ more efficient programs. More powerful computers ⇒ more complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience. 17 Selecting a Data Structure Select a data structure as follows: 1. Analyze the problem to determine the resource constraints a solution must meet. 2. Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3. Select the data structure that best meets these requirements. 18 9
  • 10. Data Structure Philosophy Each data structure has costs and benefits. Rarely is one data structure better than another in all situations. A data structure requires: space for each data item it stores, time to perform each basic operation, programming effort. 19 Data Structure Philosophy Each data structure has costs and benefits. Rarely is one data structure better than another in all situations. A data structure requires: space for each data item it stores, time to perform each basic operation, programming effort. 20 10
  • 11. Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely in terms of a set of values and a set of operations on that data type. Each ADT operation is defined by its inputs and outputs. Encapsulation: Hide implementation details. 21 Data Structure A data structure is the physical implementation of an ADT. Each operation associated with the ADT is implemented by one or more subroutines in the implementation. In a OO language such as C++, an ADT and its implementation together make up a class. Data structure usually refers to an organization for data in main memory. File structure: an organization for data on peripheral storage, such as a disk drive. 22 11
  • 12. Abstract data types we also looked at how to use an array to model a list we call a list an abstract data type it has defined operations add to the end of the list find an item in the list delete an item from the list etc. it can be implemented in different ways array, piece of paper, tree, linked list the operations have the same effect no matter how the list is implemented other examples of abstract data types set, queue, stack, map 23 Sets a set is an unordered group of elements duplicates are not allowed set of foods I like otherwise how would you tell them apart? Chips Cereal the set of "foods I Chicken like" contains the Orange Tomato elements juice soup cereal, chicken, chips, tomato soup, orange Chocolate juice and chocolate 24 12
  • 13. Lists a list is a group of elements arranged in some order Things I ate today so we can talk about (in chronological order) the first element in the list the last element in the list 1. cereal element 3 2. orange juice the order could be meaningful 3. chocolate alphabetical by size 4. tomato soup by time 5. chocolate or it could simply be the order the 6. chicken elements were added 7. chips duplicates are allowed 8. chocolate they are distinguished by their position 25 Queue a queue is a a group of items arranged in order of arrival new items can only be added to the back of the queue items can only be removed from the front of the queue shoppers at supermarket check-out taxis in rank computer processes awaiting execution first-in, first-out (FIFO) 26 13
  • 14. Stacks a stack is a group of items arranged in order new items can only be added to the top of the stack items can only be removed from the top of the stack stack of chairs or books plates in cafeteria temporary data storage in CPU last in, first out (LIFO) 27 Maps A map is a collection of confusion key/element pairs algorithm each element is stored in a position determined by its key can look up an element using its key also known as a dictionary university key is the word element is the definition 28 14
  • 15. Data Structure A data structure is the physical implementation of an ADT. Each operation associated with the ADT is implemented by one or more subroutines in the implementation. In a OO language such as C++, an ADT and its implementation together make up a class. Data structure usually refers to an organization for data in main memory. File structure: an organization for data on peripheral storage, such as a disk drive. 29 Labeling collections of objects Humans deal with complexity by assigning a label to an assembly of objects. An ADT manages complexity through abstraction. Hierarchies of labels Ex1: transistors ⇒ gates ⇒ CPU. In a program, implement an ADT, then think only about the ADT, not its implementation. 30 15
  • 16. Logical vs. Physical Form Data items have both a logical and a physical form. Logical form: definition of the data item within an ADT. Ex: Integers in mathematical sense: +, - Physical form: implementation of the data item within a data structure. Ex: 16/32 bit integers, overflow. 31 Data Type ADT: Data Items: Type Logical Form Operations Data Structure: Data Items: Storage Space Physical Form Subroutines 32 16
  • 17. Problems, Algorithms and Programs Programmers deal with: problems, algorithms and computer programs. 33 Problems Problem: a task to be performed. Best thought of as inputs and matching outputs. Problem definition should include constraints on the resources that may be consumed by any acceptable solution. 34 17
  • 18. Problems (cont) Problems ⇔ mathematical functions A function is a matching between inputs (the domain) and outputs (the range). An input to a function may be single number, or a collection of information. The values making up an input are called the parameters of the function. A particular input must always result in the same output every time the function is computed. 35 Algorithms and Programs Algorithm: a method or a process followed to solve a problem. A recipe: The algorithm gives us a “recipe” for solving the problem by performing a series of steps, where each step is completely understood and doable. An algorithm takes the input to a problem (function) and transforms it to the output. A mapping of input to output. A problem can be solved by many algorithms. 36 18
  • 19. A problem can have many algorithms For example, the problem of sorting can be solved by the following algorithms: Insertion sort Bubble sort Selection sort Shell sort Merge sort Others 37 Algorithm Properties An algorithm possesses the following properties: It must be correct. It must be composed of a series of concrete steps. There can be no ambiguity as to which step will be performed next. It must be composed of a finite number of steps. It must terminate. A computer program is an instance, or concrete representation, for an algorithm in some programming language. 38 19
  • 20. Programs A computer program is a concrete representation of an algorithm in some programming language. Naturally, there are many programs that are instances of the same algorithms, since any modern programming language can be used to implement any algorithm. 39 References Michael Main, Data Structures and Other Objects Using Java (Third Edition) Abdisalam Issa-Salwe, Taibah University, Madinah, Saudi Arabia. 40 20