SlideShare a Scribd company logo
1 of 26
OVERVIEW OF
DATA STRUCTURE AND ITS
TYPES
2/21/2018 BY MS. SHAISTA QADIR 1
PRESENTED BY
Shaista Qadir
Lecturer king khalid university
CONTENTS
DEFINITION OF DATA STRUCTURES & ALGORITHM
OVERVIEW OF DATA STRUCTURES
TYPES OF DATA STRUCTURE
LINEAR DATA STRUCTURE
NON-LINEAR DATA STRUCTURE
ABSTRACT DATA TYPE.
2/21/2018 BY MS. SHAISTA QADIR 2
DATA STRUCTURES & algorithm
2/21/2018 BY MS. SHAISTA QADIR 3
 A data structure is an arrangement of data in a computer’s memory .
 Data structures include arrays, linked lists, stacks, binary trees, and
hash tables, among others.
 Algorithms manipulate the data in these structures in various ways,
such as searching for a particular data item and sorting the data.
 It is a frame-work for storing, retrieving and manipulating data as
per the programming requirements.
 It is a logical way of storing data and it also define mechanism of
retrieve data.
 Thus, A Data Structure chosen specially for an algorithm, shall make
the algorithm more efficient.
Overview of Data Structures
 Another way to look at data structures is to focus on their
strengths and weaknesses.
 The following Table 1 shows the advantages and disadvantages of
the various data structures.
2/21/2018 BY MS. SHAISTA QADIR 4
Types of data structure
2/21/2018 BY MS. SHAISTA QADIR 5
Primitive data structures
 These are data structures that can be manipulated directly
by machine instructions. In java programming language,
the different primitive data structures are
 byte 1 byte
 short 2 bytes
 int 4 bytes
 long 8 bytes
2/21/2018 BY MS. SHAISTA QADIR 6
 float 4 bytes
 double 8 bytes
 boolean 1 bit
 char 16 bits = 2 bytes
NON Primitive data structures
 These are data structures that cannot be manipulated
directly by machine instructions.
 They are classified into
◦ linear data structures
◦ non-linear data structures.
2/21/2018 BY MS. SHAISTA QADIR 7
LINEAR DATA STRUCTURE
 The data structures that show the relationship of logical
adjacency between the elements are called linear data
structures.
 A linear data structure traverses the data elements
sequentially, in which one data element can be linearly
reached.
Example: Array, Linked list, Stack & Queue linear data
structures.
2/21/2018 BY MS. SHAISTA QADIR 8
NON LINEAR DATA STRUCTURE
 The data structures that do not show the relationship of
logical adjacency between the elements are called non-
linear data structures.
 We cannot linearly reach a data item.
 Every data item is attached to several other data items.
 Example: Trees, Graphs and Files are non-linear data
structures.
2/21/2018 BY MS. SHAISTA QADIR 9
ARRAY
 An array is a collection of homogeneous(same) type of
data elements.
 An array data structure has a collection of elements and
each element is identified by at least one index.
 An array elements are stored in contiguous or adjacent
memory locations
 An array Index always start with Zero.
 Operations performed on arrays are: Traversing,
Searching, Insertion, Deletion, Sorting & Merging
 Representation of array in memory .
2/21/2018 BY MS. SHAISTA QADIR 10
ARRAY in java
 Arrays in Java use syntax similar to that in C and C++ and not that
different from other languages, but there are nevertheless some
unique aspects to the Java approach.
 In many programming languages even object-oriented ones such as
C++, arrays are primitive types, but in Java they’re treated as
objects.
 Accordingly, we must use the new operator to create an array:
◦ int[] intArray; // defines a reference to an array
◦ intArray = new int[100]; // creates the array, and
◦ // sets intArray to refer to it
 Or we can use the equivalent single-statement approach:
◦ int[] intArray = new int[100];
◦ int intArray[] = new int[100]; // alternative syntax
 Arrays have a length field, which can be used to find the size (the
number of elements) of an array:
 int arrayLength = intArray.length; // find array size
