Presentation is loading. Please wait.

Presentation is loading. Please wait.

ET 2006 : Data Structures & Algorithms

Similar presentations


Presentation on theme: "ET 2006 : Data Structures & Algorithms"— Presentation transcript:

1 ET 2006 : Data Structures & Algorithms
Lecture 1: Introduction Malaka J Walpola

2 Outline - I Class Details Discussion & Survey
Learning Outcomes & Course Outline Assessments Class Rules & Expectations Discussion & Survey Introduction to Algorithms What is an algorithm? Flowcharts Pseudocode

3 Outline - II Basic Data Structures
Introduction to Data Structures and Abstract Data Types Basic Data Structures & Operations on Them Arrays Records Lists Stack Queue Dictionary

4 Class Details

5 ET 2006: Data Structures & Algorithms
Credits: 4 (GPA) Pre-requisites : ET 1001-Introduction to ICT Course Objective: To provide knowledge of basic data structures and algorithmic design paradigms used to manipulate data structures for common functions in software programming

6 CS 2022 : Data Structures & Algorithms
Lecturers: Malaka J. Walpola Contact information Phone:

7 CS 2022 : Data Structures & Algorithms
Hours: Lectures – (45 Hrs: 4.5 to 5 Hrs/week) Monday 1.00 – 5.30/6.00 Labs/Assignments (30 Hrs) Reading the Books, Self Study & Homework (will depend on individuals)

8 Learning Outcomes On the completion of this module, the student will be able to: LO1: Select and implement common data structures for a given situation [12 Hrs] LO2: Implement appropriate algorithms to manipulate data structures [12 Hrs] LO3: Analyze the performance and complexity of basic algorithms [9 Hrs] LO4: Use data structures and synthesize efficient algorithms to solve real life problems [12 Hrs]

9 Course Outline - I Select and implement common data structures for a given situation [12] Basic data structures and their properties: linear (arrays, linked-lists, stacks, queues) Non-linear (trees and graphs) Operations on data structures: insertion, deletion, sorting, searching, traversing Heap abstract data type and heap operations; Dictionaries and hash tables

10 Course Outline - II Implement appropriate algorithms to manipulate data structures [12] Characteristics of an algorithm. Algorithm creation techniques and matrices of algorithms: Recursion: tail and non-tail, direct and indirect; Algorithms for stacks and queues: first in first out (FIFO) and last in first out(LIFO) Sorting algorithms: Internal and external sorting Simple Sorting Algorithms (Bubble, selection, insertion) Advanced Sorting Algorithms (Merge, Quick, Bucket, Shell, Heap) Searching Algorithms: - linear (sequential) search and binary search (BST)

11 Course Outline - III Analyze the performance and complexity of basic algorithms [9] Factors considered in analyzing algorithms, and growth of functions Asymptotic notations Time complexity and asymptotic complexity analysis Efficiency of different searching and sorting algorithms

12 Course Outline - IV Use data structures and synthesize efficient algorithms to solve real life problems [12] Solving real-life recursion problems: factorials, Fibonacci numbers, Towers of Hanoi. Divide and conquer techniques; Tree and graph traversal techniques (Death-first and Breadth first), Handling cycles and vertices, Tree traversal pre-order, in-order and post-order Graph traversal algorithms: - Bellman-Ford shortest-path and Dijkstra's shortest-path algorithms

13 Method of Assessment Exam – 70% Assignments – 30% 3 hour Closed book
Answer all Will have short answer/multiple choice questions Assignments – 30% Assignment 1: On LO1 & LO2 - 10% Assignment 2: On LO3 - 10% Assignment 3: On LO4 - 10%

14 Recommended Text Books
Adam Drozdek, Data Structures and algorithms in Java, , 3rd Ed., Cengage Learning Asia, 2008 Michael Goodrich and Roberto Tamassia, Data Structures and Algorithms in Java; 5th Ed., Wiley, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein, Introduction to Algorithms, 3rd Ed. Cambridge, MA, MIT Press, 2009

15 Class Rules Be Respectful and Responsible
No talking among yourselves No cell phones/communication devices Be Organized and Follow Directions Be Prepared If you miss a lecture, it is your responsibility to makeup Assignment Must Be Your Own Work It will help you understand the material Cite all references We may be using plagiarism detection tools

16 Expectations All the students are required to read the assigned sections of the book Please keep up with the reading In-class activities and homework will assume that you have done this. All the students are expected to actively participate in the in-class activities If you have difficulties in homework, bring them to class and ask during the breaks

17 Questions or Concerns?

18 Discussion & Survey

19 Introduction to Algorithms

20 Learning Outcomes After successfully studying contents covered in this lecture, students should be able to, explain the idea of a computational task explain what an algorithm is and express an algorithm using pseudo code or flowcharts explain the concept of an abstract data type write pseudo codes for operations of linked list, stack, queue, and dictionary data structures implement linked list, stack, queue, and dictionary data structures and use them

21 Introduction Why Do We Study Data Structures and Algorithms?
To make understanding and solving problems simple To solve problems in the BEST way

22 Sample Problems Searching the Web for the IESL College of Engineering
Calculating the Fourier Transform of a Signal Designing a PCB Layout for a Circuit Sorting a List of Names Calculating Best Path from Colombo to Anuradhapura

23 Sample Problems Searching the Web for the IESL College of Engineering
Calculating Best Path from Colombo to Anuradhapura Calculating the Fourier Transform of a Signal Designing a PCB Layout for a Circuit Sorting a List of Names

