affiliate marketing
Showing posts with label binary search tree program. Show all posts
Showing posts with label binary search tree program. Show all posts

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)