1 / 16

Data Structures

Data Structures. 1- Course Syllabus. 2- Introduction about Data Structures. First: what is data structures?. A data structure is an arrangement of data in a computer’s memory (or sometimes on a disk).

hadassah
Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. First: what is data structures?

  3. 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, binarytrees, and hash tables, among others. •  Also, it is a object oriented programming Data Structures

  4. 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  Are Data structures important ???

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

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

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

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

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

  10. 3. ProcedureMakeEmpty () 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. ProcedureGetChar (inti)

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

  12. ADT String class String1 { private: char[] str; intsize; puplic: String1 () { size = -1; str = new char[80]; } ~String1(){} void Append (char c) { size++; str[size] = c; } Representation Implementation

  13. ADT String char Remove (){ char c = str[size]; size--; return(c); } char GetChar(inti){ return(str[i]); } void MakeEmpty (){ size = -1; } intLength (){ return(size); } void Concatenate (String1 s){ for (inti = 0; i<=s.Length(); i++) { char c = s.GetChar(i); Append(c); } } boolean Equal (String1 s){ } void Reverse () { } }

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

  15. Arrays

More Related