Data Structure-Basic Terminology
Data Structure-Basic Terminology
Definition:
A data structure is a specialized format for organizing and storing data. General data
structure types include the array, the file, the record, the table, the tree, and so on.
Any data structure is designed to organize data to suit a specific purpose so that it can
be accessed and worked with in appropriate ways.
1.1 Elementary Data Organization
1.1.1 Data and Data Item
Data are simply collection of facts and figures. Data are values or set of values. A
data item refers to a single unit of values. Data items that are divided into sub items are
group items; those that are not are called elementary items. For example, a students
name may be divided into three sub items [first name, middle name and last name]
but the ID of a student would normally be treated as a single item.
In the above example ( ID, Age, Gender, First, Middle, Last, Street, Area ) are elementary
data items, whereas (Name, Address ) are group data items.
Example:
information is sometimes used for data with given attributes, of, in other words
meaningful or processed data.
1.1.8 Field
A field is a single elementary unit of information representing an attribute of an
entity, a record is the collection of field values of a given entity and a file is the
collection of records of the entities in a given entity set.
1.1.9 File
File is a collection of records of the entities in a given entity set. For example, file
containing records of students of a particular class.
1.1.10 Key
A key is one or more field(s) in a record that take(s) unique values and can be
used to distinguish one record from the others.
Example
x is asymptotic with x + 1 as shown in
graph.
Asymptotic may also be defined as a way to
describe the behavior of functions in the
limit or without bounds.
0 n2 + 50n cn2
Divide by n2
Note that 50/n 0 as n
Pick n = 50
0 1 + 50/50 = 2 c = 2
With c=2
0 1 + 50/n0 2
Find n0
-1 50/n0 1
-20n0 50 n0 = 50 n0=50
0 n2 + 50n 2n2
n n0=50, c=2
Example : n3 = (n2)
0 cg(n) h(n)
0 1*12 = 1 1 = 13
0 cg(n) h(n)
0 cn2 n3
n=
1.2.2.3 Big-Theta Notation ()
We say that f(n) is Big-Theta of g(n), written as f(n) = (g(n)), iff there are
positive constants c1, c2 and n0 such that
0 c1 g(n) f(n) c2 g(n) for all n n0
Equivalently, f(n) = (g(n)) if and only if f(n) = O(g(n)) and f(n) = (g(n)). If f(n) =
(g(n)), we say that g(n) is a tight bound on f(n).
Divide by n2
c1 1/2-2/n c2
1.2.2.4 Time Space Trade-off
The best algorithm to solve a given problem is one that requires less memory
space and less time to run to completion. But in practice, it is not always possible to
obtain both of these objectives. One algorithm may require less memory space but may
take more time to complete its execution. On the other hand, the other algorithm may
require more memory space but may take less time to run to completion. Thus, we have
to sacrifice one at the cost of other. In other words, there is Space-Time trade-off
between algorithms.
If we need an algorithm that requires less memory space, then we choose the first
algorithm at the cost of more execution time. On the other hand if we need an
algorithm that requires less time for execution, then we choose the second algorithm at
the cost of more memory space.