data structures and alogarithims
TRANSCRIPT
![Page 1: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/1.jpg)
Data Structures & Algorithms
Lecture 1: Foundational Data Structures
Ms. Joan Wakasa Murumba
![Page 2: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/2.jpg)
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.
![Page 3: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/3.jpg)
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.
![Page 4: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/4.jpg)
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.
![Page 5: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/5.jpg)
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.
![Page 6: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/6.jpg)
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
![Page 7: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/7.jpg)
Examples of Abstract Data Type
Common abstract data types (ADT) typically implemented in programming languages include:
Arrays,Lists, Queues, Stacks and Trees.
![Page 8: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/8.jpg)
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
![Page 9: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/9.jpg)
A Data Type Consists of:
A domain (a set of values) A set of operations that may be applied to
the values.
![Page 10: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/10.jpg)
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
![Page 11: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/11.jpg)
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.
![Page 12: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/12.jpg)
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.
![Page 13: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/13.jpg)
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
![Page 14: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/14.jpg)
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.
![Page 15: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/15.jpg)
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
![Page 16: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/16.jpg)
A data structure example
Name Age Address Town position
Joshua 22 P. 0 BOX
2285
NYERI student
![Page 17: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/17.jpg)
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
![Page 18: Data structures and Alogarithims](https://reader035.vdocuments.net/reader035/viewer/2022062303/555e6dedd8b42a71048b51fb/html5/thumbnails/18.jpg)
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