* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Data Structures - Data structure cs322
Data Protection Act, 2012 wikipedia , lookup
Data center wikipedia , lookup
Operational transformation wikipedia , lookup
Database model wikipedia , lookup
Forecasting wikipedia , lookup
Data analysis wikipedia , lookup
Information privacy law wikipedia , lookup
Data vault modeling wikipedia , lookup
Data Structures
1- Course Syllabus.
2- Introduction about Data Structures.
First: what is data structures?
Data Structures
A
data
structure
is
an
arrangement of data in a
computer’s
memory
(or
sometimes on a disk).
Examples of data structures
include linked lists, stacks,
binary trees, and hash tables,
among others.
Also, it is a object oriented
programming
Data Structures
Data Types
Hashes
Linear data
Trees
Primitive
Arrays
Binary trees
Composite
Lists
B-trees
Abstract
data type
Graphs
Heap Trees
AVL Trees
Multi way
trees
Space Trees
Application specific trees
Are Data structures important ???
Data structures are very useful
in the construction of a program
or a system, especially if the
program has to manage huge
amounts of data efficiently, such
as large databases, airline
system , students enrollment
system and others.
It
explains
the
way
of
organizing data or elements in a
computer memory
Algorithms
Algorithms manipulate the data in
these structures in various ways,
such as inserting a new data item,
searching for a particular item, or
sorting the items.
You can think of an algorithm as a
recipe: a list of detailed
instructions for carrying out an
activity.
Abstract Data Type (ADT)
Before a program is written we should have a fairy
good idea of how to accomplish the task being
implemented by this program.
It is important to specify each task in terms of input
and output.
Behavior of the program is more important than the
gears of the mechanism accomplishing it.
Ex. If an item needed in to accomplish some tasks,
the item is specified in terms of operations
performed on it rather than in terms of its inner
structure.
ADT
These operations may act upon this item, for
example:
◦ Modifying it, searching for some details in it, or
sorting something in it.
After these operations are specified, the
implementation of the program may start.
The implementation decides which data
structure should be used to make execution
most efficient in terms of time and space.
ADT
An item specified in terms of operations is called an abstract data type.
Abstract Data Type (ADT): is a set of items and fundamental operations on
this set.
Abstraction? Anything that hides details & provides only the essentials.
◦ Examples: an integer 165 = 1.102+6.101+5.100, procedures/subprograms,
etc.
Abstract Data Types (ADTs) are Simple or structured data types whose
implementation details are hidden…
An abstract data type is not a part of a program, because a program written in
a programing language requires the definition of a data structure, not only the
operations on data structure.
An object oriented language( OOL) such as C++ has direct link to abstract
data types by implementing them as a class.
ADT: Example
ADT String1
Operations: Assume that there is a string S.
1.Procedure Append (c: char)
Requires: length(S) < 80.
Results: c is appended to the right end of S.
2. Procedure Remove (c: char)
Requires: length(S) > 0.
Results: The rightmost character of S is removed and
placed in c, S’s length decreases by 1.
3. Procedure MakeEmpty ()
Results: all characters are removed.
4. Procedure Concatenate (R: String)
Results: String R is concatenated to the right of string S,
result placed into S.
5. Procedure Reverse ()
6. Procedure Length (L: int)
7. Procedure Equal (S: String, flag: boolean)
8. Procedure GetChar (int i)
In C++ the class construct is used to
declare new data types.
In C++ operations are implemented as
function members of classes or methods.
ADT String
class String1 {
private:
char[] str;
int
size;
puplic:
String1 () {
size = -1;
str = new char[80];
}
~String1(){}
void Append (char c) {
size++;
str[size] = c;
}
Representation
Implementation
ADT
String
char Remove (){
char c = str[size];
size--;
return(c);
}
char GetChar(int i){
return(str[i]);
}
void MakeEmpty (){
size = -1;
}
int Length (){
return(size); }
void Concatenate (String1 s){
for (int i = 0; i<=s.Length(); i++) {
char c = s.GetChar(i);
Append(c);
}
}
boolean Equal (String1 s){
}
void Reverse () {
}
}
An abstract data type is not a part of a
program, because a program written in a
programing language requires the
definition of a data structure, not only the
operations on data structure.
An object oriented language( OOL) such
as C++ has direct link to abstract data
types by implementing them as a class.
Arrays