0% found this document useful (0 votes)
79 views19 pages

Data Structures and Algorithms: Computer Science Department

This document provides an introduction to data structures and abstract data types. It defines data as facts and statistics collected for reference or analysis, and describes different types of data including textual, numeric, audio, and video. It then defines a data structure as a representation of data and operations on that data, and describes some basic linear and non-linear data structures including arrays, linked lists, stacks, queues, trees, and graphs. The document outlines how data structures are selected based on their ability to represent relationships between data elements and be efficiently processed. It also introduces the concepts of abstract data types and how they are implemented via data structures.

Uploaded by

M I Malik
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)
79 views19 pages

Data Structures and Algorithms: Computer Science Department

This document provides an introduction to data structures and abstract data types. It defines data as facts and statistics collected for reference or analysis, and describes different types of data including textual, numeric, audio, and video. It then defines a data structure as a representation of data and operations on that data, and describes some basic linear and non-linear data structures including arrays, linked lists, stacks, queues, trees, and graphs. The document outlines how data structures are selected based on their ability to represent relationships between data elements and be efficiently processed. It also introduces the concepts of abstract data types and how they are implemented via data structures.

Uploaded by

M I Malik
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/ 19

Data Structures and

Algorithms

Lecture 1

Computer Science Department


Introduction to Data Structure
and
Abstract Data Types

Computer Science Department


What is Data?
• Data
• “facts and statistics collected together for reference or
analysis.” – Google

• Types of data
• Textual: For example, your name (Muhammad)
• Numeric: For example, your ID (090254)
• Audio: For example, your voice
• Video: For example, your voice and picture
• (...)

Computer Science Department


What is Data Structure?
• Data structure is a representation of data and
the operations allowed on that data.

• A data structure is a way to store and organize


data in order to facilitate the access and
modifications.

• Data Structure are the method of representing of


logical relationships between individual data
elements related to the solution of a given
problem.
Computer Science Department
Basic Data Structure

Basic Data Structures

Linear Data Structures Non-Linear Data Structures

Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables

Computer Science Department


array

Linked list

queue
tree stack

Computer Science Department


Selection of Data Structure
• The choice of particular data model* depends
on two consideration:
– It must be rich enough in structure to represent the
relationship between data elements
– The structure should be simple enough that one can
effectively process the data when necessary

* Data Model: is an abstract model that organizes elements of


data and standardizes how they relate to one another and
to the properties of real-world entities.

Computer Science Department


Types of Data Structure
• Linear: In Linear data structure, values are arrange in
linear fashion.
– Array: Fixed-size
– Linked-list: Variable-size
– Stack: Add to top and remove from top

– Queue: Add to back and remove


from front

– Priority queue: Add anywhere, remove the highest


priority

Computer Science Department


Types of Data Structure
• Non-Linear: The data values in this structure are not
arranged in order.
– Hash tables: Unordered lists
which use a ‘hash function’ to insert and search

– Tree: Data is organized in branches.

– Graph: A more general branching structure, with less strict


connection conditions than for a tree

Computer Science Department


Type of Data Structures
• Homogenous: In this type of data structures, values of
the same types of data are stored.
– Array

• Non-Homogenous: In this type of data structures, data


values of different types are grouped and stored.
– Structures
– Classes

Computer Science Department


Abstract Data Type and Data
• Definition:-
Structure
– Abstract Data Types (ADTs) stores data and allow various
operations on the data to access and change it.
– A mathematical model, together with various operations defined
on the model
– An ADT is a collection of data and associated operations for
manipulating that data

• Data Structures
– Physical implementation of an ADT
– data structures used in implementations are provided in a
language (primitive or built-in) or are built from the language
constructs (user-defined)
– Each operation associated with the ADT is implemented by one
or more subroutines in the implementation

Computer Science Department


Abstract Data Type
• ADTs support abstraction, encapsulation, and
information hiding.

• Abstraction is the structuring of a problem into well-


defined entities by defining their data and operations.

• The principle of hiding the used data structure and to


only provide a well-defined interface is known as
encapsulation.

Computer Science Department


The Core Operations of ADT
• Every Collection ADT should provide a way to:
– add an item
– remove an item
– find, retrieve, or access an item

• Many, many more possibilities


– is the collection empty
– make the collection empty
– give me a sub set of the collection

Computer Science Department


Real Value of the Course !!

• No single data structure works well for all


purposes, and so it is important to know the
strengths and limitations of several of them

Computer Science Department


Some frequently used DS.

Computer Science Department


Stacks
• Collection with access only to the last
element inserted
• Last in first out Data4 Top

• insert/push Data3

• remove/pop Data2

• top Data1

• make empty

Computer Science Department


Queues
• Collection with access only to the item that
has been present the longest
• Last in last out or first in first out
• enqueue, dequeue, front
• priority queues and dequeue
Front Back

Data1 Data2 Data3 Data4

Computer Science Department


List
• A Flexible structure, because can grow and
shrink on demand.
Elements can be:
 Inserted
 Accessed
 Deleted
At any position
last
first

Computer Science Department


Tree
• A Tree is a collection of elements called nodes.
• One of the node is distinguished as a root, along with a
relation (“parenthood”) that places a hierarchical
structure on the nodes.
Root

Computer Science Department

You might also like