Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures 1- Course Syllabus. 2- Introduction about Data Structures.

Similar presentations


Presentation on theme: "Data Structures 1- Course Syllabus. 2- Introduction about Data Structures."— Presentation transcript:

1 Data Structures 1- Course Syllabus. 2- Introduction about Data Structures.

2 First: what is data structures?

3 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

4 Data Structures Data Types Primitive Composite Abstract data type HashesLinear data Arrays Lists Trees Binary trees B-trees Heap Trees AVL Trees Multi way trees Space Trees Application specific trees Graphs

5 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

6 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.

7 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.

8 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.

9 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.10 2 +6.10 1 +5.10 0, 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.

10 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.

11 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)

12 In C++ the class construct is used to declare new data types. In C++ operations are implemented as function members of classes or methods.

13 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

14 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 () { }

15 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.

16 Arrays


Download ppt "Data Structures 1- Course Syllabus. 2- Introduction about Data Structures."

Similar presentations


Ads by Google