26
Data Structure : Unit 1 By AMAR JEET RAWAT HoD, Dept. of IT Alpine Institute of Management & Technology

Data structure unitfirst part1

Embed Size (px)

Citation preview

Page 1: Data structure unitfirst part1

Data Structure : Unit 1

By AMAR JEET RAWATHoD, Dept. of IT

Alpine Institute of Management & Technology

Page 2: Data structure unitfirst part1

Basic Terminology

• Datum : Singular form of data , refers to single unit of values. e.i. 1,4,A,z,& etc.

• Data : Data are simply values or set of values. It’s a collection of data items. i.e. 45741,BX6T

• Information : Processed data which provide some meaning. e.i. Roll no : 45741.

• Knowledge : Collection of related information.– Your name is Alok . Your roll no is 45741.

Page 3: Data structure unitfirst part1

Basic Terminology

• Entity : Some object that has certain attributes or properties which may be assigned values.

• Entity Set: Entities having similar attributes.– All employees from an entity set.

Attribute Name Age Gender ID Number

Values Alok 23 Male 2401-12-A6

Page 4: Data structure unitfirst part1

Basic Terminology

Data are organizes into the hierarchy of fields, records and files which reflect some relationship between attributes, entities and entity set.

• Field : is a single elementary unit of information representing an attribute of an entity.

• Record : is the collection of field values of given entity.

• File: is collection of records of entities in a set of entity.

Page 5: Data structure unitfirst part1

Example

Roll No Name Class Age Contact

1120100 Alok Kumar BCA-2 20 963852741

1120101 Tarun BCA-2 21 789541621

1120102 Pooja B.Sc(IT)-4 20 745241624

Attributes

field

Record

File

Page 6: Data structure unitfirst part1

Records Types

• Fixed Length Records: All the records contain the same data items with the same amount of space assigned to each data item.

• Variable Length Records: These records contain data items with different amount of space assigned to each data item.

Page 7: Data structure unitfirst part1

Study of Data Structure includes

• Logical or mathematical description of the structure

• Implementation of the structure on a computer

• Quantitative analysis of the structure to determine the amount of memory(space) needed to store the structure and time required (time) to process the structure.

Page 8: Data structure unitfirst part1

Data Structure

• Logical or mathematical model of a particular organization of data is called data structure.

Page 9: Data structure unitfirst part1

9

The Need for Data Structures

Data structures organize data more efficient programs.

More powerful computers more complex applications.

More complex applications demand more calculations.

Complex computing tasks are unlike our everyday experience.

Page 10: Data structure unitfirst part1

10

Efficiency

A solution is said to be efficient if it solves the problem within its resource constraints.– Space– Time

• The cost of a solution is the amount of resources that the solution consumes.

Page 11: Data structure unitfirst part1

11

Data Structure Philosophy

Each data structure has costs and benefits.Rarely is one data structure better than

another in all situations.A data structure requires:

– space for each data item it stores,– time to perform each basic operation,– programming effort.

Page 12: Data structure unitfirst part1

12

Data Structure Philosophy (cont)

Each problem has constraints on available space and time.

Only after a careful analysis of problem characteristics can we know the best data structure for the task.

Bank example:– Start account: a few minutes– Transactions: a few seconds– Close account: overnight

Page 13: Data structure unitfirst part1

13

Logical vs. Physical Form

Data items have both a logical and a physical form.

Logical form: definition of the data item within an ADT.– Ex: Integers in mathematical sense: +, -

Physical form: implementation of the data item within a data structure.– Ex: 16/32 bit integers, overflow.

Page 14: Data structure unitfirst part1

Data Structure Types

Page 15: Data structure unitfirst part1

Linear Data Structure

• A data structure is said to be linear if its elements form a sequence or a linear list.– Array– Link List– Stack– Queue

Page 16: Data structure unitfirst part1

Array

• Collection of similar finite elements.– Collection of integers– Collection of images.

• Simplest type of data structure.• Types of Arrays

– Singular or simple Array.– Multidimensional Array

Page 17: Data structure unitfirst part1
Page 18: Data structure unitfirst part1

Data Structure Operations

• Traversal : Visit every part of the data structure• Search : Traversal through the data structure for a given

element• Insertion : Adding new elements to the data structure• Deletion : Removing an element from the data structure.• Sorting : Rearranging the elements in some type of order(e.g

Increasing or Decreasing)• Merging : Combining two similar data structures into one

Page 19: Data structure unitfirst part1

Stack

• Stack is an ordered list of objects.• Stack is based on LIFO (Last in first out)

Page 20: Data structure unitfirst part1

Queue

• It is an ordered list of elements n , such that n>0 in which all deletions are made at one end called the front end and all insertions at the other end called the rear end .

• Theoperational semantic of queue is FIFO i.e. first in first out

Page 21: Data structure unitfirst part1

Example

Page 22: Data structure unitfirst part1

Link List

• Linked List is a linear data structure which consists of group of nodes in a sequence which is divided in two parts.

• Each node consists of its own data and the address of the next node and forms a chain. Linked Lists are used to create trees and graphs.

Page 23: Data structure unitfirst part1

Non-Linear Data Structure

• The Data structure is said to be Non-Linear Data Structures if it's elements do not form a sequence or a linear series but form a hierarchical format.– Graphs– Tree

Page 24: Data structure unitfirst part1

Graph

• Graph is an ordered pair G=(V,E), where – V: set of vertices ,nodes , points– E: set of edges , arcs, lines

Page 25: Data structure unitfirst part1

Link List

Page 26: Data structure unitfirst part1