2/21/2018 BY MS. SHAISTA QADIR 11
Vectors in java
 A vector is a data structure with a contiguous block of
memory, just like an array.
 Storage is managed automatically so that on an attempt
to insert an element into a full vector, a larger memory
block is allocated for the vector, the vector elements are
copied to the new block, and the old block is released.
 Vector is thus a flexible array; that is, an array whose size
can be dynamically changed.
 Vectors may work when the amount of data isn’t known
in advance.
2/21/2018 BY MS. SHAISTA QADIR 12
Vectors in java
 Vector implements a dynamic array.
 Vector proves to be very useful if you don't know the size
of the array in advance or you just need one that can
change sizes over the lifetime of a program.
 The key difference between Arrays and Vectors in Java is
that Vectors are dynamically-allocated.
 They aren't declared to contain a type of variable;
instead, each Vector contains a dynamic list of references
to other objects.
 The Vector class is found in the java.util package.
2/21/2018 BY MS. SHAISTA QADIR 13
CONSTRUCTION OF VECTORS
 import java.util package to make the vectors working in
your program.
 SYNTAX
◦ Vector vectorname = new Vector(vector capacity, capacity
increment);
 Example:
◦ Vector list = new Vector(3,4);
 Capacity of the vector list is 3 and capacity increment is 4
 We cannot directly store simple data type in a vector.
2/21/2018 BY MS. SHAISTA QADIR 14
METHODS IN VECTOR
1- list.addElement(item) : add item to list at the end.
2- list.elementAt(n) : return name of object at n position.
3- list.size() : returns the number of objects in list.
4- list.removeElementAt(n) : removes object at nth position.
5- list.removeElement(item) : removes item from list.
6- list.removeAllElements() : removes all objects from list.
7- list.copyinto(Array) : copy all elements to array.
8- list.insertElementAt(item, n) : inserts item to nth position.
9- list.isEmpty() : returns true if empty otherwise returns false.
10- list.lastElement(Array) : gives last object from the list.
11- list.firstElement(Array) : gives first object from the list.
12- list.clear(Array) : it will removes all elements from list.
2/21/2018 BY MS. SHAISTA QADIR 15
METHODS IN VECTOR
 An Example code to insert elements, APPLE and ORANGE in
