ds5 (1)
ds5 (1)
5-Marks Questions
1.What is primitive data structure? Explain the different operations performed on
primitive data structure.
Data structures that are directly operated upon by machine-level instructions are known
as primitive data structures. Ex: int ,float, pointer etc.,
The various operations that can be performed on primitive data structures are:
Create: Create operation is used to create a new data structure. This operation reserves
memory space for the program elements.
Destroy: Destroy operation is used to destroy or remove the data structures from the
memory space.
Select: Select operation is used by programmers to access the data within data
structure.
Update: Update operation is used to change data of data structures.
Front Rear
FRONT=1
10 20 30 REAR=3
0 1 2 3 4
Circular Queue: A circular queue is a queue in which all nodes are treated as circular
such that the last node follows the first node.
Priority Queue: A priority queue is a queue that contains items that have some preset
priority. An element can be inserted or removed from any position depending on some
priority.
Dequeue (Double Ended queue): It is a queue in which insertion and deletion takes place
at both the ends.
STACK is the array that contain N elements and TOP is the pointer to top element of the array. This
procedure deletes TOP element from STACK.
17. Write an algorithm to insert a data element at the rear end of the queue.
Let Queue is the linear array with N elements
Front is the pointer contains the location of the element to be deleted
Rear contains the location of the inserted element.
18. Write an algorithm to delete a data element from the front end of the queue.
Let Queue is the linear array with N elements
Front is the pointer contains the location of the element to be deleted
Rear contains the location of the inserted element.
Step 1: if FRONT=NULL then
PRINT “Underflow” Exit
Step 2: item=Queue[FRONT]
Step 3: if(FRONT=REAR) then
FRONT=0 REAR=0
Else
FRONT = FRONT +1
Step 4: Return
19. Write an algorithm to delete a data element from the front end of the queue.
Let Queue is the linear array with N elements
Front is the pointer contains the location of the element to be deleted
Rear contains the location of the inserted element.
Step 1: if FRONT=NULL then
PRINT “Underflow” Exit
Step 2: item=Queue[FRONT]
Step 3: if(FRONT=REAR) then
FRONT=0 REAR=0
Else
FRONT = FRONT +1
Step 4: Return