24 Computational Task A computational task is not just a “single” task such as “Is prime ?” “What is 37487*2371 ?” A computational task is a whole family of “similar” tasks with varying INPUT, such as “Given a whole number A, is A prime?” “Given 2 numbers x and y, what is x times y?”

25 Algorithm What is an Algorithm?
Well defined procedure Takes some inputs Produce some outputs An algorithm is a step-by-step method of solving a computational task Recipe

26 Specifying Algorithms
Listing the Steps Flowcharts Pseudocode Program Listing Class Activity: Specify an algorithm to add all the numbers in a list by listing the steps

27 Flowcharts A diagram that show the “flow of control” of an algorithm/a program Flowchart symbols

28 Flowchart Symbols Terminals Input/output Data
Represents the stat or end of the process Represented by rounded rectangles Input/output Data Represented by parallelograms Indicate an input or output operation Start End Read input x Output Max Value

29 Flowchart Symbols Stored Data Processing Represented by rectangles
Indicates a process such as a mathematical computation or variable assignment Processing Stored data value x = x + 1 y = y + 5 Increment x add 5 to y

30 Flowchart Symbols Decision Represented by diamond shape
Indicates different paths of execution/choices the program can take Is end of the array? Yes No More employees ? Yes No

31 Flowcharts Example Class Activity
Draw the flowchart of an algorithm to add all the numbers in a list of numbers Class Activity Draw the flowchart of an algorithm to find and print the largest number in a list of numbers

32 Pseudocode Human readable version of program code
An intermediate level between program code and listing of steps Each step should be simple and precise Can use predefined procedures Example: Express an algorithm to add all the numbers in a list of numbers using pseudocode Class Activity: Express an algorithm to find and print the largest number in a list of numbers using pseudocode

33 Basic Data Structures

34 Introduction What is a data structure? Examples
A way to store and organize data Operations performed on them Facilitates creation, access and modification Examples Records, arrays, link lists, stacks, queues, trees, graphs Discuss sample applications (priority queue, etc.) and provide an overview of how we can modify the basic data structures to suite our requirements

35 Introduction What is a ADT? Importance of ADT
Data structure specification A set of operations on the structure Implementation independent Importance of ADT Data abstraction Allows us to focus on important aspects of data Encapsulation or information hiding

36 Introduction ADT specification The set of operations on the structure
Name Input/Pre condition Process Output/Post condition Types of operations Constructors Access procedures Manipulation procedures

37 Arrays A finite set of homogeneous elements
Stored in continuous memory locations Calculating address of elements 2D arrays Row major vs column major ordering

38 Arrays Types Strings as character arrays
Multidimensional arrays Arrays that can grow Dynamic arrays Strings as character arrays In c: null terminated character arrays In java: string has a length Which type of array to use will depend on Requirements Programming language construct Arrays, ArrayList, and Vector

39 Records A simple data structure Example Stores heterogeneous data
Also called tuple or struct Example A record to store student name, index no, and currentGPA Index no: integer name: string CurrentGPA: floating point

40 ADT - Linked List A set of linked elements Consists of
Nodes (Elements) An attribute called head which specifies the first node of the linked list Node composition Data fields Pointers

41 Linked List - Specification
LIST-SEARCH(L,k) Finds the first node with the key k in the list L Returns NIL if no element is found LIST-INSERT(L,x) Inserts the node x into the front of the list L LIST-DELETE(L,x) Deletes the node x from the list L if exists

42 Linked List - Types Linked list Doubly linked list
Circular linked list

43 Linked List - Specification
Extensions LIST-INSERT(L,x,i) Inserts the node x into the ith location of the list L Modifications for double linked lists LIST-INSERT-BEFORE (L,x,i) Inserts the node x before the ith element of the list L LIST-INSERT-AFTER(L,x,i) Inserts the node x after the ith element of the list L

44 Linked List - Implementation
C Using pointers Allocate & free memory dynamically C++/Java/Python Classes Create objects and link them Comparison between lists in Python and the linked lists

45 ADT - Queue A first in first out (FIFO) data structure
Similar to the queue you see in day to day life Insert -> enqueue Insert element to the end of the queue Delete -> dequeue Remove the first element from the queue Priority queues

46 ADT - Stack A last in first out (LIFO) data structure
Insert -> push Insert element to the top of the stack Delete -> pop Remove the element from top of the stack

47 ADT - Dictionary Represents a set Operations Search (S,k)
Insert (S,x) – add element to the dictionary Delete (S,x) Minimum (S) Maximum (S) Successor (S,x) Predecessor (S,x)

48 Self Studying

49 Homework Write pseudo codes for the operations of a (single) linked list Write pseudo codes for the operations of a double linked list How can you implement a stack and a queue using a linked list? Write the pseudo codes for the operations Will there be any advantages if you use a double linked list?

50 Homework How can you implement a dictionary using a linked list?
What type of a linked list (single linked list, double linked list or a circular linked list) would be the best option? Why? What will be the answer to the above question if we remove the “Predecessor ” operation? Write the pseudo codes for the operations

51 References [1] T.H. Cormen, C.E. Leiserson, R.L. Rivest and C. Stein, Introduction to Algorithms, 3rd Ed. Cambridge, MA, MIT Press, [2] S. Baase and Allen Van Gelder, Computer Algorithms: Introduction to Design and Analysis, 3rd Ed. Delhi, India, Pearson Education, 2000.


Download ppt "ET 2006 : Data Structures & Algorithms"

Similar presentations


Ads by Google