www.bookspar.com | Website for students | VTU NOTES
Data Structures with C (06CS35)
Model question paper 1
1.
a. Explain different ways of passing parameters to a function. Write a program using
pointer to pass an array to a function to find the smallest of n numbers. (10 marks)
b. What is the output of the following?
int X[3][5]={
{1, 2, 3, 4, 5},
{11, 12, 13, 14, 15}
}
*n=&X;
i.
*(*(X+2) +1)
ii.
*(*(X+1))
iii.
*n
iv.
*(n+2)
v.
*(*(X)+2)+1
(10 marks)
2.
a. Write C function to implement the following
i. To copy n characters of string to one another
ii. To compare n characters of two strings
iii. To concatenate two strings
iv. To find length of string.
(8 marks)
b. Difference between structure and union. Also state the difference between structure
and array.
(6 marks)
c. Write a program to print the no of consonants, vowels, digits and special characters
stored in a specific file.
(6 marks)
3.
a. Discuss various exceptional conditions that should be handled while using stacks.
(6marks)
b. Write an algorithm for converting an infix expression to postfix. Trace the algorithm
indicating the contents of stack for the expression ((A-(B+C))*(D$(E+F) (10 marks)
c. Convert infix to postfix and prefix ((a-(b+c))*d$(e+f)
(4 marks)
4.
a. What is recursion? Illustrate with an example, what are the disadvantages of
recursion? With a neat stack trace, explain the working of recursive Fibonacci program.
(12 marks)
b. A circular queue of size 5 contains three elements- 20,40,60 with front =1 and rear=3.
Show with necessary diagrams, what is the value of front and rear after each of these
operations.
i. Insert 50
ii. Insert 90
iii.Insert 30
www.bookspar.com | Website for students | VTU NOTES
www.bookspar.com | Website for students | VTU NOTES
iv.Delete
v. delete
vi.Insert 70
(8 marks)
5.
a. What are linked lists? How do they compare with arrays? Give their relative merits of
both when certain operations are carried out.
(6 marks)
b. Write C functions to
i. Insert an item in an ordered linked list
ii. To delete a specified item.
iii. Reverse a linked list
(14 marks)
6.
a. Discuss the necessity of circular linked lists. Implement a stack using CLL.
(12 marks)
b. Write a program to check if a string is a palindrome or not using DLL. (8 marks)
7.
a. Why is tree called a nonlinear data structure. Define the following?
i. Binary tree.
ii. Complete binary tree.
iii. Height of a binary tree.
(6 marks)
b. Construct the binary tree given the following traversals.
Inorder : E A C K F H D B G
Preorder: F A E K C D H G B
(8 marks)
c. How is binary tree represented using array? Illustrate with an example and hence
define
i. child
ii. Siblings
iii. Ancestor
iv. Descendents
(6 marks)
8.
a. What is a threaded binary tree? Give the structure of a right-in Threaded binary tree
and its implementation in C for inorder traversal.
(10 marks)
b . Construct a binary search tree to find
i.
The maximum and minimum element in the tree.
ii.
To count the no of terminal and nonterminal nodes. (10 marks)
Data Structures with C (06CS35)
www.bookspar.com | Website for students | VTU NOTES
www.bookspar.com | Website for students | VTU NOTES
Model question paper 2
1.
a. Explain the different memory allocation functions available in C. Develop a program
to determine the sum of positive and negative numbers on an integer array of size 5 using
dynamic memory allocation. (10 marks)
b. Explain with example lvalue and rvalue expressions (5 marks)
c. A C program contains the following
Static int x[8] = {10, 20, 30. 40, 50, 60, 70, 80};
What is the output of i) x+2 ii) &x +2 iii) &(x +2) iv) *x+4 v) *(x+(*x+2))
(5 marks)
2.
a. Write a C program to check whether two words are anagrams? ((8 marks)
b. Define Structures. Give an example of nested structures. (6 marks)
c. Write a C program to merge two files of integers to produce third file. (6 marks)
3.
a. Give a suitable algorithm to ensure that parenthesis are nested properly for the example
{X + (Y – [A+B]) * C-[(D+E)]}.Also trace the algorithm for the example.
(12 marks)
b. Implement two stacks using a single array and also indicate the appropriate exception
conditions.
(8 marks)
4.
a. What is priority queue? Differentiate between ordinary queue and priority queue.
(8 marks)
b. Write a recursive function to search for a key item using linear search. (6 marks)
c. Explain the efficiency of recursion
(6 marks)
5.
a. Explain the array implementations of lists and what are its limitations?
(10 marks)
b. Write a C function to
i. delete all occurrences of a given key item in Singly Linked List.
ii. Search an element in Singly Linked List
(10 marks)
6.
a. What are Header nodes? How do header nodes help to simplify the operation of
Circular Doubly Linked List?
(6 marks)
b. Write C function to implement the following in a Doubly Linked List.
i. Insert a node at the specified location.
ii. Delete a node from the specified location.
iii. Display the list in the forward and backward direction.
(14 marks)
www.bookspar.com | Website for students | VTU NOTES
www.bookspar.com | Website for students | VTU NOTES
7.
a. Write the algorithm for constructing a binary search tree .While constructing the tree,
duplicates are not permitted. Trace the algorithm on input14,15,4,9,7,18,3,5,16,4,20,17,9,14,5.
(10 marks)
b. Write the algorithms for various tree traversal methods with examples. (10 marks)
8.
a. Write a function to delete a node from BST considering all three cases. (10 marks)
b. What is an expression tree? Write a program to evaluate an expression tree.
(10 marks)
www.bookspar.com | Website for students | VTU NOTES
Download

question-paper-Data-Structures-with-C-06cs35-10cs35

get an essay or any other
homework writing help
for a fair price!
check it here!