data structures lecture 1...1 data structures lecture 1 ali sajjad haris teaching assistant ,...

29
1 Data Structures Lecture 1 1 Ali Sajjad HARIS Teaching Assistant , Faculty of Computer Science, Kabul Education University Email: [email protected] Slides Preparation Credit to Mr. Omerkhel

Upload: others

Post on 02-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

1

Data StructuresLecture 1

1

Ali Sajjad HARIS

Teaching Assistant ,Faculty of Computer Science,Kabul Education UniversityEmail: [email protected] Preparation Credit to Mr. Omerkhel

Page 2: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

2

Today’s Lecture

n Motivationn Course Detailsn Course objectivesn Course goals or outcomesn Course outlinesn Basic termsn Data structure definitions

Page 3: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

3

Why?Why are you

studying DataStructure andComputerScience ?

Page 4: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

4

Are these your Motivations?n Motivations is a feeling of enthusiasm,

interest, or commitment that makessomebody want to do something, orsomething that causes such a feeling.

n Because many people take itn Just a random choice, no particular reasonsn A required coursen I failed C++ & Java before; n Want to be taught by a tough instructor n More …

Page 5: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

5

I believe your REAL motivation is ...

I take it because Iam interested

Page 6: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

6

Course Details

n Course Title: Data Structures

n Credit Hours: 04

n Course Prerequisites C++ and Java

Page 7: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

7

Course Objectives: n The course is designed to teach students

structures and schemes, which allow them to writeprograms to efficiently manipulate, store, andretrieve data.

n To extend and deepen the student's knowledgeand understanding of algorithms and datastructures and the associated design andanalysis techniques

Page 8: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

8

Course Objectives

n It focuses the student's attention on the designof program structures that are correct, efficientin both time and space utilization, and definedin terms of appropriate abstractions.

Page 9: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

9

Course Goalsn Upon completion of this course, a successful

student will be able to:

q Describe the strengths and limitations of linear datastructures, trees, graphs, and hash tables

q Select appropriate data structures for a specifiedproblem

q Compare and contrast the basic data structuresused in Computer Science: lists, stacks, queues,trees and graphs

Page 10: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

10

Course Goals

q Recognize when and how to use the following datastructures: arrays, linked lists, stacks, queues andbinary trees.

q Identify and implement the basic operations formanipulating each type of data structure

q Perform sequential searching, binary searching

Page 11: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

11

Course Goals

q Apply various sorting algorithms including bubble,insertion and selection sort.

q Understand recursion and be able to give examples ofits use

Page 12: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

12

Course Outline - In Introduction to data structuresn Linear and non-linear data structuresn Arraysn Algorithms and flowchartsn sorting algorithms including bubble, insertion and

selection sort.n Linear search and binary searchn Stack; Implementation of stack using arraysn Applications of a stackn Infix to postfix conversionn Evaluation of postfix expressions

Page 13: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

13

Course Outline - IIn Queues; Implementation of queues using arraysn Circular Queues; Priority Queues;n List data structuren Singly linked listn Doubly linked listn Analysis of List data structuresn Circular linked listn Trees; Tree traversals; Binary search trees and

implementationn Graph

Page 14: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

14

Recommended Books

Textbooks:n Data Structures & Algorithms in Java

by Robert Laforen Mark A. Weiss, Data Structures andAlgorithm Analysis in C, 2nd Edition,Pearson Education Inc. India, 1997 .

Page 15: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

15

Marks Distribution of Coursen Assignments ……….……… 20%

n Mid term .………….….. 20%

n Final .……………… 60%

Page 16: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

16

Basic Termsn DataØ Data is a plural word and its singular form is ‘Datum’ is a

Latin word meaning “something given”.

Ø Numbers, characters, symbols, images etc., which canbe processed by computer

Ø Data is a collection of facts made up of text, numbersand dates:

Ali 35000 7/18/86Any raw collection of facts and figures which is not meaningful to

the user is called data.

Page 17: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

17

Basic Terms

Ø Information is the meaning given to data in the way it isinterpreted,

Ø e.g. Mr. Ali is a sales person whose annual salary is $35,000and whose hire date is July 18, 1986

Ø Processed or meaningful form of data is called information,like "Farhan, 40" are two data items, but "Farhan is now 40years old" is an information

Page 18: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

18

Organizing Datan Any organization for a collection of records that can besearched, processed in any order, or modified.

n Nicklaus Wirth DefinitionProgram = Algorithms + Data Structures

n The choice of data structure and algorithm canmake the difference between a program running ina few seconds or many days

Page 19: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

19

Data Structuren Is the organized collection of data

n programs have to follow certain rules to accessand process the structured data

n Data structure = Organized data + Allowable operations

n this is an extension of the concept of data type.We defined a data type as:

Page 20: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

20

n Data Type = Permitted Data Values + Operations

n Simple data type can be used to built new scalardata types, for example enumerated type in C.

n Similarly there are standard data structures whichare often used in their own right and can form thebasis for complex data structures,

q like Arrays, are basic building block for more complexdata structures

Page 21: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

21

Efficiencyn A solution is said to be efficient if it solves the

problem within its resource constraints.q Spaceq Time

n The cost of a solution is the amount ofresources that the solution consumes.

Page 22: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

22

Data Structure

q refers to the actual implementation of the data typeand offers a way of storing data in an efficientmanner.

q Any data structure is designed to organize data tosuit a specific purpose so that it can be accessedand worked in appropriate ways both effectively andefficiently

22

Page 23: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

23

Data Structuren Is a particular way of storing and organizing

data in a computer so that it can be usedefficiently

n Different kinds of data structures are suited todifferent kinds of applications and some are highlyspecialized to specific tasks

q e.g. B-trees are particularly well-suited forimplementation of databases, while compilerimplementations usually use hash tables to look upidentifiers

Page 24: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

24

Data Structure

n provide a means to manage huge amountsof data efficiently, such as large databasesand internet indexing services

n Usually, efficient data structures are a keyto designing efficient algorithms.

Page 25: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

25

Types of Data Structuren Type of Data Structures according to the

presentation of data (i.e. How data is presented)1. Linear Data Structure

1. Sequential Data Structures1. Array2. Queue3. Stack

2. Pointer Data Structure (Linked List)

2. Non Linear Data Structure1. Tree2. Graphs

Page 26: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

26

Common operation for all Data Structure are.q Insert ( Insert new item/element into a

data structure)

q Delete (Remove an item from DataStructure)

q Sort (Use to arrange all items in eitherascending or descending order)

26

Page 27: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

27

Common operation for all Data Structure are.

q Search (Use to locate an element/itemof a data structure)

q Merge (Use to combine the elements ofmore than one similarly data structure

q Traversing (Scanning or visit of eachelement for view etc)

Page 28: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

28

Summary

n Motivationn Course Detailsn Course objectivesn Course goals or outcomesn Course outlinesn Basic termsn Data structure definitions

Page 29: Data Structures Lecture 1...1 Data Structures Lecture 1 Ali Sajjad HARIS Teaching Assistant , Faculty of ComputerScience, Kabul Education University Email: Ali.chum7@gmail.com Slides

29

Thanks