0% found this document useful (0 votes)
16 views

02 Abstract Data Types

This document discusses the CS250 course on data structures and algorithms. It covers abstract data types (ADTs) and lists as an ADT. The key points are: 1) The course covers ADTs and lists as an ADT, with Dr. Sohail Iqbal as the instructor. The textbook is "Data Structures Using C++" by Nell Dale, Jones and Bartlett Publishers. 2) An ADT specifies permitted operations and time/space guarantees without concerning itself with implementation details. A list is presented as an example ADT, with operations like create, destroy, check if empty/full, etc. 3) A list is a collection of homogeneous elements with a

Uploaded by

Raahima Aamir
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

02 Abstract Data Types

This document discusses the CS250 course on data structures and algorithms. It covers abstract data types (ADTs) and lists as an ADT. The key points are: 1) The course covers ADTs and lists as an ADT, with Dr. Sohail Iqbal as the instructor. The textbook is "Data Structures Using C++" by Nell Dale, Jones and Bartlett Publishers. 2) An ADT specifies permitted operations and time/space guarantees without concerning itself with implementation details. A list is presented as an example ADT, with operations like create, destroy, check if empty/full, etc. 3) A list is a collection of homogeneous elements with a

Uploaded by

Raahima Aamir
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

CS250: Data Structures and Algorithms

Abstract Data Types and


List as ADT

Instructor: Dr. Sohail Iqbal

1
Text book:
– Data Structures Using C++ by Nell Dale, Jones and
Bartlett Publishers. 3rd Ed.

– On LMS with Enrolment code: 4127 5890 6


Native data types does not RSA
Algorithm
• Int: 4 bytes, float: 4 bytes, double: 8 bytes

• RSA algorithm need to store two prime


integers of length 1024 bits = 128 Bytes.

• So, native data types won’t help. However,


language support to define about own data
types: Abstract Data Types
3
You don’t need
to tell the
fabrication
details to
carpenter.

Use
Abstraction:
Hiding details
ADTs and List as ADT
• Abstract Data Types
• What is a List
• List as Abstract Data Type (ADT)
• Operations on List
• Sequential implementation of List
ADT = MRF of a Data Structure
• Abstract Data Type is the MRF (Minimal
Required Functionality) of any Data Structure
along with some operations.

6
Abstract Data Types (ADTs)

• Data storage & operations encapsulated by an ADT.


• ADT specifies permitted operations as well as time and space guarantees.
• User unconcerned with how it’s implemented
 but we are concerned with implementation in this class
• ADT is a concept or convention:
 not something that directly appears in your code
 programming language may provide support for communicating ADT to users
 (e.g. classes in Java & C++)
Dictionary ADT
What is List Data Structure?
We use Lists all the time
List of addresses
List of things to do
List of guests for a party
Grocery list
And so on
 List as an ADT
Values: A list is a collection of homogenous
elements with linear relationship between them.
A Sequential List
• Length of list is 4.
• Maximum number of elements is 6.
• Remember array and list are different things;
array can be used only as a data container
for storing list elements

Data David Rizi Kashif John


Index 0 1 2 3 4 5
What is List Data Structure?
• At the logical level, each element in the list except the
first one has a unique predecessor and each element
except the last one has a unique successor.

• Lists can be unordered; elements may be placed into


a list in no particular order.

• List may be ordered in different ways


What is List Data Structure
• Lists can also be ordered by value.
 A list of names can be ordered alphabetically.
 A list of grades can be ordered numerically.

• Elements of the list may be records (structures).


 In that case, a list may be ordered on the basis of
one or more fields of a record.
 For example, a list of student records may be
ordered based on their first name or their roll
number field.

• The field which is used to sort a list of records, is


called key; such a list is called key ordered list.
List Data Structure
• We often call a value ordered list a sorted
list.

• Key : The field in a record based on which


the elements of a list are ordered logically
(and/or physically).
List ADT
• Structure The list elements are of
ListElementType, and contain a key field
called Key, of KeyType.

• A list may be logically ordered from smallest


unique element key value to largest.
Data David John Kashif Rizi
Index 0 1 2 3 4 5
Operations on the Elements of List ADT
List ADT - Operations
• CreateList(MAX_ELEMENTS, Template)
 Function : Initializes List to empty state

 Input : MAX_ELEMENTS, Template

 Precondition : None

 Output : List

 Post conditions : List exists and is empty


List ADT - Operations
• DestroyList (List)
 Function : Destroys all elements , leaving List in
empty state.

 Input : List

 Preconditions : List has been created

 Output : Empty List


List ADT - Operations
• EmptyList(List) : Returns Boolean value
 Function : Determines whether List is empty

 Input : List ( ListType)

 Preconditions : List has been created.

 Output : true/false
List ADT - Operations
• isFull(List) : Returns Boolean value
 Function : Determines whether List is full.

 Input : List (ListType)

 Preconditions : List has been created.

 Output : true/false

 Post conditions : FullList() = ( List is full ).


Any Questions/Comments?

Thank You!

20
Why ADT when List can Work?
• Abstract Data Types invites us to think about
the data structures with the operations of
your choice.

• No need to stick to stack or queue all the


time!

21

You might also like