SlideShare a Scribd company logo
using Java
2015
Data Structure
Prepared by: Mahmoud Rafeek Al-farra
in Java
2. Introduction to data structure
mfarra.cst.ps www.fb.com/MahmoudRFarra
Contents
Big - Oh notation
Generic programming
Collection Classes
Applications of data structure
What is data structure ?
What is data structure ?
mfarra.cst.ps www.fb.com/MahmoudRFarra
 Data Structure:
 Abstract way to organize information.
 A collection of basic data types.
 Algorithm:
 Abstract way to perform computation tasks.
What is data structure ?
mfarra.cst.ps www.fb.com/MahmoudRFarra
 Classification of data structure:
Data
Structure
Structure
Linear
Non-Linear
Memory
Allocation
Static
Dynamic
Linear data structure
mfarra.cst.ps www.fb.com/MahmoudRFarra
Linked List
Stack
Queue
Non-Linear data structure
mfarra.cst.ps www.fb.com/MahmoudRFarra
Tree
Graph
Heap
Static memory allocation
mfarra.cst.ps www.fb.com/MahmoudRFarra
 Static memory allocation means the program must
obtain its space before the execution and can not
obtain more while or after execution.
 Example:
 array data structure
Dynamic memory allocation
mfarra.cst.ps www.fb.com/MahmoudRFarra
 The dynamic memory allocation is the ability for a
program to obtain more memory space at execution
time to hold new nodes and to release space no longer
needed.
 Dynamic data structures as:
 Array lists, Vectors
 Linked Lists
 Stacks, Queues
 Trees, Heaps
Applications of data structure
mfarra.cst.ps www.fb.com/MahmoudRFarra
 Priority Queue: in banks, restaurants, …
 Hash Tables: in banks for combining two or more
accounts for matching Social Security Numbers.
 Family Tree
 Country Map
 Queue of tasks
 Order of operations in computer
Generic programming
mfarra.cst.ps www.fb.com/MahmoudRFarra
 Generic programming refers to writing code that will
work for many types of data.
 Generics let you parameterize types.
 With this capability, you can define a class or a
method with generic types that the compiler can
replace with concrete types.
Generic programming
mfarra.cst.ps www.fb.com/MahmoudRFarra
 For example:
 Java defines a generic ArrayList class for
storing the elements of a generic type.
 From this generic class, you can create an
ArrayList object for holding strings and an
ArrayList object for holding numbers.
 Here, strings and numbers are concrete types
that replace the generic type.
Collections
mfarra.cst.ps www.fb.com/MahmoudRFarra
 A Collection is a data type that is capable of holding
a group of items.
 The Collection interface defines the common
operations for lists, vectors, stacks, queues, priority
queues, and sets.
 In Java, Collection classes can be implemented as a
class, along with methods to add, remove, and
examine items.
 Think about a bag
Collection Classes
mfarra.cst.ps www.fb.com/MahmoudRFarra
 A bag can be put in its initial state, which is an empty
bag.
 Numbers can be added into the bag.
 You may check how many occurrences of a certain
number are in the bag.
 Numbers can be removed from the bag.
 You can check how many numbers are in the bag.
