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

PPTX
3 searching algorithms in Java
PPT
Chapter 10: hashing data structure
PPTX
القوائم المترابطة Linked List باستخدام لغة جافا
PPTX
7 stack and vector
PPTX
المحاضرة الثامنة: تراكيب البيانات الطابور
PPTX
5 Array List, data structure course
PDF
3 Array operations
PPT
Chapter 4: basic search algorithms data structure
3 searching algorithms in Java
Chapter 10: hashing data structure
القوائم المترابطة Linked List باستخدام لغة جافا
7 stack and vector
المحاضرة الثامنة: تراكيب البيانات الطابور
5 Array List, data structure course
3 Array operations
Chapter 4: basic search algorithms data structure

What's hot (20)

PPT
Chapter 3: basic sorting algorithms data structure
PPT
Chapter 5: linked list data structure
PPTX
Presentation on Elementary data structures
PPTX
Presentation on queue
PDF
Datastructure
PPTX
Data structure and its types
PPT
Data structures
PPTX
Array vs array list
PPTX
Introduction to data structure
PPTX
Bca ii dfs u-1 introduction to data structure
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
PDF
Data structures (introduction)
PPTX
Data structure & its types
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
PPT
Data Structure In C#
PPT
Queue Data Structure
PPTX
Introduction to data structure
PPT
L11 array list
PPTX
Mca ii dfs u-1 introduction to data structure
PPTX
Data Structure -List Stack Queue
Chapter 3: basic sorting algorithms data structure
Chapter 5: linked list data structure
Presentation on Elementary data structures
Presentation on queue
Datastructure
Data structure and its types
Data structures
Array vs array list
Introduction to data structure
Bca ii dfs u-1 introduction to data structure
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structures (introduction)
Data structure & its types
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structure In C#
Queue Data Structure
Introduction to data structure
L11 array list
Mca ii dfs u-1 introduction to data structure
Data Structure -List Stack Queue
Ad

Similar to 2 introduction to data structure (20)

PPT
12_-_Collections_Framework
PDF
1 intro of data structure course
PPTX
Java Unit 2 (Part 2)
PDF
Java cheatsheet
PPT
Oop lecture7
PPTX
collection framework.pptx
PPTX
List interface in collections framework
PPT
Collection framework
PPTX
VTUOOPMCA5THMODULECollection OverV .pptx
PPTX
mca5thCollection OverViCollection O.pptx
PPTX
VTUOOPMCA5THMODULEvCollection OverV.pptx
PPTX
VTUOOPMCA5THMODULECollection OverVi.pptx
PPT
Core & advanced java classes in mumbai
PPSX
Lecture 1
PPT
PPTX
Java Hands-On Workshop
PPTX
Fundamental Data Structures and Algorithms.pptx
PPT
Java collection
PPTX
Collection in java to store multiple values.pptx
PPT
Java Collection fundamentals and Uses Unit
12_-_Collections_Framework
1 intro of data structure course
Java Unit 2 (Part 2)
Java cheatsheet
Oop lecture7
collection framework.pptx
List interface in collections framework
Collection framework
VTUOOPMCA5THMODULECollection OverV .pptx
mca5thCollection OverViCollection O.pptx
VTUOOPMCA5THMODULEvCollection OverV.pptx
VTUOOPMCA5THMODULECollection OverVi.pptx
Core & advanced java classes in mumbai
Lecture 1
Java Hands-On Workshop
Fundamental Data Structures and Algorithms.pptx
Java collection
Collection in java to store multiple values.pptx
Java Collection fundamentals and Uses Unit
Ad

More from Mahmoud Alfarra (20)

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

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Classroom Observation Tools for Teachers
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Lesson notes of climatology university.
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Cell Structure & Organelles in detailed.
RMMM.pdf make it easy to upload and study
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Classroom Observation Tools for Teachers
01-Introduction-to-Information-Management.pdf
Pharma ospi slides which help in ospi learning
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Computing-Curriculum for Schools in Ghana
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Lesson notes of climatology university.
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Types and Its function , kingdom of life
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O7-L3 Supply Chain Operations - ICLT Program
GDM (1) (1).pptx small presentation for students
102 student loan defaulters named and shamed – Is someone you know on the list?
Cell Structure & Organelles in detailed.

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