Sunteți pe pagina 1din 4

DATA STRUCTURE AND ALGORITHMS

ASSIGNMENT
QUESTION-01: DEFINE ARRAY
ANSWER:
In programming, a series of objects all of which are the same size and type.
Each object in an array is called an array element. For example, you could
have an array of integers or an array of characters or an array of anything
that has a defined data type. The important characteristics of an array are:
Each element has the same data type (although they may have different
values).
The entire array is stored contiguously in memory (that is, there are no gaps
between elements).
Arrays can have more than one dimension. A one-dimensional array is called
a vector ; a two-dimensional array is called a matrix.
EXPLAIN ALGORITHM FOR INSERTING ELEMENTS IN AN ARRAY?
ARRAY Insertion
Inserting an element at end of linear array can be done easily if the array is
large
enough
to
accommodate
new
item.
If the element is to be inserted in the middle of array then half members
must be moved downward to new location to accommodate new element by
keeping
the
order
of
other
elements
ARRAY INSERTION ALGORITHM
Algorithm for Insertion: (Inserting into Linear Array) INSERT (LA, N, K, ITEM)
1. [Initialize counter] Set J: = N.
2. Repeat Steps 3 and 4 while j >= k;
3. [Move jth element downward.] Set LA [J + 1]: =LA [J].
4. [Decrease counter] Set J: = J-1

[End of step 2 loop]


5. [Insert element] Set LA [K]:=ITEM.
6. [Reset N] Set N:=N+1
7. EXIT.

QUESTION-02: DEFINE DATA STRUCTURE AND EXPLAIN ALGORITHMIC


NOTATION IN DATA STRUCTURE?
In computer science, a data structure is a particular way of organizing data in
a computer so that it can be used efficiently. Data structures can implement
one or more particular abstract data types (ADT), which are the means of
specifying the contract of operations and their complexity. In comparison, a
data structure is a concrete implementation of the contract provided by an
ADT.
Different kinds of data structures are suited to different kinds of applications,
and some are highly specialized to specific tasks. For example, relational
databases most commonly use B-tree indexes for data retrieval, while
compiler implementations usually use hash tables to look up identifiers.
Data structures provide a means to manage large amounts of data efficiently
for uses such as large databases and internet indexing services. Usually,
efficient data structures are key to designing efficient algorithms. Some
formal design methods and programming languages emphasize data
structures, rather than algorithms, as the key organizing factor in software
design. Storing and retrieving can be carried out on data stored in both main
memory and in secondary memory.
ALGORITHMIC NOTATION
Asymptotic notation is a way of expressing the cost of an algorithm. Goal of
Asymptotic notation is to simplify Analysis by getting rid of unneeded
information
Following are the asymptotic notation:
BigOh Notation (O) :
>> O(g(n)) = { f(n) : there exist positive constants c and n0 such that 0 <
f(n) < c*g(n) for all n > n0 }.

>> It is asymptotic upper bound.


>>The function f(n) = O(g(n)) iff there exist positive constants c and n0 such
that f(n) c * g(n) for all n, n n0.
>> The statement f(n) = O(g(n)) states only that g(n) is an upper bound on
the value of f(n) for all n, n no.
Omega Notation ()
>> (g (n)) = { f(n) : there exist positive constants c and n0 such that 0 < c
* g(n) < f(n) for all n > n0 }
>> Asymptotic lower bound.

>> The function f(n) = (g(n)) iff there exist positive constants c and n0
such that f(n) c * g(n) for all n, n n0.
>> The statement f(n) = (g(n)) states only that g(n) is only a lower bound
on the value of f(n) for all n, n no.
Theta Notation ()
>> (g(n)) = { f(n) : there exist positive constants c1 and c2 and n0 such
that 0 < c1 * g(n) < f(n) < c2 * g(n) for all n > n0 }
>> The function f(n) = (g(n)) iff there exist positive constants C1, C2 and
n0 such that C1 * g(n) f(n) C2 * g(n) for all n, n n0.
Little oh Notation (o)
>> o(g(n)) = { f(n) : for any positive constant c>0 , there exists a constant
n0 such that 0 < f(n) < c * g(n) for all n > n0 }
>> We use o notation to denote an upper bound that is not asymptotically
tight.
>> The definitions of O-notation and o-notation are similar. The main
difference is that in f(n) =O(g(n)), the bound 0 < f(n) < c*g(n) holds for some
constant c>0 but in f(n) =O(g(n)), the bound 0 < f(n) < c *g(n) holds for all
constants c > 0.
Little omega Notation (w)

>> w(g(n)) = { f(n) : for any positive constant c>0 , there exists a constant
n0 such that 0 < c * g (n) < f(n) for all n > n0 }
>> We use w notation to denote an lower bound that is not asymptotically
tight.

S-ar putea să vă placă și