data structures and alogarithims
TRANSCRIPT
Data Structures & Algorithms
Lecture 1: Foundational Data Structures
Ms. Joan Wakasa Murumba
Definitions A data type simply refers to a defined kind of
data, that is, a set of possible values & basic operations on those values.
When applied in programming languages, a data type defines a set of values & the allowable operations on those values.
Types of data in programming languages include integers, floating point numbers or characters, tuples, records, ADT, etc.
Definitions
Integers: Numbers that do not have decimal places
Floating point number: A real number (that is, a number that can contain a fractional part). The following are floating-point numbers:
3.0 , -111.5 , ½ , 3E-5 etc.
A Tuple A tuple is an ordered set of values. The separator for each value is often a comma
(depending on the rules of the particular language).
Common uses for the tuple as a data type are (1) for passing a string of parameters from one program to another, and (2) representing a set of value attributes in a relational database.
A Tuple An example of a tuple that emphasizes the
different data types that may exist within a tuple data type: 17,*,2.49,Seven
The above example is sometimes referred to as a 4-tuple, since it contains four values.
ADT
An Abstract Data type is defined as a mathematical model of the data objects that make up a data type as well as the functions that operate on these objects.
A set of data values and associated operations that are precisely specified independent of any particular implementation
A data type is abstract in the sense that it is independent of various concrete implementations
Examples of Abstract Data Type
Common abstract data types (ADT) typically implemented in programming languages include:
Arrays,Lists, Queues, Stacks and Trees.
Data Types
Data types are important in computer programmes because they classify data so that a translator can reserve appropriate memory storage to hold all possible values, e.g. integers, real numbers, characters, strings, and Boolean values
A Data Type Consists of:
A domain (a set of values) A set of operations that may be applied to
the values.
Data Type Classification Simple Data Type: This is where some data
items may be used singly The simple data types are classified as
follows: a. Characterb. Numeric integerc. Numeric reald. Boolean (logical).
Data Structures: May be combined together and arranged to form other data items
Data Structure
A data structure is the implementation of an abstract data type in a particular programming language.
Data structures can also be referred to as “data aggregate”.
A data structure is an organization of information, usually in memory, for better algorithm efficiency, such as queue, stack, list, and tree, or conceptual unity, such as the name and address of a person.
Data Structure
Data structures are collections of data values, the relationships among them and functions or operations that can be applied to that data.
Classification of Data StructuresData structures are broadly divided into two: Linear Data Structures Non-Linear Data Structures.
Linear Data Structures Linear data structures are data structures in
which individual data elements are stored and accessed linearly in the computer memory.
Examples include: lists, stacks, queues and arrays
Non-Linear Data Structures A non-linear data structure, as the name
implies, is a data structure in which the data items are not stored linearly in the computer memory, but data items can be processed using some techniques or rules.
Typical non-linear data structures are Trees.
Purposes of Data Structures For implementation of databases, e.g.,
trees Provide a means of handling large
amounts of data efficiently, e.g. Large database, indexing services, etc.
Efficient data structures are a key to designing efficient algorithms
A data structure example
Name Age Address Town position
Joshua 22 P. 0 BOX
2285
NYERI student
From the above data structure, data types can be
Data item Data type
Name Text, string
Age Integer, number,
Address Text, Alpha-numeric
Town Text
Position Text
Take Away Assignment
Q1. Computer Storage and management is key in programming and computing. Find out the relationship it has with data structures and
algorithms. Use suitable illustrations
Q2. Discuss in details A Stack data structure, giving its components, functions, operations, strengths and weaknesses and applications
Assignment Due on 13th July, 2014