the vector fruits
import java.util.*;
class VectorExample
{
public static void main(String args[])
{
Vector fruits = new Vector(5,4);
fruits.insertElementAt(“APPLE",0);
fruits.insertElementAt(“ORANGE",1);
}
}
2/21/2018 BY MS. SHAISTA QADIR 16
LINKED LIST
 A Linked list is a linear collection of data elements .It
has two part one is info and other is link part.
 info part stores information/Data and link part stores
address of next node.
 Operations Performed: Traversing, Searching, Insertion
& Deletion
2/21/2018 BY MS. SHAISTA QADIR 17
stack (lifo)
 A Stack is a list of elements in which an element may be
inserted or deleted at one end which is known as TOP
of the stack.
 A Stack also called last in first out (LIFO) system.
 Operations Performed:
 Push: add an element in stack
 Pop: remove an element in stack
2/21/2018 BY MS. SHAISTA QADIR 18
EEE TOP
DDD
CCC
BBB
AAA
queue (fifo)
 A Queue also called first in first out (FIFO) system.
 A queue is a linear list of element in which insertion can
be done at one end which is known as rear and deletion
can be done at other end which is known as front.
 Operations Performed:
 Insertion : add a new element in queue.
 Deletion: Removing an element in queue.
2/21/2018 BY MS. SHAISTA QADIR 19
Non-linear data
structure
 TREE
 GRAPH
2/21/2018 BY MS. SHAISTA QADIR 20
TREE
 A Tree data structure has a collection of nodes starting
at the root node.
 Each node has a value and a list of child nodes.
 Data in a particular node can be reached non-linearly.
 Operations Performed: Traversing, Searching, Insertion
& Deletion
2/21/2018 BY MS. SHAISTA QADIR 21
graph
 Data sometimes contain a relationship between pairs of
elements which is not necessarily hierarchical in nature.
 For example, an airline flies only between cities
connected by lines.
 Operations Performed: Traversing, Searching, Insertion
& Deletion
2/21/2018 BY MS. SHAISTA QADIR 22
abstract data type
(ADT)
2/21/2018 BY MS. SHAISTA QADIR 23
 An abstract data type (ADT) is defined as a mathematical
model of the data objects that make up a data type as well
as the functions that operate on these objects.
 An item specified in terms of operations is called an
abstract data type.
 Roughly speaking, it’s a way of looking at a data structure:
 focusing on what it does and ignoring how it does its job.
 Examples: Stack, Queue, etc
abstract data type
(ADT)
2/21/2018 BY MS. SHAISTA QADIR 24
• To write a program, a programmer should
•first specify each task in terms of input, output,
operations performed on input, the rules associated
with the operations.
•After this the implementation of the program may
start.
• Abstract Data Type is defined in terms of data items and
the associated operations and not its implementation.
• In Java it is in the form of an ‘Interface’
• Interfaces are similar to classes and contain abstract
method or signatures.
• Methods in an Interface are defined by the class which
implements the Interface.
abstract data type
(ADT)
2/21/2018 BY MS. SHAISTA QADIR 25
• EXAMPLE
public interface Valuable
{
public boolean isValuable ();
}
public class Gold implements Valuable
{
public boolean isValuable ()
{
return true;
}
}
Interface Class Valuable
Has Abstract method
isValuable
Implementation Class Gold.
The method isValuable() is
implemented here.
2/21/2018 BY MS. SHAISTA QADIR 26
THANK YOU

More Related Content

What's hot

Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in pythonTMARAGATHAM
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)Hirra Sultan
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structurekalyanineve
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm03446940736
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 

What's hot (20)

Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Hashing
HashingHashing
Hashing
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
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)
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
Data structure and its types.
Data structure and its types.Data structure and its types.
Data structure and its types.
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Java threads
Java threadsJava threads
Java threads
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 

Similar to Lecture 1

Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdNimmi Weeraddana
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESsuthi
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxmexiuro901
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS Adams Sidibe
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Tutort Academy
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)ShrushtiGole
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresresamplopsurat
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureadeel hamid
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...AntareepMajumder
 

Similar to Lecture 1 (20)

UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
Ch1
Ch1Ch1
Ch1
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
 

More from Shaista Qadir

More from Shaista Qadir (6)

Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Sorting
SortingSorting
Sorting
 
Searching
SearchingSearching
Searching
 
Queue
QueueQueue
Queue
 
linked list
linked listlinked list
linked list
 
