0% found this document useful (0 votes)
48 views

Unit 3 - Data Structures

The document discusses various data structures including files, variables, arrays, and lists. It explains that data structures hold data to be manipulated in programs and are associated with data types like integer, float, and char. The document also covers topics like one-dimensional and two-dimensional arrays, static versus dynamic arrays, and linked lists.

Uploaded by

Bergue Chris
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Unit 3 - Data Structures

The document discusses various data structures including files, variables, arrays, and lists. It explains that data structures hold data to be manipulated in programs and are associated with data types like integer, float, and char. The document also covers topics like one-dimensional and two-dimensional arrays, static versus dynamic arrays, and linked lists.

Uploaded by

Bergue Chris
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

OUbs017212

DESIGN & ALGORITHMS


Unit 3
Data Structures
Objectives
By completing this unit you will be able to:
• Understand fundamentals of data structures
• Explain the simple file structure
• Highlight the memory aspect of data structures
• Define the different data types
• Introduce one dimensional and 2 dimensional arrays
Agenda
• Introduction to Data Structure
• Files
• Variables, Constants & Data Types
• Arrays
• Lists
Introduction to Data Structure
• Data structures actually holds the data to be manipulated within a
program.
• Data structures are associated with data types, for example integer,
floating points, characters, strings, etc.
• Data structures are also linked to the memory. Therefore good use of
data structures implies optimization of the memory, hence
optimization of the coding and running of a program.
• With the evolution of computing like today we are in the era of cloud
and big data, consequently more complex data structures are paving
out their way
Files
• Files are very common and have been used as data structures from
the very beginning of computer science.
• Generally data is stored in sequence or sequential order in a file, for
example a text file or a file with a set of commands, A file can be
declared as follows:
• VAR f: File
• f := Open(name)
Files
• Simple file management functions are open, close, delete and
rename.
• Files are stored on disks, memories or processors registries when they
are executed.
• You must be familiar with file system that is the format in which a disk
is formatted to store information. Examples of file systems File
Allocation Table (FAT16/FAT32) according to the number of bits or
Unix File System and Linux File System.
• A file is generally attached to a file type or extension like .txt, .docx,
.xls, .db, etc.
Variables
• If you declare a variable in C, you ask the operating system for a piece
of memory.
• This piece of memory you give a name and you can store something
in that piece of memory (for later use).
• There are two basic kinds of variables in C which are numeric and
character.
Numeric Variables
• Numeric variables can either be of the type integer (int) or of the type
real (float).
• Integer (int) values are whole numbers (like 10 or -10).
• Real (float) values can have a decimal point in them. (Like 1.23 or
-20.127)
Character Variables
• Character variables are letters of the alphabet, American Standard
Code for Information Interchange (ASCII) characters or numbers 0-9.
• If you declare a character variable you must always put the character
between single quotes (like so ‘A’ ). So remember a number without
single quotes is not the same as a character with single quotes.
Constants
• The difference between variables and constants is that variables can
change their value at any time but constants can never change their
value.
• The constants value is locked for the duration of the program.
• Constants can be very useful, Pi for instance is a good example to
declare as a constant.
Data Types
• Primitives vs. References
• Primitive types are the basic types of data:
• byte, short, int, long, float, double, boolean, char
• primitive variables store primitive values
• Reference types are any instantiable class as well as arrays:
• String, Scanner, Random, Die, int[], String[], etc.
• reference variables store addresses
Arrays
• The array is probably the most widely used data structure, in some
languages it is even the only one available.
• An array consists of components which are all of the same type, called
its base type; it is therefore called a homogeneous structure. The
array is a random-access structure, because all components can be
selected at random and are equally quickly accessible.
• In order to denote an individual component, the name of the entire
structure is augmented by the index selecting the component.
• This index is to be an integer between 0 and (n-1), where n is the
number of elements, the size, of the array.
Arrays
• Format: TYPE T = ARRAY n OF T0
• Examples
• TYPE Row = ARRAY 4 OF REAL
• TYPE Card = ARRAY 80 OF CHAR
• TYPE Name = ARRAY 32 OF CHAR
Lists
• Lists known as Linked Lists data structures similar to arrays.
• A linked list is a data structure consisting of a group of nodes which
together represent a sequence.
• Under the simplest form, each node is composed of data and a
reference (in other words, a link) to the next node in the sequence;
more complex variants add additional links.
Summary

• Data structures hold data to be manipulated in a computer program


• A file normally stores information in a sequential manner, such files are
called flat files
• Lists often called linked list is also a sequential data structure
• Examples of data types are integer, char, float, string, Boolean, real, etc.
• Different data types require different memory space, floating point
requires more bits than a simple integer, double integer requires twice the
number of bits of a simple integer
• Arrays normally consist of data of the same data type, the data in array is
indexed using an integer which can start from 0 or 1
Summary

• Arrays are mono-dimensional that is a single column or multi-dimensional that is


multiple rows and columns
• Static arrays are fixed size arrays whereas dynamic arrays are arrays that are
extensible
• Variables are data structures that see the values changing during runtime
whereas constants have fixed values
• In networking Stream and Datagrams are data structures for TCP and UDP
respectively
• LIFO stands for Last In First Out, FIFO stands for First In First Out
• In RDBMS the data structure is a 2 dimension that is a table which can be related
to another table or other tables
Thank You For Your Attention

Any Question?
Activities
1. Explain the how data is structured using the following data structures:
i. Variable
ii. Arrays
iii. Lists
2. Describe the different data types you are aware of.
3. Explicit the following methods in data stack:
i. LIFO
ii. FIFO
4. What are the data structures used in the following:
i. Databases
ii. Network data models
iii. Hierarchal data model
iv. Clouds
Activities
5. What is the difference in terms of data structure between a plain text file and an
RDBMS in the context of data storage?
6. State difference between a static array and a dynamic array.
7. A secretary working on office applications save directly her work on a secondary
storage like a pen drive. Why according to you this can be qualified as a computer
misuse.
8. What is a multilinked data structure? State one application of multilink data
structure.
9. Imagine you wish to do some very complex mathematical calculations so you will
declare your data type to float or double integer. Describe these data types.
10. How would convert a string data type into integer data type in a sort algorithm in
alphabetical order for instance?

You might also like