0% found this document useful (0 votes)
17 views8 pages

Alg in Ds

thanking u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

Alg in Ds

thanking u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

1(a).

LIST ADT USING ARRAY

AIM
To write a python program to implement list ADT using array

ALGORITHM
1. Start the program.

2. Read the number of elements in the list and create the list.

3. Read the position and element to be inserted.

4. Adjust the position and insert the element.

5. Read the position and element to be deleted.

6. Remove the element from the list and adjust the position.

7. Read the element to be searched.

8. Compare the elements in the list with searching element.

9. If element is found, display it else display element is not found.

10. Display all the elements in the list.

11. Stop the program.

RESULT:
Thus a Python program to implement the List using array is written and
executed successfully.
1 (b). LIST ADT USING LINKED LIST

AIM
To write a python program to implement list ADT using linked list

ALGORITHM
1. Start the program.

2. Create a node using structure

3. Dynamically allocate memory to node

4. Create and add nodes to linked list.

5. Read the element to be inserted.

6. Insert the elements into the list.

7. Read the element to be deleted.

8. Remove that element and node from the list.

9. Adjust the pointers.

10. Display the elements in the list.

11. Stop the program.

RESULT:
Thus a python program to implement the List ADT using linked list is written and
executed successfully.

2(a). STACK ADT USING SINGLY LINKED LIST


AIM:

To write a python program to implement the stack using singly linked list.

ALGORITHM:

A) Push Operation:
1. To push an element into the stack, copy the element to be inserted in the data field
of the new node.
2. Assign the reference field of the new node as NULL.
3. Check if top is not NULL, if so, then assign the value of top in the reference field of
new node.
4. Assign the address of the new node to the top.

B) Pop Operation:
1. To pop an element from the stack, check whether the top of the stack is NULL.
2. If so, then return stack is empty and element cannot be popped from the stack.
3. Else, assign the top value to a temporary node.
4. Now assign the value in the reference field of the node pointed by top to the top
value.
5. Return the value in the data field of the temporary node as the element deleted and
delete the temporary node.

RESULT:

Thus a python program to implement the stack using linked list is written and
executed successfully.

2(b) QUEUE ADT USING LINKED LIST


AIM:

To write a C program to implement the queue using linked list.

ALGORITHM:

ENQUEUE:

1. Create a new node and allocate memory space for the new node.

2. Assign the element to be inserted in the data field of the new node.

3. Assign NULL to the address field of the new node.

4. Check if rear and front pointers are NULL.

5. If so, then make the front and rear pointers to point to new node.

6. If not, then assign address of the new node as the rear pointer value.

DEQUEUE:

1. Check if queue is not empty.

2. If it is empty, return queue underflow and dequeue operation cannot be done.

3. If not, assign the front->next value as the new front pointer and free the deleted node.

RESULT:

Thus a python program to implement the queue using linked list is written and executed
Successfully
3. INFIX EXPRESSION CONVERTS THE EXPRESSION TO POSTFIX FORM USING
SATCK ADT

AIM:

To write a python program to implement the infix expression converts the


Expression to postfix form using stack ADT

ALGORITHM:

Start the program


1. If a character is operand, push it to stack.
2. If a character is an operator, if there are fewer than 2 values on the stack give error
insufficient values in expression go to step 4 else pop 2 operands from stack
o Create a new string and by putting the operator between operands.
o Push this string into stack
o Repeat Steps 1 and 2
3. At last there will be only one value or one string in the stack which will be our infix
4. Exit
5. Stop the program

RESULT:

Thus a python program to implement the infix expression converts the


Expression to postfix form using stack ADT is written and executed successfully

4. PRIORITY QUEUE ADT


AIM:

To write a python program to implement the priority of queue ADT using linked list.

ALGORITHM:

1. Start The Program


2. Create an empty queue
3. Add elements to the queue, simultaneously applying the priority function to
assign a priority to each element
4. Use a dequeue operation to remove the highest priority element when ready
5. Continue dequeue until the queue is empty
6. Stop the program

RESULT:

Thus a python program to implement the priority of queue ADT using linked list is
written and executed successfully

5. BINARY SEARCH TREE


AIM:

To write a python program to implement binary search tree.

ALGORITHM:

1. Start the program.

2. Declare the node.

3. Read the elements to be inserted.

4. Create the binary search tree.

5. Read the element to be searched.

6. Visit the nodes by inorder.

7. Find the searching node and display if it is present with parent node.

8. Read the element to be removed from BST.

9. Delete that node from BST.

10. Display the binary search tree by inorder.

11. Stop the program.

RESULT:

Thus a python program to implement the binary search tree is written and executed
successfully.

6. AVL- TREE

You might also like