0% found this document useful (0 votes)
10 views23 pages

Lecture Week 15.1b

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views23 pages

Lecture Week 15.1b

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

What is Data Structure?

Data Structures
◼ Data: Any digital file stored in computer system, such as: audio/video file,
word file, pdf file, images, text file, etc.

◼ Data structures is a way to organize, process, retrieve, store data efficiently.

◼ For specific purposes, appropriate data structures can be used.


Dictionary:
sorted data

◼ Data is words with their meanings.


◼ Words are arranged in Alphabetic
order (sorted Data)
◼ Searching is fast
◼ Makes it easier to insert new words
at proper place
Data Structures are Classified into Two Types
◼ Linear data structure: arrange sequentially or linearly where each and
every element is attached to its previous and next adjacent.
• Array
• Linked list
• Stacks
• Queues
◼ Non-linear data structure: not arranged sequentially or linearly
• Trees
• Graphs
Array Data Structure
◼ Suppose we are looking for a specific data value from 50,000 items
◼ [ dbh nik aks rby cjk maf yyt qmn bbn pkm fad … … … … rsa udi]

◼ The data could be in beginning of the array or towards the end…

◼ It would be lot easier if data were organized.


◼ One can carry out different operations on array elements
◼ Search for an element
◼ Delete an element
◼ Insert a new element

• Deletion and Insertion would need lot of operations


• Searching would need very few operations if array is sorted
Is it possible to handle the problem
without shifting so many data values?
Linked List Data Structure
Linked List Data Structure
Locations: 42 76 53

42 A 76 B 53 C 

Head

◼ A linked list is a series of connected nodes


◼ Each node contains
node
◼ Data (any type)
A
◼ Link to the next node in the list
data link
◼ The last node points to NULL
Operations on Linked List
Locations: 42 76 53

42 A 76 B 53 C 

Head

◼ Deletion
◼ Insertion
◼ Searching
Queue Data Structure
Queue Data Structure
◼ Cannot join in any random position in the list
◼ Must join at end of the list
◼ Only the first person in the list gets serviced (front of the list),
for ex: bank waiting line
Queue Data Structure
Stack Data structure
Stack Data Structure
◼ You cannot access any
random element of stack
◼ Only top element can be
accessed or removed
Tree
Nature Lover’s View of A Tree
Computer Scientist’s View
Basics
A tree data structure stores information in nodes
• Similar to linked lists:
- There is a first node or root
- Each node has a variable number of references to successors
- Each node, other than the root, has exactly one node pointing to it
Graph
What is a graph?

• Graphs represent the relationships among data items


• A graph G consists of
- a set V of nodes (vertices)
- a set E of edges: each edge connects two nodes
• Each node represents an item
• Each edge represents the relationship between two items

node
edge

You might also like