All the interfaces and classes defined in the Java Collections
Framework are grouped in the java.util package.
Collection Classes
mfarra.cst.ps www.fb.com/MahmoudRFarra
Examples
Collection classes in Java
Array List
Stack
Queue
List
Linked List
Heap
Sets store a group of nonduplicate elements.
Lists store an ordered collection of elements.
Stacks store objects that are processed in a last-in, first-out fashion.
Queues store objects that are processed in a first-in, first-out fashion.
PriorityQueues store objects that are processed in the order of their priorities.
Collection Classes
mfarra.cst.ps www.fb.com/MahmoudRFarra
Collection Test
mfarra.cst.ps www.fb.com/MahmoudRFarra
import java.util.*;
public class TestCollection {
public static void main(String[] args) {
ArrayList<String> collection1 = new ArrayList<>();
collection1.add("New York");
collection1.add("Atlanta");
System.out.println("A list of cities in collection1:");
System.out.println(collection1);
System.out.println("nIs Dallas in collection1? "+ collection1.contains("Dallas"));
collection1.remove("Dallas");
System.out.println("n" + collection1.size() + " cities are in collection1 now");
Collection<String> collection2 = new ArrayList<>();
collection2.add("Seattle");
collection2.add("Portland");
System.out.println("nA list of cities in collection2:");
System.out.println(collection2);
Collection Test
mfarra.cst.ps www.fb.com/MahmoudRFarra
The Collection interface contains the methods for manipulating the elements
in a collection.
Big - Oh notation
mfarra.cst.ps www.fb.com/MahmoudRFarra
 We might be satisfied with evaluating the performance
or complexity of data structures by precisely counting
the number of statements executed or objects
referenced.
 We adopt special notation to define upper bounds
and lower bounds on functions.
 In CS, usually the functions we are bounding are
running times, memory requirements.
Big - Oh notation
mfarra.cst.ps www.fb.com/MahmoudRFarra
using Java
2015
FB: M a h m o u d R F a r r a
YouTube: M a h m o u d R F a r
SlidesShare: mralfarra
Thank you

More Related Content

What's hot (20)

PPT
Chapter 3: basic sorting algorithms data structure
Mahmoud Alfarra
 
PPT
Chapter 5: linked list data structure
Mahmoud Alfarra
 
PPTX
Presentation on Elementary data structures
Kuber Chandra
 
PPTX
Presentation on queue
Rojan Pariyar
 
PDF
Datastructure
Griffinder VinHai
 
PPTX
Data structure and its types
Navtar Sidhu Brar
 
PPT
Data structures
Manaswi Sharma
 
PPTX
Array vs array list
Ravi Shetye
 
PPTX
Introduction to data structure
Vivek Kumar Sinha
 
PPTX
Bca ii dfs u-1 introduction to data structure
Rai University
 
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Hassan Ahmed
 
PDF
Data structures (introduction)
Arvind Devaraj
 
PPTX
Data structure & its types
Rameesha Sadaqat
 
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
PPT
Data Structure In C#
Shahzad
 
PPT
Queue Data Structure
Zidny Nafan
 
PPTX
Introduction to data structure
NUPOORAWSARMOL
 
PPT
L11 array list
teach4uin
 
PPTX
Mca ii dfs u-1 introduction to data structure
Rai University
 
PPTX
Data Structure -List Stack Queue
surya pandian
 
Chapter 3: basic sorting algorithms data structure
Mahmoud Alfarra
 
Chapter 5: linked list data structure
Mahmoud Alfarra
 
Presentation on Elementary data structures
Kuber Chandra
 
Presentation on queue
Rojan Pariyar
 
Datastructure
Griffinder VinHai
 
Data structure and its types
Navtar Sidhu Brar
 
Data structures
Manaswi Sharma
 
Array vs array list
Ravi Shetye
 
Introduction to data structure
Vivek Kumar Sinha
 
Bca ii dfs u-1 introduction to data structure
Rai University
 
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Hassan Ahmed
 
Data structures (introduction)
Arvind Devaraj
 
Data structure & its types
Rameesha Sadaqat
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
Data Structure In C#
Shahzad
 
Queue Data Structure
Zidny Nafan
 
Introduction to data structure
NUPOORAWSARMOL
 
L11 array list
teach4uin
 
Mca ii dfs u-1 introduction to data structure
Rai University
 
Data Structure -List Stack Queue
surya pandian
 

Similar to 2 introduction to data structure (20)

PPT
12_-_Collections_Framework
Krishna Sujeer
 
PDF
1 intro of data structure course
Mahmoud Alfarra
 
PPTX
Java Unit 2 (Part 2)
Dr. SURBHI SAROHA
 
PDF
Java cheatsheet
Anass SABANI
 
PPT
Oop lecture7
Shahriar Robbani
 
PPTX
collection framework.pptx
SoniaKapoor56
 
PPTX
List interface in collections framework
Ravi Chythanya
 
PPT
Collection framework
DilvarSingh2
 
PPTX
VTUOOPMCA5THMODULECollection OverV .pptx
VeenaNaik23
 
PPTX
mca5thCollection OverViCollection O.pptx
VeenaNaik23
 
PPTX
VTUOOPMCA5THMODULEvCollection OverV.pptx
VeenaNaik23
 
PPTX
VTUOOPMCA5THMODULECollection OverVi.pptx
VeenaNaik23
 
PPT
Core & advanced java classes in mumbai
Vibrant Technologies & Computers
 
PPSX
Lecture 1
Shaista Qadir
 
PPT
STRINGS IN JAVA
LOVELY PROFESSIONAL UNIVERSITY
 
PPTX
Java Hands-On Workshop
Arpit Poladia
 
PPTX
Fundamental Data Structures and Algorithms.pptx
JennyLynMasgong
 
PPT
Java collection
Arati Gadgil
 
PPTX
Collection in java to store multiple values.pptx
ASHUTOSH TRIVEDI
 
PPT
Java Collection fundamentals and Uses Unit
vinipant
 
12_-_Collections_Framework
Krishna Sujeer
 
1 intro of data structure course
Mahmoud Alfarra
 
Java Unit 2 (Part 2)
Dr. SURBHI SAROHA
 
Java cheatsheet
Anass SABANI
 
Oop lecture7
Shahriar Robbani
 
collection framework.pptx
SoniaKapoor56
 
List interface in collections framework
Ravi Chythanya
 
Collection framework
DilvarSingh2
 
VTUOOPMCA5THMODULECollection OverV .pptx
VeenaNaik23
 
mca5thCollection OverViCollection O.pptx
VeenaNaik23
 
VTUOOPMCA5THMODULEvCollection OverV.pptx
VeenaNaik23
 
VTUOOPMCA5THMODULECollection OverVi.pptx
VeenaNaik23
 
Core & advanced java classes in mumbai
Vibrant Technologies & Computers
 
Lecture 1
Shaista Qadir
 
Java Hands-On Workshop
Arpit Poladia
 
Fundamental Data Structures and Algorithms.pptx
JennyLynMasgong
 
Java collection
Arati Gadgil
 
Collection in java to store multiple values.pptx
ASHUTOSH TRIVEDI
 
Java Collection fundamentals and Uses Unit
vinipant
 
Ad

More from Mahmoud Alfarra (20)

PPT
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
PPT
Computer Programming, Loops using Java
Mahmoud Alfarra
 
PPT
Chapter9 graph data structure
Mahmoud Alfarra
 
PPT
Chapter 8: tree data structure
Mahmoud Alfarra
 
PPT
Chapter 7: Queue data structure
Mahmoud Alfarra
 
PPT
Chapter 6: stack data structure
Mahmoud Alfarra
 
PPT
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
PPT
Chapter1 intro toprincipleofc#_datastructure_b_cs
Mahmoud Alfarra
 
PPT
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
PPTX
3 classification
Mahmoud Alfarra
 
PPT
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
PPT
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
PPT
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
PPT
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
PPT
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
PPT
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
PPT
2 programming-using-java how to built application
Mahmoud Alfarra
 
PPT
1 programming-using-java -introduction
Mahmoud Alfarra
 
PPTX
تلخيص النصوص تلقائيا
Mahmoud Alfarra
 
PDF
4×4×4 لتحصيل التميز
Mahmoud Alfarra
 
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Chapter9 graph data structure
Mahmoud Alfarra
 
Chapter 8: tree data structure
Mahmoud Alfarra
 
Chapter 7: Queue data structure
Mahmoud Alfarra
 
Chapter 6: stack data structure
Mahmoud Alfarra
 
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
Chapter1 intro toprincipleofc#_datastructure_b_cs
Mahmoud Alfarra
 
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
3 classification
Mahmoud Alfarra
 
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
2 programming-using-java how to built application
Mahmoud Alfarra
 
1 programming-using-java -introduction
Mahmoud Alfarra
 
تلخيص النصوص تلقائيا
Mahmoud Alfarra
 
4×4×4 لتحصيل التميز
Mahmoud Alfarra
 
Ad

Recently uploaded (20)

PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Introduction presentation of the patentbutler tool
MIPLM
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
infertility, types,causes, impact, and management
Ritu480198
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Difference between write and update in odoo 18
Celine George
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Horarios de distribución de agua en julio
pegazohn1978
 

2 introduction to data structure

  • 1. using Java 2015 Data Structure Prepared by: Mahmoud Rafeek Al-farra in Java 2. Introduction to data structure
  • 2. mfarra.cst.ps www.fb.com/MahmoudRFarra Contents Big - Oh notation Generic programming Collection Classes Applications of data structure What is data structure ?
  • 3. What is data structure ? mfarra.cst.ps www.fb.com/MahmoudRFarra  Data Structure:  Abstract way to organize information.  A collection of basic data types.  Algorithm:  Abstract way to perform computation tasks.
  • 4. What is data structure ? mfarra.cst.ps www.fb.com/MahmoudRFarra  Classification of data structure: Data Structure Structure Linear Non-Linear Memory Allocation Static Dynamic
  • 5. Linear data structure mfarra.cst.ps www.fb.com/MahmoudRFarra Linked List Stack Queue
  • 6. Non-Linear data structure mfarra.cst.ps www.fb.com/MahmoudRFarra Tree Graph Heap
  • 7. Static memory allocation mfarra.cst.ps www.fb.com/MahmoudRFarra  Static memory allocation means the program must obtain its space before the execution and can not obtain more while or after execution.  Example:  array data structure
  • 8. Dynamic memory allocation mfarra.cst.ps www.fb.com/MahmoudRFarra  The dynamic memory allocation is the ability for a program to obtain more memory space at execution time to hold new nodes and to release space no longer needed.  Dynamic data structures as:  Array lists, Vectors  Linked Lists  Stacks, Queues  Trees, Heaps
  • 9. Applications of data structure mfarra.cst.ps www.fb.com/MahmoudRFarra  Priority Queue: in banks, restaurants, …  Hash Tables: in banks for combining two or more accounts for matching Social Security Numbers.  Family Tree  Country Map  Queue of tasks  Order of operations in computer
  • 10. Generic programming mfarra.cst.ps www.fb.com/MahmoudRFarra  Generic programming refers to writing code that will work for many types of data.  Generics let you parameterize types.  With this capability, you can define a class or a method with generic types that the compiler can replace with concrete types.
  • 11. Generic programming mfarra.cst.ps www.fb.com/MahmoudRFarra  For example:  Java defines a generic ArrayList class for storing the elements of a generic type.  From this generic class, you can create an ArrayList object for holding strings and an ArrayList object for holding numbers.  Here, strings and numbers are concrete types that replace the generic type.
  • 12. Collections mfarra.cst.ps www.fb.com/MahmoudRFarra  A Collection is a data type that is capable of holding a group of items.  The Collection interface defines the common operations for lists, vectors, stacks, queues, priority queues, and sets.  In Java, Collection classes can be implemented as a class, along with methods to add, remove, and examine items.  Think about a bag
  • 13. Collection Classes mfarra.cst.ps www.fb.com/MahmoudRFarra  A bag can be put in its initial state, which is an empty bag.  Numbers can be added into the bag.  You may check how many occurrences of a certain number are in the bag.  Numbers can be removed from the bag.  You can check how many numbers are in the bag. All the interfaces and classes defined in the Java Collections Framework are grouped in the java.util package.
  • 14. Collection Classes mfarra.cst.ps www.fb.com/MahmoudRFarra Examples Collection classes in Java Array List Stack Queue List Linked List Heap Sets store a group of nonduplicate elements. Lists store an ordered collection of elements. Stacks store objects that are processed in a last-in, first-out fashion. Queues store objects that are processed in a first-in, first-out fashion. PriorityQueues store objects that are processed in the order of their priorities.
  • 16. Collection Test mfarra.cst.ps www.fb.com/MahmoudRFarra import java.util.*; public class TestCollection { public static void main(String[] args) { ArrayList<String> collection1 = new ArrayList<>(); collection1.add("New York"); collection1.add("Atlanta"); System.out.println("A list of cities in collection1:"); System.out.println(collection1); System.out.println("nIs Dallas in collection1? "+ collection1.contains("Dallas")); collection1.remove("Dallas"); System.out.println("n" + collection1.size() + " cities are in collection1 now"); Collection<String> collection2 = new ArrayList<>(); collection2.add("Seattle"); collection2.add("Portland"); System.out.println("nA list of cities in collection2:"); System.out.println(collection2);
  • 17. Collection Test mfarra.cst.ps www.fb.com/MahmoudRFarra The Collection interface contains the methods for manipulating the elements in a collection.
  • 18. Big - Oh notation mfarra.cst.ps www.fb.com/MahmoudRFarra  We might be satisfied with evaluating the performance or complexity of data structures by precisely counting the number of statements executed or objects referenced.  We adopt special notation to define upper bounds and lower bounds on functions.  In CS, usually the functions we are bounding are running times, memory requirements.
  • 19. Big - Oh notation mfarra.cst.ps www.fb.com/MahmoudRFarra
  • 20. using Java 2015 FB: M a h m o u d R F a r r a YouTube: M a h m o u d R F a r SlidesShare: mralfarra Thank you