affiliate marketing

Monday, 12 December 2011

PRIORITY QUEUE USING HEAP


PRIORITY QUEUE USING HEAP
Aim:
            To implement priority queue using Heap in C program.
Algorithm:
            Step 1: [Include necessary header files]
            Step 2: [Define maxsize as 15]
            Step 3: [Declare necessary variables]
            Step 4: READ  option, opt
                        IF opt is 1 THEN CALL INSERT()
                        IF opt is 2 THEN CALL DELMAX()
                        IF opt is 3 THEN CALL DIS()
            Step 5: [END OF MAIN FUNCTION]

Algorithm For INSERT()

EXPRESSION TREE


EXPRESSION TREE
Aim:
                                    To write a C program to demonstrate an expression tree.
Algorithm for Main ()
                                    Step 1: [ INCLUDE NECESSARY HEADER FILES]
                                    Step 2: [READ X]
                                    Step 3:[ CALL EXPTREE(),CALL DISPLAY(), CALL INORDER(),CALL
 PREORDER(),CALL EVALUATE ()]
Algorithm for EXPTREE()

            Step 1: Read Character
            Step 2: IF Character        operator then
                        CALL PUSH_OP()
            Step 3: [IF Character has only numbers]
                        IF [ is ALnum( str[i]           1 )] THEN
                        CREATE Newnode
            Step 4: Check for ‘ NULL ‘ condition
            Step 5: ASSIGN priority
            Step 6: IF ( Priority !=0) THEN CALL POP_OP()
            Step 7: IF Character = ‘)’ THEN CALL PUSH_OP()

Algorithm for INORDER (tree t)

BINARY SEARCH TREE


BINARY SEARCH TREE
Aim
To write a C program to implement a stack using binary search tree.
Algorithm
1.                  [Include all the necessary header files.]
2.                  [Declare the structure with all necessary variables.]
3.                  Read x;
4.                  Call INORDER().
5.                  Call PREORDER().
6.                  Call POSTORDER().
7.                  Call display().
8.                   
Algorithm For INSERT(P,X)

POLYNOMIAL MANUPULATION


POLYNOMIAL MANUPULATION
Aim
To implement polynomial manipulation using doubly linked lists.
Algorithm
POLYADD(POLY1: POLY2:POLY)
HEAD:POLY
Step 1: Assign HEAD+=NULL
Step2: While (POLY !=null)
Step3: HEAD=INSERTNODE(HEAD,COPYNODE,(POLY1,1))
Step4: POLY1=POLY1àNEXT
Step5: [End of Step2 while structure]
Step6: While(POLY2 1=NULL)
Step7: HEAD =INSERTNODE(HEAD,COPYNODE(POLY2,1))
Step8: POLY2=POLY2àNEXT
Step9: [End of Step 6 while Structure]
Step10: Return HEAD
END POLYADD()

Algorithm for polynomial subtraction

POLYSUB(POLY1:POLY, POLY2:POLY)
HEAD:POLY
Step1: Assign HEAD=NULL
Step2: While(POLY1!=NULL)
Step3: HEAD=INSERTNODE(HEAD,COPYNODE(POLY1,1))
Step4: POLY1=POLY1à NEXT
Step5: [End of Step2 while Structure]
Step6:While(POLY2!=NULL)
Step7: HEAD=INSERTNODE(HEAD,COPYNODE(POLY2,-1))
Step8: POLY2=POLY2àNEXT
Step9: [End of Step 6 While Structure]
Step10: Return HEAD
END POLYSUB()

Coding:

DOUBLY LINKED LIST – LINKED LIST IMPLEMENTATION


DOUBLY LINKED LIST – LINKED LIST IMPLEMENTATION

      Aim:
         To write a program to implement doubly linked list using linked list.
      Algorithm:
         Step 1: Declare header and pointer variables
         Step 2: Display the choices
         Step 3: If choice is 1 the get the element to be inserted in beginning and call ins_beg function.
         Step 4: If choice is 2 the get the element to be inserted in the end and call the ins_end function
         Step 5: If choice is 3 then get the element to be deleted and call deletion function.
         Step 6: If choice is 4 then call display duncation
         Step 7: If choice is default the exit the program
         Step 8: Terminate the program execution.
      Program: