Professional Documents
Culture Documents
CPCS-204: Data Structures I
CPCS-204: Data Structures I
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 1
Data
• Collection of facts from which conclusion may be drawn
• Example:
• Temperature is 10o C;
• Conclusion: COLD!
• Types of data:
• Textual: name (Muhammad)
• Numeric: id (375604)
• Audio: voice
• Image: picture
• …
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 2
Data Types
• Built-in constructs of a programming language to manipulate
“basic types of data”
• Character
• Integer
• Real
• …
• Examples
• int, char, double, …
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 3
Data Structures
• A particular way of storing and organizing data in a computer
so that it can be used efficiently
• Group of data elements grouped under one name
• Also referred as Abstract Data Type (ADT)
• Example:
• Array:
int dayTemperatures[24];
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 4
Goal
• Organize data to facilitate efficient
• Storage
• Retrieval
• Manipulation
• Design Issue
• Challenge is to select most appropriate DS for a problem
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 5
Data Structures Types
• Array
• Stack
• Linked list
• Queue
• Tree
• Graph
• Hash Table
• Heap
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 6
Data Structures Classification
• Based on Existence
• Physical
• Can be created independently
– Array, Linked List
• Logical
• Can’t be created independently
– Stack, queue, tree, graph
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 7
Data Structures Classification
• Based on Memory allocation
• Static
• Fixed sized DSs
– Arrays
• Dynamic:
• Change size
– Linked lists
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 8
Data Structures Classification
• Based on Representation
• Linear
• Arrays
• Linked lists
• Stack
• Queues
• Non-linear
• Trees
• Graphs
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 9
Operations on Data Structures
• Traversing
• Accessing/visiting each data element exactly once so that certain
items in the data may be processed
• Searching
• Finding location of a given data element (key) in the structure
• Insertion
• Adding new data element to structure
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 10
Operations on Data Structures
• Deletion
• Removing a data element from structure
• Sorting
• Arranging the data elements in some logical fashion
• ↑↓
• Merging
• Combining data elements form two or more data structures into one
CPCS204, Data Structures I, Updated by Pr. Abdullah Basuhail, CS, FCIT, KAU, 1442H-2021G 11