Data Structures and Algorithms Lecture (1) - University of Science and Technology - PDF

Summary

This document is a lecture on data structures and algorithms, provided by the University of Science and Technology. It covers an introduction to data structures and algorithms, including basic definitions, data types, and concepts including searching, sorting, etc. It highlights the importance of organizing data effectively.

Full Transcript

**University of Science and Technology** **Faculty of Computer Science and Information Technology** **Data Structures and Algorithms** **Semester 6** **Course Description** This course will focus on data structures and algorithms for manipulating them. Data structures for storing information in...

**University of Science and Technology** **Faculty of Computer Science and Information Technology** **Data Structures and Algorithms** **Semester 6** **Course Description** This course will focus on data structures and algorithms for manipulating them. Data structures for storing information in tables, lists, stacks, queues, trees and graphs will be covered. Basic algorithms for creating, manipulating and using these structures will also be discussed. Different types of searching and sorting techniques will also be introduced and will be compared. Students will carry out a number of programming assignments, which will emphasize various aspects of data organization and manipulation process. **Course Goals** 1\. To ensure that students are familiar with ways to implement elementary data structures and their associated algorithms. 2\. To introduce students to the implementation of more complex data structures and their associated algorithms. 3\. To acquaint students with advanced sorting techniques. 4\. To teach students how to determine the time complexity of algorithms. 5\. To introduce students to algorithm design techniques. **Course Learning Outcomes (CLOs)** Upon successful completion of this course, students should be able to: 1\. Understand the implementation of lists, stacks, queues, search trees, heaps, union-find ADT, and graphs and be able to use these data structures in programs they design 2\. Prove basic properties of trees and graphs 3\. Perform breadth-first search and depth-first search on directed as well as undirected graphs 4\. Use advanced sorting techniques (heapsort, mergesort, quicksort) 5\. Determine the running time of an algorithm in terms of asymptotic notation 6\. Solve recurrence relations representing the running time of an algorithm designed using a divide-and- conquer strategy **Course Content** Topics to be covered are: [A. Basic data structures] 1\. List 2\. Stack 3\. Queue [B. Analysis of algorithms] 1\. Time complexity 2\. Upper and lower bounds [C. Sorting] 1\. Insertion sort 2\. Merge sort 3\. Quick sort 4\. Heap sort 5\. Performance bounds [D. Dictionary] 1\. Binary search trees 2\. AVL tree 3\. B tree [E. Graphs] 1\. Definition, representation, and modeling tool 2\. Breath-first search 3\. Depth-first search 4\. Directed graph and topological s [F. Hashing] 1\. Hash tables and functions 2\. Collision resolution **Laboratory Exercises** This course requires a weekly three-hour laboratory component. Topics to be covered in the laboratory sessions should include: Basic data structures -- review exercises in basic data structures. Time complexity -- exercises in estimating time complexity of algorithms by measurement. Performance bounds -- exercises in estimating performance bounds of algorithms by measurement. Sorting I -- exercises in the use and analyzing of sorting algorithms including merge sort and quick sort. Sorting II -- additional exercises in the use and analyzing of sorting algorithms including heap sort. Dictionary I -- exercises in the use of dictionary as an abstract data type including binary search tree and AVL tree. Dictionary II -- additional exercises in the use of dictionary including B tree. Breath-first search -- exercises in the use of breath-first search algorithm. Depth-first search -- exercises in the use of depth-first search Depth-first search -- exercises in the use of depth-first search algorithm. Topological sort -- exercises in the use of topological sort algorithm Undergraduate Information Technology and Computer Science Programs Page 36 Hashing I -- exercises in the implementation of hash tables and functions. Hashing II -- exercises in the implementation of collision resolution **Textbook:** Debdutta Pal, Suman Halder. Data structures and Algorithms with C, Copyright © 2018, Alpha Science International LTD. **University of Science and Technology** **Faculty of Computer Science and Information Technology** **Data Structures and Algorithms** **Lecture (1): Introduction to Data Structure** **Prof. Noureldien A. Noureldien** **1.1 Introduction** Data Structures in Computer Science is one of the core fields that belongs to its foundations, with the design, analysis, and implementation of algorithms for the efficient solutions of the problem concerned. The data structure is one of the subjects that intrinsically connected with the design and implementations of efficient algorithms. **[The subject Data Structure deals with the study of methods, techniques, and tools to organize or structure data in computer memory]**. Now before defining Data Structure, we should know what is data? And what is the difference between data and information? **1.2 Data and Information** Data is a plural of datum, which is originally a Latin noun meaning ―something given. The Oxford dictionary meaning of data is: i\) Facts or statistics used for reference or analysis. ii\) The quantities, characters or symbols operated by a computer. For our purpose, the second meaning is more important. Therefore, we can say that: **[The data represent quantities, characters, or symbols on which operations are performed by a computer,]** stored and recorded on either magnetic, optical, or mechanical recording media, and transmitted in the form of digital electrical signals. **[Definition: Data is the basic entity or fact that is used in a calculation or manipulation process.]** Data is commonly processed by some stages. Unprocessed data or raw data is a collection of numbers, characters, that may be considered as an input of a stage and processed data is the output of the stage. There are two types of data, numerical and alphanumerical data. Data may be a single value or a set of values and it is to be organized in a particular fashion. This organization or structuring of data will have a profound impact on the efficiency of the program. **1.3 Data Structure** **[Definition: Data Structure is defined as a mathematical or logical model of organizing the data items into computer memory in such a way that they can be used efficiently]**. Data Structure can be used for the following purpose: i\) Organizing the data -- How data items are organized in the main memory? ii\) Accessing methods -- How data items can be accessed? iii) Specifying the degree of associativity -- How data items are interrelated? iv\) Processing alternatives for data -- How many different ways are there in which these data items can be processed? **[A program is a set of instructions, which involve a computer performing some kind of computation or algorithm]**. Data Structure affects the design of both structural and functional aspects of a program. To implement a program of an algorithm, we should select an appropriate data structure for that algorithm. Therefore, the programs are inherited by an algorithm and its associated data structure. **Algorithm + Data Structure = Program** **1.4 Classifications of Data Structure** Data Structure can be classified into two categories: i\) Primitive data structure ii\) Non-Primitive data structure **1.4.1 Primitive Data Structure** The primitive data structures are defined that can be manipulated or operated by the machine instruction. There are numerous types of data structures, generally built upon simpler primitive data types, called Primitive data structures, which are represented in computer memory. ***Example:*** Integer, floating point, characters, pointer, boolean, etc. are some of the different primitive data structure. In C language, the different primitive data structures are defined using the data type such as int, char, float, double etc. **1.4.2 Non-primitive Data Structure** The non-primitive data structures are a data structure that cannot be manipulated or operated directly by the machine instructions. These are more sophisticated data structures. Non-primitive data structures are derived from the primitive data structure. These are a group of homogeneous or heterogeneous data items. ***Example:*** Arrays, structure, stack, queues, linked lists etc. The Non-primitive data structures are classified into two categories: i\) Linear data structure ii\) Non-linear data structure **1.5 Linear Data Structures** The data structure is linear if every data item is related to its previous and next data items (e.g., array, linked list). In the linear data structure, data items are arranged in memory in a linear sequence and data items are accessed linearly. The traversing of the linear data structure is exactly once. Linear data structures are two types: 1. Sequential 2. Linked Sequential Data Structures are based on arrays where objects are stored in a sequence of consecutive memory locations. ***Example:*** Arrays, Stacks, Queues Linked Data Structure is a data structure, which consists of a set of nodes linked together and organized with links. ***Example:*** Linked Lists, Linked Stacks, Linked Queues **1.6 Non-linear Data Structures** A data structure is non-linear if every data item attaches to many other data items in specific ways to reflect relationships (e.g., tree). In non-linear data structures, the data elements are not in sequence, i.e., insertion and deletion are not possible in a linear manner. The traversing of the non-linear data. structure is always more than one. ***Example:*** Graphs, Trees **Static Data Structure** The static data structure is a kind of data structure, in which once memory space is allocated it cannot extend, i.e. the memory allocation for the data structure takes place at compile-time that cannot be changed afterwards. ***Example:*** Array **Dynamic Data Structure** Dynamic Data Structure is another kind of data structure, which can be extended or shrink during the execution, i.e., the memory allocation as well as memory de-allocation for the data structure takes place at run-time and allocates memory as required amount at any time. ***Example:*** linked list, stack, queue, tree **1.7 Applications of Data Structure** Different Data Structure is used in real life, such as the representation of an image in the form of a bitmap, implement printer spooler so that jobs can be printed in the order of their arrival, store information about the directories and files in a system, etc. Data Structure is used in various fields of Computer Science, such as: Compiler Design Operating System Database Management System Statistical Analysis Package Numerical Analysis Graphics Artificial Intelligence Simulation Different kinds of data structures are suitable for different kinds of applications. Some data structures are highly specialized for specific tasks. For example, databases use B-tree indexes for small percentages of data retrieval, and compilers and databases use dynamic hash tables as lookup tables, operating systems use queues for process management, I/O request handling. **1.8 Abstract Data Type** A data type refers to the type of data that variables hold. Thus, integer, real, characters are referred to as primitive data types. **Data Object** represents an object having a data. The study of classes of objects whose logical behavior is defined by a set of values and a set of operations. ***Definition:*** An Abstract Data Type (ADT) describes the data objects, which constitute the data structure and the fundamental operations supported on them. A data structure is the **design representation** of an ADT. The same ADT may be represented by several data structures. There are many data structures corresponding to the ADT ―set‖. **1.9 Operations Perform on Data Structure** Data are processed by means of certain operations, which appear in the data structure. The particular data structure is chosen largely depends on the frequency of the operation that needs to be performed on the data structure. Different kinds of operations are to be performed on data structures. ![](media/image2.png)

Use Quizgecko on...
Browser
Browser