Complexity Analysis
Complexity Analysis Complexity Analysis
Complexity Analysis
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Lecture 1

  • 1. OVERVIEW OF DATA STRUCTURE AND ITS TYPES 2/21/2018 BY MS. SHAISTA QADIR 1 PRESENTED BY Shaista Qadir Lecturer king khalid university
  • 2. CONTENTS DEFINITION OF DATA STRUCTURES & ALGORITHM OVERVIEW OF DATA STRUCTURES TYPES OF DATA STRUCTURE LINEAR DATA STRUCTURE NON-LINEAR DATA STRUCTURE ABSTRACT DATA TYPE. 2/21/2018 BY MS. SHAISTA QADIR 2
  • 3. DATA STRUCTURES & algorithm 2/21/2018 BY MS. SHAISTA QADIR 3  A data structure is an arrangement of data in a computer’s memory .  Data structures include arrays, linked lists, stacks, binary trees, and hash tables, among others.  Algorithms manipulate the data in these structures in various ways, such as searching for a particular data item and sorting the data.  It is a frame-work for storing, retrieving and manipulating data as per the programming requirements.  It is a logical way of storing data and it also define mechanism of retrieve data.  Thus, A Data Structure chosen specially for an algorithm, shall make the algorithm more efficient.
  • 4. Overview of Data Structures  Another way to look at data structures is to focus on their strengths and weaknesses.  The following Table 1 shows the advantages and disadvantages of the various data structures. 2/21/2018 BY MS. SHAISTA QADIR 4
  • 5. Types of data structure 2/21/2018 BY MS. SHAISTA QADIR 5
  • 6. Primitive data structures  These are data structures that can be manipulated directly by machine instructions. In java programming language, the different primitive data structures are  byte 1 byte  short 2 bytes  int 4 bytes  long 8 bytes 2/21/2018 BY MS. SHAISTA QADIR 6  float 4 bytes  double 8 bytes  boolean 1 bit  char 16 bits = 2 bytes
  • 7. NON Primitive data structures  These are data structures that cannot be manipulated directly by machine instructions.  They are classified into ◦ linear data structures ◦ non-linear data structures. 2/21/2018 BY MS. SHAISTA QADIR 7
  • 8. LINEAR DATA STRUCTURE  The data structures that show the relationship of logical adjacency between the elements are called linear data structures.  A linear data structure traverses the data elements sequentially, in which one data element can be linearly reached. Example: Array, Linked list, Stack & Queue linear data structures. 2/21/2018 BY MS. SHAISTA QADIR 8
  • 9. NON LINEAR DATA STRUCTURE  The data structures that do not show the relationship of logical adjacency between the elements are called non- linear data structures.  We cannot linearly reach a data item.  Every data item is attached to several other data items.  Example: Trees, Graphs and Files are non-linear data structures. 2/21/2018 BY MS. SHAISTA QADIR 9
  • 10. ARRAY  An array is a collection of homogeneous(same) type of data elements.  An array data structure has a collection of elements and each element is identified by at least one index.  An array elements are stored in contiguous or adjacent memory locations  An array Index always start with Zero.  Operations performed on arrays are: Traversing, Searching, Insertion, Deletion, Sorting & Merging  Representation of array in memory . 2/21/2018 BY MS. SHAISTA QADIR 10
  • 11. ARRAY in java  Arrays in Java use syntax similar to that in C and C++ and not that different from other languages, but there are nevertheless some unique aspects to the Java approach.  In many programming languages even object-oriented ones such as C++, arrays are primitive types, but in Java they’re treated as objects.  Accordingly, we must use the new operator to create an array: ◦ int[] intArray; // defines a reference to an array ◦ intArray = new int[100]; // creates the array, and ◦ // sets intArray to refer to it  Or we can use the equivalent single-statement approach: ◦ int[] intArray = new int[100]; ◦ int intArray[] = new int[100]; // alternative syntax  Arrays have a length field, which can be used to find the size (the number of elements) of an array:  int arrayLength = intArray.length; // find array size 2/21/2018 BY MS. SHAISTA QADIR 11
  • 12. Vectors in java  A vector is a data structure with a contiguous block of memory, just like an array.  Storage is managed automatically so that on an attempt to insert an element into a full vector, a larger memory block is allocated for the vector, the vector elements are copied to the new block, and the old block is released.  Vector is thus a flexible array; that is, an array whose size can be dynamically changed.  Vectors may work when the amount of data isn’t known in advance. 2/21/2018 BY MS. SHAISTA QADIR 12
  • 13. Vectors in java  Vector implements a dynamic array.  Vector proves to be very useful if you don't know the size of the array in advance or you just need one that can change sizes over the lifetime of a program.  The key difference between Arrays and Vectors in Java is that Vectors are dynamically-allocated.  They aren't declared to contain a type of variable; instead, each Vector contains a dynamic list of references to other objects.  The Vector class is found in the java.util package. 2/21/2018 BY MS. SHAISTA QADIR 13
  • 14. CONSTRUCTION OF VECTORS  import java.util package to make the vectors working in your program.  SYNTAX ◦ Vector vectorname = new Vector(vector capacity, capacity increment);  Example: ◦ Vector list = new Vector(3,4);  Capacity of the vector list is 3 and capacity increment is 4  We cannot directly store simple data type in a vector. 2/21/2018 BY MS. SHAISTA QADIR 14
  • 15. METHODS IN VECTOR 1- list.addElement(item) : add item to list at the end. 2- list.elementAt(n) : return name of object at n position. 3- list.size() : returns the number of objects in list. 4- list.removeElementAt(n) : removes object at nth position. 5- list.removeElement(item) : removes item from list. 6- list.removeAllElements() : removes all objects from list. 7- list.copyinto(Array) : copy all elements to array. 8- list.insertElementAt(item, n) : inserts item to nth position. 9- list.isEmpty() : returns true if empty otherwise returns false. 10- list.lastElement(Array) : gives last object from the list. 11- list.firstElement(Array) : gives first object from the list. 12- list.clear(Array) : it will removes all elements from list. 2/21/2018 BY MS. SHAISTA QADIR 15
  • 16. METHODS IN VECTOR  An Example code to insert elements, APPLE and ORANGE in the vector fruits import java.util.*; class VectorExample { public static void main(String args[]) { Vector fruits = new Vector(5,4); fruits.insertElementAt(“APPLE",0); fruits.insertElementAt(“ORANGE",1); } } 2/21/2018 BY MS. SHAISTA QADIR 16
  • 17. LINKED LIST  A Linked list is a linear collection of data elements .It has two part one is info and other is link part.  info part stores information/Data and link part stores address of next node.  Operations Performed: Traversing, Searching, Insertion & Deletion 2/21/2018 BY MS. SHAISTA QADIR 17
  • 18. stack (lifo)  A Stack is a list of elements in which an element may be inserted or deleted at one end which is known as TOP of the stack.  A Stack also called last in first out (LIFO) system.  Operations Performed:  Push: add an element in stack  Pop: remove an element in stack 2/21/2018 BY MS. SHAISTA QADIR 18 EEE TOP DDD CCC BBB AAA
  • 19. queue (fifo)  A Queue also called first in first out (FIFO) system.  A queue is a linear list of element in which insertion can be done at one end which is known as rear and deletion can be done at other end which is known as front.  Operations Performed:  Insertion : add a new element in queue.  Deletion: Removing an element in queue. 2/21/2018 BY MS. SHAISTA QADIR 19
  • 20. Non-linear data structure  TREE  GRAPH 2/21/2018 BY MS. SHAISTA QADIR 20
  • 21. TREE  A Tree data structure has a collection of nodes starting at the root node.  Each node has a value and a list of child nodes.  Data in a particular node can be reached non-linearly.  Operations Performed: Traversing, Searching, Insertion & Deletion 2/21/2018 BY MS. SHAISTA QADIR 21
  • 22. graph  Data sometimes contain a relationship between pairs of elements which is not necessarily hierarchical in nature.  For example, an airline flies only between cities connected by lines.  Operations Performed: Traversing, Searching, Insertion & Deletion 2/21/2018 BY MS. SHAISTA QADIR 22
  • 23. abstract data type (ADT) 2/21/2018 BY MS. SHAISTA QADIR 23  An abstract data type (ADT) is defined as a mathematical model of the data objects that make up a data type as well as the functions that operate on these objects.  An item specified in terms of operations is called an abstract data type.  Roughly speaking, it’s a way of looking at a data structure:  focusing on what it does and ignoring how it does its job.  Examples: Stack, Queue, etc
  • 24. abstract data type (ADT) 2/21/2018 BY MS. SHAISTA QADIR 24 • To write a program, a programmer should •first specify each task in terms of input, output, operations performed on input, the rules associated with the operations. •After this the implementation of the program may start. • Abstract Data Type is defined in terms of data items and the associated operations and not its implementation. • In Java it is in the form of an ‘Interface’ • Interfaces are similar to classes and contain abstract method or signatures. • Methods in an Interface are defined by the class which implements the Interface.
  • 25. abstract data type (ADT) 2/21/2018 BY MS. SHAISTA QADIR 25 • EXAMPLE public interface Valuable { public boolean isValuable (); } public class Gold implements Valuable { public boolean isValuable () { return true; } } Interface Class Valuable Has Abstract method isValuable Implementation Class Gold. The method isValuable() is implemented here.
  • 26. 2/21/2018 BY MS. SHAISTA QADIR 26 THANK YOU