chapter1c-introductiontodatastructure
chapter1c-introductiontodatastructure
Structure
❖ Introduction
❖ Abstract Data Types
1
What is Program?
• A computer term that can be used as both a noun and a
verb.
• A set of instructions and executable software that runs on a
computer.
• Data structures + Algorithms
2
What is data structure?
• Describes how data are arranged for access by an algorithm
• A set of rules that hold data together
• Combination of data (in several types) into a structure with
associate or defined relationship rules
• A set of algorithm that using several programming language
• Data structure = A container stores data
3
What is algorithm?
• Steps needed to perform a computation
• A finite number of steps for solving a particular problem
within a certain time frame.
• Step by step problem solving technique
• 2 types of algorithm
• Pseudo-code
• Flowchart
• Algorithm = Logic + Control
4
Why study algorithms?
• To get a clear picture and idea before writing a computer
program.
• It help programmers to write efficient code
• Execute faster
• Uses less memory
5
What is data?
• Data –values or sets of values
• Data item – single unit of values
• Collection of data are frequently organized into a hierarchy of
• Fields
• Records
• Files
• Entity – something that has certain attributes assigned values.
E.g. a = 10
E.g. b = 20
6
Data types
• A data type consists of
• a domain (= a set of values)
• a set of operations.
7
Category of data structure types in C
• Primitive Data Types (Simple data types)
• integer(int)
• floating point(float)
• character(char)
• void
8
Simple data types
• Integral
• Boolean
• bool
• Enumerated
• enum
• Character
• char, unsigned char, wchar_t
• Integer
• short, int, long, unsigned short, unsigned int, unsigned long
• Floating-point
• float, double, long double
9
Abstract data types
• Divided into 2
• Linear
• An arrangement of element in sequential format
• E.g. array, stack, queue, linked list
• Non-Linear
• One element connected to a number of element
• E.g. tree, graphs
10
Classification of Abstract data types
11
Abstract data types (Linear)
• Arrays – An arrays is a collection or list of a finite number n of
similar data elements. A subscript(or index) is used to reference the
elements of an array.
• Stack – A stack is an ordered collection of entries or items that can
only be accessed at one end. A stack is a ‘Last In First Out’ (LIFO)
data structure.
• Queue – A queue is a data structure of an ordered collection of items
or list in which insertion may be made at one end (called tail or rear of
the queue) and deletions may be made at the other end.
• Linked List – A linked list consists of structures related to one
another by pointers rather than by being members of an array.
12
Abstract data types (Non-Linear)
• Graph – A graph is an nonlinear data structure, consisting of a set of
nodes with a set of connections called links or branches (links can
either be one-way or two-way)
• Trees – Hierarchical relationship between various elements can be
represented in tree data structure. A tree consists of a finite set of
elements called nodes and a finite set of directed lines called branches
that connect these nodes.
13
Data structure operations
• Traversing – accessing and processing each record items or elements
exactly once
• Searching - search or find the location of records or elements based
on given key value or key field. Certain conditions may be applied in
searchers.
• Inserting - Adding new record element to existing list
• Deleting – Deleting or removing an existing record element from
the list
• Sorting – Arranging records in an orderly or sorted mannered such
as alphabetically, numerically or others according to some key value.
• Merging - Combining two or more sorted list into a single list
14
THE END
15