AMIETE – ET/CS/IT (NEW SCHEME)   –   Code: AE52/AC52/AT52

 

Subject: C & DATA STRUCTURES

Flowchart: Alternate Process: JUNE 2009Time: 3 Hours                                                                                                     Max. Marks: 100

 

 

NOTE: There are 9 Questions in all.

·      Question 1 is compulsory and carries 20 marks. Answer to Q. 1. must be written in the space provided for it in the answer book supplied and nowhere else.

·      Out of the remaining EIGHT Questions answer any FIVE Questions. Each question carries 16 marks.

·      Any required data not explicitly given, may be suitably assumed and stated.

 

 

Q.1       Choose the correct or the best alternative in the following:                                  (210)

       

             a.  ________ are the special directives used to format printing.

 

                  (A) Operators                                      (B) Escape sequences

                  (C) Strings                                            (D) Identifiers                                                       

 

             b. We can combine multiple expressions in a single expression using ______.

 

                  (A) comma operator                             (B) increment operator

                  (C) bitwise operator                             (D) assignment operator

 

             c.  The _____ field specification is used to read or write a short integer.

 

                  (A) %c                                                 (B) %f

                  (C) %d                                                 (D) %hd

 

             d.  The switch expression should be _______ expression.

 

                  (A) an integer                                       (B) a logical

                  (C) a real                                              (D) a logical or real

 

             e.  For every variable there are two attributes :__________.

 

                  (A) int and float                                    (B) address and value

                  (C) increment and decrement                (D) printf and scanf

 

             f.   A string is a _______ array with a null terminator at the end.

 

                  (A) integer                                            (B) float

                  (C) multidimension                                (D) character

 

             g. The order of the bubble sort algorithm is ________.

 

                  (A) O(n2)                                             (B) O(n)

                  (C) first                                                (D) second

 

             h.  A leaf node of a tree is a node with a degree equal to __________.

 

(A)  0                                                    (B) 1

                  (C) 2                                                    (D) k

 

             i.   For a binary tree, the maximum number of nodes at level i will be _____.

 

                  (A)                                          (B) 2i

                  (C) 2i-1                                                 (D) none

 

             j.   A graph can be traversed _____________.

 

                  (A) only by using the depth-first traversal                                                                           

                  (B) only by using the breadth-first traversal

                  (C) using the depth-first traversal or breadth-first traversal                                                 

                  (D) none of the above

 

 

Answer any FIVE Questions out of EIGHT Questions.

Each question carries 16 marks.

 

 

  Q.2     a.   What is type conversion?  Differentiate between explicit and implicit type conversion.  Substantiate your answer with help of an example.           (6)

                  

             b.   List the different arithmetic operators available in C.  Explain with help of example what is meant by precedence of arithmetic operators.      (6)

 

             c.   Write the following function using conditional operator

                   y = 1.5x + 3 for x  2

                   y = 2x +5 for x > 2                                                                                            (4)

 

  Q.3     a.   Write a switch statement and an if-else statement in C to find the grade of a student as per the following conditions:

                   If percentage < 40 then grade = Fail

                   percentage between 41 and 50  then grade = C

                   percentage between 51 and 60  then grade = B

                   percentage between 61 and 80  then grade = A

                   beyond 80 then A+                                                                                            (8)

            

             b.   Write a C program to add first n even numbers.                                                  (8)

 

  Q.4     a.   With a C program example, show how an array element can be accessed using a pointer.               (6)

       

             b.   Write a C function that adds two integers without using the ‘+’ operator.             (4)

 

             c.   Write a C recursive function for calculating factorial of a given integer.                 (6)


 

  Q.5     a.   Differentiate between a structure and a union.  Explain with the help of example how are individual members accessed in each of them.                     (6)

 

             b.   What are direct access file and indexed sequential file?                                        (4)

 

             c.   Write a program to copy one string into another and count the number of characters copied.                                                                      (6)

       

  Q.6     a.   Write a C program to sort a given set of N integers using bubble sort.               (12)

 

             b.   Define a heap.  Point out the difference between a maximum heap and minimum heap.                    (4)

 

  Q.7     a.   Write a C program to implement a stack using linked list representation.            (12)

 

             b.   What are queues and circular queues?  (4)

       

  Q.8     a.   Define a Binary search tree.  Draw the binary search tree for the following data assuming tree is initially empty.

                   50,  33,   44,   22,   77,   35,   60,   40                                                              (8)

 

             b.   Write a C program to count the number of nodes in a given binary tree.               (8)

 

  Q.9     a.   Represent the following graph using

                   (i)  Adjacency matrix                          

 
                   (ii) Adjacency list                                                                                              (8)

 

 

 

 

 

 

 

 

 

 

 

             b.   Define a minimum spanning tree.  Outline Prim’s Algorithm to create a minimum spanning tree for a weighted graph.                                                  (8)