4. data-structure
4. data-structure
9. Define searching.
The process of finding the location of a data item in the
given collection of data items is called as searching.
27. Name the type of memory allocation use by the linked list.
Dynamic memory allocation.
FRONT REAR
A B C D E
0 1 2 3 4 5 6 7 8
FRONT = 1 REAR = 5
Base(A)=3000, W=4
The formula for finding location of an element A[I][J] in array A with lower
bound LB, base address Base(A) and word size W per array cell is given by
7. Consider the array A of order 25x4 with base value 2000 and one word per
memory location. Find the address of A [12][3] in column-major order.
Solution:
Base(A)=2000, W=1, M=25, N=4, I=12, J=3, LB=0(assumption)
LOC(A[I][J]) = Base (A)+ W[(I-LB) +m*(J-LB)]
LOC (A [12][3] = 2000+1[12-0) +25*(3-0)
= 2000+1[12+25*(3)]
= 2000+1[87]
= 2087
50 40 70 20 Null
Disadvantage:
In a singly linked list, a pointer is available to access all the
succeeding nodes, but not preceding nodes. In the singly
linked lists, the link field of the last node contains NULL
1 2 3 4
The link field of the last node contains the address of the first
node is called as circular linked list.
In circular linked list is possible to reach any node from any
other.
INFO
Algorithm: A is the array with N elements. ITEM is the element to be inserted in the
position P.
16. Define the following: a. Root Node b. Leaf Node c. Height d. Depth e.
Internal node.
a) Root node: The top most node in a tree
b) Leaf node: Nodes that do not have children.
c) Height: Number of nodes which must be traversed from the root
to reach a leaf of a tree.
d) Depth: It is the number of ancestors of a node excluding
itself i.e., the length of the path to its root.
e) Internal node: An internal node or inner node is any node of a tree that
has child nodes.