Wednesday, April 3, 2013

MARCH /APRIL-2009 (c-05)



3231
BOARD DIPLOMA EXAMINATION, (C09)
MARCH /APRIL-2009
DCM-III SEMESTER EXAMINATION
DATA STRUCTURES THROUGH C

TIME: 3 HOURS TOTAL MARKS:80

PART-A 10*3=30
Instruction: (1) answer all questions.
(2) Each question carries three marks.
1. Differentiate between arrays and linked list.
2. What are the applications of stack?
3. What is a circular queue? Explain it briefly.
4. Define the following terms related to tree: (a) root (b)leaf (c)subtree (d)degree of a node.
5. Define the tree structure with example.
6. Represent the following tree in array form.

7. Write the various tree traversal techniques.
8. What is time and space complexity in sorting?
9. Explain the principle of bubble sort.
10. Compare linear search and binary search.
PART-B                                                   5*10=50
Instruction: (1) answer any five questions.
                          (2) Each question carries ten marks.

11.  Write a C function to insert and delete elements in a doubly linked list.

12.  Expain how to convert the following infix expression to postfix form and write all rules. (A + B * C)/(D+ E).
13.  Write a C program to implement queues using arrays.
(a) write preorder, inorder and postorder traversals of tree given below


(b) Explain about binary search sort.
15(a) Construct a tree given inorder and preorder
Preorder : DBEAFCG
Inorder : ABDECFG
16. write functions in C to create and display binary tree.
17. Explain about quick sort with an example and write algorithm.
18. (a) Write an algorithm form binary search.
(b) Define data structures and classify them

MARCH /APRIL-2007 (c-05)





3231
BOARD DIPLOMA EXAMINATION, (C09)
MARCH /APRIL-2007
DCM-III SEMESTER EXAMINATION
DATA STRUCTURES THROUGH C

TIME: 3 HOURS TOTAL MARKS:80

PART-A 10*3=30
Instruction: (1) answer all questions.
(2) Each question carries three marks.

1. What is searching and What are the methods of searching.
2. List the advantages and disadvantages of Linked list
3. What is a circular queue? Explain briefly.
4. What do you meant by sparse matrix. Give an example.
PART-B 5*10=50
Instruction: (1) answer any five questions.
(2) Each question carries ten marks.
11. Write linear search algorithm.
12. Explain how to insert and delete elements in a double linked list
13(b) Write an algorithm for reversal of a single linked list.

MARCH /APRIL-2008 (c-09)




3231
BOARD DIPLOMA EXAMINATION, (C09)
MARCH /APRIL-2008
DCM-III SEMESTER EXAMINATION
DATA STRUCTURES THROUGH C

TIME: 3 HOURS TOTAL MARKS:80

PART-A 10*3=30
Instruction: (1) answer all questions.
(2) Each question carries three marks.

1. What is a priority queue? Explain it briefly.
2. Explain the purpose of dummy header.

PART-B 5*10=50

Instruction: (1) answer any five questions.
(2) Each question carries ten marks.
11. Write algorithm for binary search.
12. Explain how to create a single linked list with the help of an algorithm
13. Explain how to perform insertion/deletion operation on a single linked list
14.Write a C program to represent a matrix as sparse matrix.
15. Explain how to convert the following in fix expression to post fix form and write all rules. X+(y+z).

MARCH/APRIL-2013 (c-05)



C-09-CM-402
457
BOARD DIPLOMA EXAMINATION, (C-05)
MARCH/APRIL-2013
DCME-FOURTH SEMESTER EXAMINATION
Time: 3 hours]                   [Total Marks: 100
PART-A
Instructions: (1) Answer all questions
Each question carries Four marks.
 Answers should be brief and straight to the point and shall not exceed five simple sentences.
1.      Define data structure and classify them.
2.      Explain the linear data structures.
3.      Differentiate between arrays and linked list
4.      Write in short, about queue.
5.      List different types of representing an expression.
6.      List applications of stacks.
7.      Define the terms-tree, binary tree, complete binary tree.
8.      List applications of tree
9.      List various sorting techniques.
10.   Explain the method of linear search.

PART-B
Instructions: (1) Answer any five questions.
(2) Each question carries 12 marks.
(3) Answers should be comprehensive and the criteria for valuation is the content but not the length of the answer
11.  (a) write an algorithm to create singly linked list. (b) write a program to search a given element in singly linked list.
12.   Explain about the operations of doubly linked list..
13.   (a) write an algorithm to implement stack operations. (b) write a program to create sparse matrix for a given matrix
14.   Explain about binary search sort with an example.
15.   (a) write an algorithm to create a binary tree.
        (b). write the post traversal for the given binary tree.

16.  construct binary tree given inorder and preorder traversals: Preorder-ABDGCEHIF. Inorder- DGBAHEICF
17. (a) Write an algorithm to implement bubble sort and mention its time complexity. (b) write a program to implement quick sort.
18. (a) Explain with an example about merge sort. (b) write a program to implement binary search.





Saturday, November 24, 2012

OCT/NOV-2012(c-05)


C-09-CM-402
457
BOARD DIPLOMA EXAMINATION, (C-05)
OCT/NOV-2012
DCME-FOURTH SEMESTER EXAMINATION
Time: 3 hours]                   [Total Marks: 80
PART-A
Instructions: (1) Answer all questions
Each question carries three marks.
 Answers should be brief and straight to the point and shall not exceed five simple sentences.
1.       What is linked list? Give example.
2.       State the applications of stack.
3.       What is priority queue?
4.       Define complete binary tree.
5.       List various tree traversal techniques.
6.       Write the uses of sparse matrix.
7.       What are the different representations of tree in memory?
8.       List various sorting techniques.
9.       What is merge sort?
10.   Define ‘binary search’. Give an example.
PART-B
Instructions: (1) Answer any five questions.
(2) Each question carries ten marks.
(3) Answers should be comprehensive and the criteria for valuation is the content but not the length of the answer
11.   (a) write a c program for insertion operation on a single-linked list. (b) explain double-linked circular list with an example.
12.   Explain the algorithm for conversion of infix to postfix expression with an example.
13.   (a) explain the implementation of queue using linked list. (b) write a short note on circular queue.
14.   Write a c program to perform traversal operations on tree.
15.   (a) explain linked representation of binary tree with an example. (b) explain binary search sort.
16.   Explain with a program for operations on binary tree for integers.
17.   (a) explain the principle of quick sort with an example. (b) write a c program for selection sort.
18.   (a) explain about abstract data types. (b) explain linear search technique with example.



Answers:

PART-A

19.   What is linked list? Give example.
20.   State the applications of stack.
21.   What is priority queue?
22.   Define complete binary tree.
23.   List various tree traversal techniques.
24.   Write the uses of sparse matrix.
25.   What are the different representations of tree in memory?
26.   List various sorting techniques.
27.   What is merge sort?
28.   Define ‘binary search’. Give an example.

PART-B

29.   (a) write a c program for insertion operation on a single-linked list. (b) explain double-linked circular list with an example.
30.   Explain the algorithm for conversion of infix to postfix expression with an example.
31.   (a) explain the implementation of queue using linked list. (b) write a short note on circular queue.
32.   Write a c program to perform traversal operations on tree.
33.   (a) explain linked representation of binary tree with an example. (b) explain binary search sort.
34.   Explain with a program for operations on binary tree for integers.
35.   (a) explain the principle of quick sort with an example. (b) write a c program for selection sort.
36.   (a) explain about abstract data types. (b) explain linear search technique with example.




Home                    Next(Oct/Nov-2012(c-09)


OCT/NOV-2012 (c-09)






C-09-CM-402
457
BOARD DIPLOMA EXAMINATION, (C-09)
OCT/NOV-2012
DCME-FOURTH SEMESTER EXAMINATION
Time: 3 hours]                   [Total Marks: 80
PART-A
Instructions: (1) Answer all questions
Each question carries three marks.
 Answers should be brief and straight to the point and shall not exceed five simple sentences.
1.       Define non-linear data structure and give an example.
2.       What is the time complexity?
3.       Write how the queue data structures are sued in computers.
4.       Define a linked list.
5.       What is a postfix expression? Give an example.
6.       What are the uses of a sparse matrix?
7.       Construct a binary tree from the inorder dbeac and the preorder abdec.
8.       List the operations that can be performed on a binary tree.
9.       Write how the merge sort works.
10.   What is searching? List the types of searching methods.
PART-B
Instructions: (1) Answer any five questions.
(2) Each question carries ten marks.
(3) Answers should be comprehensive and the criteria for valuation is the content but not the length of the answer
11.   (a) write how a node is inserted in a doubly linked list. (b) write how a node is deleted from a doubly linked list.
12.   Explain how to search and replace an element in a singly linked list.
13.   Write a program for implementing a circular queue using arrays.
14.   Explain the stack operations with example.
15.   Explain various tree traversal operations for the given example and write the outputs :


16.   Explain the representation of a binary tree using (a) arrays (b) linked lists.
17.   Explain the process of selection sort.
18.   (a) write a pseudo code bubble sorting. (b) write the algorithm for binary search.



Answers


PART-A
.
1.       Define non-linear data structure and give an example.
2.       What is the time complexity?
3.       Write how the queue data structures are sued in computers.
4.       Define a linked list.
5.       What is a postfix expression? Give an example.
6.       What are the uses of a sparse matrix?
7.       Construct a binary tree from the inorder dbeac and the preorder abdec.
8.       List the operations that can be performed on a binary tree.
9.       Write how the merge sort works.
10.   What is searching? List the types of searching methods.
PART-B
1.   (a) write how a node is inserted in a doubly linked list. (b) write how a node is deleted from a doubly linked list.
12.   Explain how to search and replace an element in a singly linked list.
13.   Write a program for implementing a circular queue using arrays.
14.   Explain the stack operations with example.
15.   Explain various tree traversal operations for the given example and write the outputs :

16.   Explain the representation of a binary tree using (a) arrays (b) linked lists.
17.   Explain the process of selection sort.
18.   (a) write a pseudo code bubble sorting. (b) write the algorithm for binary search.
















Monday, October 22, 2012

AVL TREES


//EX: 1C Program to insert and delete elements in an AVL Tree 1
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#define FALSE 0
#define TRUE 1
struct AVLNode
{
  int data;
  int balfact;
  struct AVLNode *left;
  struct AVLNode *right;
};

struct AVLNode * insert(struct AVLNode *,int,int *);
struct AVLNode * deldata(struct AVLNode *,int,int *);
struct AVLNode * del(struct AVLNode *,struct AVLNode *,int *);
struct AVLNode * balr(struct AVLNode *,int *);
struct AVLNode * ball(struct AVLNode *,int *);
void display(struct AVLNode *);
void deltree(struct AVLNode *);
void main()
{
  struct AVLNode *avl=NULL;
  int h;
  clrscr();
  avl=insert(avl,20,&h);
  avl=insert(avl,6,&h);
  avl=insert(avl,29,&h);
  avl=insert(avl,5,&h);
  avl=insert(avl,12,&h);
  avl=insert(avl,25,&h);
  avl=insert(avl,32,&h);
  avl=insert(avl,10,&h);
  avl=insert(avl,15,&h);
  avl=insert(avl,27,&h);
 // avl=insert(avl,13,&h);
  printf("\n AVL Tree : \n");
  display(avl);
  avl=deldata(avl,5,&h);
  avl=deldata(avl,12,&h);
  printf("\n AVL tree after deletion of a node : \n");
  display(avl);
  deltree(avl);
  getch();

}



/* Inserts an element intp tree */
struct  AVLNode * insert(struct AVLNode *root,int data,int *h)
{
  struct AVLNode *node1,*node2;
  if(!root)
  {
     root=(struct AVLNode *)malloc(sizeof(struct AVLNode));
     root->data=data;
     root->left=NULL;
     root->right=NULL;
     root->balfact=0;
     *h=TRUE;
     return(root);
  }
  if(data < root->data)
  {
     root->left=insert(root->left,data,h);
     /* If left subtree is higher */
     if(*h)
     {
    switch(root->balfact)
    {
       case 1:
         node1=root->left;
         if(node1->balfact==1)
         {
           printf("\n Right Rotation alond %d. ",root->data);
           root->left=node1->right;
           node1->right=root;
           root->balfact=0;
           root=node1;
         }
         else
         {
          printf("\n Double rotation , left along %d",node1->data);
          node2=node1->right;
          node1->right=node2->left;

          printf(" then right along %d. \n",root->data);
          node2->left=node1;
          root->left=node2->right;
          node2->right=root;

          if(node2->balfact==1)
         root->balfact=-1;
          else
         root->balfact=0;
          if(node2->balfact==-1)
         node1->balfact=1;
          else
         node1->balfact=0;
          root=node2;
      }
      root->balfact=0;
      *h=FALSE;
      break;
       case 0:
         root->balfact=1;
         break;
       case -1:
         root->balfact=0;
         *h=FALSE;
      }
      }

  }

  if(data > root->data)
  {
    root->right=insert(root->right,data,h);
    /* If the right subtree is higher */
    if(*h)
    {
       switch(root->balfact)
       {
      case 1:
           root->balfact=0;
           *h=FALSE;
           break;
      case 0:
           root->balfact=-1;
           break;
      case -1:
           node1=root->right;
           if(node1->balfact==-1)
           {
          printf("\n Left rotation along %d. ",root->data);
          root->right=node1->left;
          node1->left=root;
          root->balfact=0;
          root=node1;
           }
           else
           {
          printf("\n Double rotation , right along %d",node1->data);
          node2=node1->left;
          node1->left=node2->right;
          node2->right=node1;
          printf(" then left along %d. \n",root->data);
          root->right=node2->left;
          node2->left=root;
          if(node2->balfact==-1)
             root->balfact=1;
          else
             root->balfact=0;
          if(node2->balfact==1)
             node1->balfact=-1;
          else
             node1->balfact=0;
          root=node2;
          }
          root->balfact=0;
          *h=FALSE;
    }
    }
 }
  return(root);

}


/* Deletes an item from the tree */
struct AVLNode * deldata(struct AVLNode *root,int data,int *h)
{
   struct AVLNode *node;
   if(!root)
   {
      printf("\n No such data. ");
      return (root);
   }
   else
   {
      if(data < root->data)
      {
     root->left=deldata(root->left,data,h);
     if(*h)
       root=balr(root,h);
      }
      else
      {
     if(data > root->data)
     {
        root->right=deldata(root->right,data,h);
          if(*h)
         root=ball(root,h);
     }
     else
     {
        node=root;
        if(node->right==NULL)
        {
           root=node->left;
           *h=TRUE;
           free(node);
        }
        else
        {
          node->right=del(node->right,node,h);
          if(*h)
         root=ball(root,h);
        }
      }
    }
      }

   return(root);
 }


 struct AVLNode * del(struct AVLNode *succ,struct AVLNode *node,int *h)
 {
    struct AVLNode *temp=succ;
    if(succ->left!=NULL)
    {
       succ->left=del(succ->left,node,h);
       if(*h)
      succ=balr(succ,h);
    }
    else
    {
       temp=succ;
       node->data=succ->data;
       succ=succ->right;
       free(temp);
       *h=TRUE;
    }
     return(succ);
}


/* Balance the tree , if right subtree is higher */
struct AVLNode * balr(struct AVLNode *root,int *h)
{
   struct AVLNode *node1,*node2;
   switch(root->balfact)
   {
     case 1:
    root->balfact=0;
    break;
     case 0:
    root->balfact=-1;
    *h=FALSE;
    break;
     case -1:
    node1=root->right;
    if(node1->balfact <= 0)
    {
      printf("\n Left rotation along %d. ",root->data);
      root->right=node1->left;
      node1->left=root;
      if(node1->balfact==0)
      {
          root->balfact=-1;
          node1->balfact=1;
        *h=FALSE;
      }
      else
      {
          root->balfact=node1->balfact=0;
      }
      root=node1;
    }
     else
     {
       printf("\n Double rotation , right along %d ",node1->data);
       node2=node1->left;
       node1->left=node2->right;
       node2->right=node1;
       printf(" then left along %d. \n",root->data);
       root->right=node2->left;
       node2->left=root;

       if(node2->balfact==-1)
      root->balfact=1;
       else
      root->balfact=0;
       if(node2->balfact==1)
     node1->balfact=-1;
       else
     node1->balfact=0;
       root=node2;
       node2->balfact=0;
    }
}
  return (root);
}


/* Balances the tree , if the left subtree is higher */
struct AVLNode * ball(struct AVLNode * root,int *h)
{
   struct AVLNode *node1,*node2;
   switch(root->balfact)
   {
      case -1:
     root->balfact=0;
     break;
      case 0:
     root->balfact=1;
     *h=FALSE;
     break;
      case 1:
     node1=root->left;
     if(node1->balfact >= 0)
     {
         printf("]n Right rotation along %d. ",root->data);
         root->left=node1->right;
         node1->right=root;
         if(node1->balfact==0)
         {
        root->balfact=1;
        node1->balfact=-1;
        *h=FALSE;
         }
         else
         {
           root->balfact=node1->balfact=0;
         }
         root=node1;
     }
     else
       {
      printf("\n Double rotation , left along %d ",node1->data);
      node2=node1->right;
      node1->right=node2->left;
      node2->left=node1;
      printf(" then right along %d .\n",root->data);

      root->left=node2->right;
      node2->right=root;

      if(node2->balfact==1)
          root->balfact=-1;
      else
          root->balfact=0;

      if(node2->balfact==-1)
          node1->balfact=1;
      else
          node1->balfact=0;
      root=node2;
      node2->balfact=0;
       }
    }
    return (root);
}




/*n Displays the tree in-order */
void display(struct AVLNode *root)
{
  if(root!=NULL)
  {
    display(root->left);
    printf("%d\t",root->data);
    display(root->right);
  }
}


/* Deletes the tree */
void deltree(struct AVLNode * root)
{
   if(root!=NULL)
   {
    deltree(root->left);
    deltree(root->right);
   }
   free(root);
}
//: CLICK HERE AVL TREES IN CPP