Data Strs Using C

Embed Size (px)

Citation preview

  • 8/6/2019 Data Strs Using C

    1/4

    EC401M S RAMAIAH INSTITUTE OF TECHNOLOGY

    (AUTONOMOUS INSTITUTE, AFFILIATED TO VTU)BANGALORE - 560 054SEMESTER END EXAMINATIONS - JUNE 2010

    Course & Branch : BE (Electronics and Communication) Semester : IVSubec Data Structures usingCMxMarks 100Subject Code EC401 Duraton 3 Hrs

    USN 1 S

    Instructions to the Candidates:Answer one full question from each unit.

    UNIT-I

    1 . a)b)

    Describe the two ways of passing parameter to functions. When doyou prefer to use each of them?Which of the following prototype declarations are invalid? Why?

    (08)(05)

    i) int (fun) void;ii) double fun (void);iii) float fun (x,y,z);iv) int fun (int a,b);v) void fun (int a, int &b);c) Write a C program to multiply two matrices using a function with (07)

    pointers.2. a) i) Find the final values stored in the variables x,y,z at the end of the, (06)

    program.void main(){int x,y,z, *p, *q;x=10;y=15;z=20;p=&xq=&z;*q=*p+y_3;Y=Y-(*P);*p=*q_z;}

    Page 1 of 4

  • 8/6/2019 Data Strs Using C

    2/4

    EC401What is the output of the following code?main(){static int a[5]={2,4,6,8,10};int i, b=5;for (i=0;i

  • 8/6/2019 Data Strs Using C

    3/4

    EC401UNIT - III

    5. a) Write a C function to split a linear linked list into two linear linked (10)lists on the basis of data. The even numbers are stored in the firstlist and odd numbers are stored in the second list. Display the evenand odd lists.

    b) Write advantages of doubly linked list over singly linked list. Write a (10)C function that will insert a given integer value into an ordereddoubly linked list.

    6. a) Write a C function for the following using singly linked list. (10)i) Read a polynomialii) Multiply two polynomialsiii) Display a polynomial

    b) Give a comparison between linked list and array. (04)c) Write a C function to delete a node from the front end and insert it at (06)

    the end of the list using circular linked list with header node.UNIT - IV

    7. a) Write a C program to represent a queue using circular linked list. (08)b) Assume a 5 element circular queue. Initially queue is empty. Show (06)

    the contents of the queue after each of the following operations.Insert(Q,10), Insert (Q,20), Delete (Q), Delete (Q), Insert (Q,30),Delete (Q).

    c) Write algorithms for the following operations on a stack implemented (06)using linked list.i) Push ii) Pop iii) Show the top value of the stack.iv) Check whether stack is full v) Check whether stack is empty

    8. a) Convert the following infix expression to prefix form. (08)i) a + b *(c-d) / e iii) a^b^c/a/b/cii) a * (b+(c-d+e*f)*g iv) ((a*b+c)-(b-c/e)) + a^bb) What is stack? Mention its appications. (04)

    c) Write a program using queue to check whether a string is a (08)palindrome or not.

    UNIT - V9. a) What is Binary tree? Explain various traversal techniques with (08)

    suitable example.b) Write a C function for the following using a Binary search tree. (06)

    i) Insert an elementii) Largest element in a treeiii) Total number of elements in a tree.

    c) Draw the expression trees for the followingi) a*b+(c/d)-eii) a*(b+c)/d-eiii) a^b c+c*d*e

    (06)

    Page 3 of 4

  • 8/6/2019 Data Strs Using C

    4/4

    EC401Consider a binary tree with 8 nodes. The preorder and inordertraversal of binary tree T yield the following sequence of nodes.Preorder : ABDEGHCFInorder : DBGEHACFDraw the Binary Tree T.

    c) Write a C function for the followingi) Create a BSTii) Delete an item from BST

    Define the following terms with one examplei) Complete Binary tree.ii) Almost complete binary tree.iii) Depth of a tree.iv) Binary search tree.

    *************************

    10. a)

    b )

    (04)

    (08)

    (08)

    Page 4 of 4