Sei sulla pagina 1di 4

EC401

USN 1 S

M S RAMAIAH INSTITUTE OF TECHNOLOGY


(AUTONOMOUS INSTITUTE, AFFILIATED TO VTU)
BANGALORE - 560 054
SEMESTER END EXAMINATIONS - JUNE 2010
Course & Branch : BE (Electronics and Communication ) Semester : IV
Subject : Data Structures using C Max . Marks 100
Subject Code EC401 Duration 3 Hrs

Instructions to the Candidates:


Answer one full question from each unit.

UNIT-I

1. a) Describe the two ways of passing parameter to functions. When do (08)


you prefer to use each of them?
b) Which of the following prototype declarations are invalid? Why? (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=&x
q=&z;
*q=*p+y_3;
Y=Y-(*P);
*p=*q_z;
}

Page 1 of 4
EC401
What 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<5;i++)
{
f(q[i],&b);
printf("%d, %d\n",a[i],b);
}

b) Write a C program to find standard deviation for N integers using (09)


functions, passing array as a parameter.
c) Explain memory leak and dangling pointer with suitable example. (05)

UNIT - II
3. a) What is a graph? Explain adjacency matrix and linked list (07)
representation of a graph with suitable example.
b) Write a C program to sort N integer numbers using address (08)
calculation sort (Hash sort).
c) What is sequential search? Explain with suitable example. (05)

4. a) Explain breadth first traversal and depth first traversal with suitable (06)
example.
b) For the given following graph G shown in Fig.4b. find its minimum (07)
spanning tree using Kruskal's algorithm. Show all steps.

11
Fig.4b
c) What is binary searching? Explain with suitable example. (07)

Page 2 of 4
EC401
UNIT - 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 first
list and odd numbers are stored in the second list. Display the even
and 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 ordered
doubly linked list.

6. a) Write a C function for the following using singly linked list. (10)
i) Read a polynomial
ii) Multiply two polynomials
iii) 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/c
ii) a * (b+(c-d+e*f)*g iv) ((a*b+c)-(b-c/e)) + a^b
b) What is stack? Mention its applications. (04)
c) Write a program using queue to check whether a string is a (08)
palindrome or not.

UNIT - V
9. 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 element
ii) Largest element in a tree
iii) Total number of elements in a tree.
c) Draw the expression trees for the following (06)
i) a*b+(c/d)-e
ii) a*(b+c)/d-e
iii) a^b^c+c*d*e

Page 3 of 4
EC401
10. a) Consider a binary tree with 8 nodes. The preorder and inorder (04)
traversal of binary tree T yield the following sequence of nodes.
Preorder : ABDEGHCF
Inorder : DBGEHACF
Draw the Binary Tree T.

b) Define the following terms with one example (08)


i) Complete Binary tree.
ii) Almost complete binary tree.
iii) Depth of a tree.
iv) Binary search tree.
c) Write a C function for the following (08)
i) Create a BST
ii) Delete an item from BST

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

Page 4 of 4

Potrebbero piacerti anche