0% found this document useful (0 votes)
68 views12 pages

Abstract Data Type Is A Definition of New Type, Describes Its Data Structure Is An Implementation of ADT. Many ADT

Uploaded by

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

Abstract Data Type Is A Definition of New Type, Describes Its Data Structure Is An Implementation of ADT. Many ADT

Uploaded by

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

Data Structures

 Data structure is a representation of data and the operations


allowed on that data.
 Abstract Data Type is a definition of new type, describes its
properties and operations.
 Data Structure is an implementation of ADT. Many ADT
can be implemented as the same Data Structure.
 If I think right, array as ADT means a collection of elements
and as Data Structure, how it's stored in a memory. Stack is
ADT with push, pop operations, but can we say about stack
data structure if I mean I used stack implemented as an
array in my algorithm? And why heap isn't ADT? It can be
implemented as tree or an array.

1
Abstract Data Types
 In Object Oriented Programming data and
the operations that manipulate that data are
grouped together in classes
 Abstract Data Types (ADTs) or data
structures or collections store data and allow
various operations on the data to access and
change it

2
The Core Operations
 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
– and on and on and on…
 Many different ways to implement these items each
with associated costs and benefits

3
Lists
 Items have a position in this Collection
– Random access or not?
 Array Lists
– internal storage container is native array
 Linked Lists
public class Node
{ private Object data;
private Node next; last
} first

CS 307 Fundamentals of 4
Computer Science
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

CS 307 Fundamentals of 5
Computer Science
Operations on stacks
There are four basic operations, stack, push, pop and empty,
that we define in this chapter.

The stack operation


The stack operation creates an empty stack. The following
shows the format.

12.6
Figure 12.3 Stack operation
The push operation
The push operation inserts an item at the top of the stack.
The following shows the format.

12.7
Figure 12.4 Push operation
The pop operation
The pop operation deletes the item at the top of the stack.
The following shows the format.

12.8
Figure 12.5 Pop operation
Stack ADT
We define a stack as an ADT as shown below:

12.9
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 deque
Front Back

Data1 Data2 Data3 Data4

10
Trees

 Similar to a linked list

Root

11
Other Types of Trees
 Binary Search Trees
– sorted values
 Heaps
– sorted via a different algorithm
 AVL and Red-Black Trees
– binary search trees that stay balanced
 Splay Trees
 B Trees

12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy