SlideShare una empresa de Scribd logo
1 de 13
data structures question paper anna university.

                    CS 1151 DATASTRUCTURES

PART – A (10 * 2 = 20 Marks)/

Answer ALL questions

1. Define ADT.
2. How do you push and pop elements in a linked stack?
3. Prove that the number of odd degree vertices in a connected graph should be even.
4. Define NP hard and NP complete.
5. Define binary search tree.
6. List out and define the performance measures of an algorithm.
7. What is Recursion? Explain with an example.
8. List out the various techniques of hashing.
9. What is the worst case complexity of Quick sort?
10. State the algorithmic technique used in merge sort.

PART B (5 * 16 = 80 Marks)

11.(a) Derive the best, average, worst case time complexity of a linear search.

(b) (i) Develop an algorithm for binary search. Validate the algorithm with a suitable data set.
(10)
(ii) What is Top down approach? Explain. (6)

12. (a) Write ADT operations for array implementation of polynomial addition. (b) Write
ADT operations for array implementation of a queue.

13. (a) Write insertion algorithm for AVL tree. Write suitable rotation algorithms. (b) (i)
Explain the algorithm for separate chaining. ( 8 )
(ii) Explain implementation of priority queue ( 8 )

14. (a) Write ADT operations for heap sort. Using the above algorithm sort the following:
35 45 25 11 6 85 17 35

(b) (i) Explain the quick sort algorithm. ( 8 )
(ii) Explain external sorting. Give relevant example. ( 8 )15. (a) Explain Dijkstra’s
algorithm using the following graph. Find the shortest path between v1, v2, v3, v4, v6 and
v7.
[Diagram not available] (b) (i) Write ADT operation for Prim’s algorithm. ( 8 )
(ii) Explain the topological sort algorithm. ( 8 )

      1. What do you mean by sorting? Mention the di erent types of sorting, give some
          examples and explain any one indetail. [16 marks]
    2. Compare the advantage and disadvantage of bubble, insertion and selection sort.
    3. Write a program to sort the elements whose worst and average case are O(n log n).
        [16 marks]
4. Write a program to explain selection sort . Which type of technique does it belong.
    [16 marks]
5. Write a program to explain selection sort . Which type of technique does it belong.
    [16 marks]
6. Write a program to sort the elements whose worst case is O(n2) and average case is
    O(n log n). [16 marks]
7. (a) Explain selection sort indetail.
    (b) Explain bubble sort indetail. [8+8]
8. Write an algorithm for routine merge(x,lb1,ub1,ub2) that assumes that x[lb1]
    through x[ub1] and x[ub1 + 1] through x[ub2] are sorted and merges the two into
    x[lb1] through x[ub2]. [16 marks]
9. (a) Explain Quick sort with algorithm.
    (b) Analyse the worst case performance of Quick sort and compare with Selection
    sort.[8+8 marks]
10. (a) Write a C program to sort the elements of an array using Quick sort with
    suitable example.
    (b) What is the worst case and best case time complexity of the above program?
11. Write an algorithm for quick sort. What is its time complexity. [16 marks]
12. (a) Write an algorithm for selection sort
    (b) Sort the following numbers using selection sort and give the required steps.
    96,31,27,42,34,76,61,10,4 [8+8]
13. (a) Using linear search delete the number 26 from the list of numbers and give the
    steps.
    10,7,17,26,32,92
    (b) Write a C program to implement the same. [8+8 marks]
14. (a) Distinguish between linear and binary search methods.
    (b) Write an algorithm for non-recursive binary search method. [8+8 marks]
15. (a) Write a C program to sort the elements of an array using bubble sort technique
    with a suitable example.
    (b) What is the worst case and best case time complexity of bubble sort? [10+6
    marks]
16. (a) Write a C program to sort given integers using partition exchange sort.
    (b) Derive the time complexity of partition exchange sort. [8+8]
17. Write a C program that searches a value in a stored array using binary search.
    What is the time complexity of binary search? [16 marks]
18. (a) Write a C program to merge two sorted arrays of integers.
    (b) Derive the time complexity of merge sort. [8+8 marks]
19. (a) Write and explain non-recursive algorithm for binary search with suitable
    example and discuss the various time complexities of binary search.
    (b) Suppose that the list contains the integers 1,2,8 in this order. Trace through the
    steps of binary search to determine what comparisons of keys are done in searching.
    i. To lo cate 3
    ii. To lo cate 4.5 [8+8 marks]
20. Trace through the steps by hand to sort the following list in Quick sort.
    28 7 39 3 63 13 61 17 50 21 [16 marks]
21. What are the advantages and disadvantages of stack ? Write a program to illustrate
    stack operation ? [16 marks]
22. Give an algorithm / C program to reverse a singly linked circular list inplace. [16
    marks]
23. What are the advantages and disadvantages of stack ? Write a program to illustrate
    queue operation ? [16 marks]
24.   Compare singly and doubly linked list to perform insertion operation . [16 marks]
25.   Write a program to illustrate the various operations of singly linked list . [16 marks]
26.   Write a program to delete a node in singly and doubly linked list . [16 marks]
27.   Write a C program using pointers to implement Queue with all operation. [16
      marks]
28.   Write a routine to concatenate two singly linked lists. [16 marks]
29.   What is a stack? Explain two di erent representations of a stack. List the operations
      performed on a stack and write functions for implementing these operations.[16
      marks]
30.   (a) Write a 'C' Program to convert an infix expression into prefix expression (b)
      Transform the following expression to prefix, using the approach (A + B) * (C$(D -
      E) + F) - G [8+8 marks]
31.   (a) Mention and explain various types of queues and give an example for each (b)
      Compare various types of queues. [8+8 marks]
32.   Write an algorithm to perform each of the following operations to a linked list. (a)
      Return the sum of the integers in a list. (b) Return the number of elements in a list.
      [8+8 marks]
33.   Design insertion and deletion algorithms for a doubly linked circular lists. [16
      marks]
34.   (a) Derive a method to convert a postfix expression into its prefix form (b) Consider
      the following arithmetic expression in postfix notation: 7 5 2 + * 4 1 5 - / - i. Find the
      equivalent prefix form of the above . ii. Obtain the computed value of the expression
      from its postfix notation.[8+4+4 marks]
35.   (a) What is a network? (b) What is a spanning tree? (c) Define minimal spanning
      tree . (d) What are the various traversals in a tree? [16 marks]
36.   Write an algorithm to perform deletion operation in a Binary Search Tree. [16
      marks]
37.   (a) Define multi graph and graph with self- loop . (b) Explain connected graph with
      example. [8+8 marks]
38.   Explain Kruskal's method of determining the minimal spanning tree. [16 marks]
39.   (a) Write a program to swap nodes in a binary tree. (b) Write a program to find min
      and max nodes in a binary tree. [8+8 marks]
40.   Explain binary search tree operations indetail. [16 marks]
41.   Explain non-recursive and recursive algorithm for converse in order traversal of
      binary tree. [16 marks]
42.   Write a C program for creating, inserting and deletion in a Binary tree. [16 marks]
43.   (a) Describe di erent types of trees. (b) Write a C program to implement Binary
      tree. [6+10 marks]
44.   (a) List and explain about the basic operations on a graph. (b) Write a C program
      for depth first search of a graph. [7+9 marks]
45.   Write a C program for creating, inserting and deletion in a Binary tree. [16 marks]
46.   (a) Write C function for minimum spanning tree of a weighted undirected graph (b)
      Write a C program to implement depth first traversal of graph. [10+6 marks]
47.   (a) List and explain about the basic operations on a graph. (b) Write a C program
      for depth first search of a graph. [7+9 marks]
48.   Write and explain the breath first traversal and depth first traversal in a graph with
      algorithm. [8+8 marks]
49.   Write in detail about the following: (a) Depth first search of a graph (b) Minimum
      spanning trees [8+8 marks]
50.   (a) Define graph. Explain the properties of a graph. (b) What is the di erence
      between strongly connected graph and weakly connected graph? [8+8 marks]
Time : Three hours Maximum : 100 marks
Answer ALL questions.
PART A — (10 ? 2 = 20 marks)
1. Define data structure and storage structure.
2. What is iteration? Give example.
3. What are primitive data types?
4. Compare the following statement : Break and Continue.
5. Differentiate singly linked list and circularly linked list.
6. Define stack.
7. What is hashing function?
8. Define single rotation on AVL tree.
9. Define direct access in a file.
10. What is the difference between binary tree and binary search tree?
PART B — (5 ? 16 = 80 marks)
11. (i) Write an algorithm for binary searching with example. Analyze the time
requirement of the algorithm. (11)
(ii) Explain the structure of indexed sequential files. (5)
12. (a) (i) Explain in detail about top–down approach and bottom–up approach with
suitable programming examples. (10)
(ii) Discuss about sequence selection iteration with examples. (6) Or
(b) (i) What is recursion? Give the application of recursion with programs.
(10)
(ii) What are the features of structured programming methodologies? Explain. (6)
13. (a) (i) What are the I/O statements used in ‘C’? Explain with examples. (8)
(ii) Write a program to compute the sum of the digits in a number and also to
reverse the digits. (8) Or
(b) (i) Discuss various control functions used in C. (8)
(ii) Solve the following equations for and using C language : (8)
14. (a) (i) What are the various stack operations? Explain. (6)
(ii) What are the various queue operations? Explain. (5)
(iii) Explain the application of stack for conversion of infix to postfix. (5) Or
(b) (i) What are the advantages and disadvantages of doubly linked list over singly
linked list? Explain the application of doubly linked list.
(9) (ii) Implement any two operations on circular linked list. (7)
15. (a) (i) Give a binary tree representation of the expression . (3)
(ii) What are the various tree traversal methods? Explain. (9)
(iii) Write an algorithm to convert general tree to binary tree. (4) Or
(b) (i) List out the application of binary tree and explain. (6)
(ii) Describe various hashing techniques. (10)
PART A-(10 X 2=20 marks)

1.When will you say an algorithm efficient? Give the notations for time complexity.
2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify your
answer.
3.Why is linked list used for polynomial arithmetic?
4.Write the role of stack in function call.
5.What is the minimum number of nodes in an AVL tree of height 5?
6.What is the use of sentinel value in binary heap?
7.Which is the best way of choosing the pivot element in quick sort?
8.Merge sort is better than insertion sort. Why?
9.Define a graph. How it differs from tree?
10.What is minimum spanning tree? Name any two algorithms used to find MST.

PART B-(5 X 16=80 marks)
11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 using
basic operations.
(ii).Write the routines for inserting and deleting elements from a queue. Check for
the conditions Q-empty and Q-full.
11.(b).(i).How would you implement a stack of queues? Write routines for creation
and inserting of elements into it.
(ii).Write routines to insert heterogeneous data into the list.
12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree.
(ii).A full node is a node with two children. Prove that the number of full nodes plus
one is equal to the number of leaves in a binary tree.
12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree.
(ii).Write the procedure to implement single and double rotations while inserting
nodes in an AVL tree.
13.(a).Explain with suitable examples the basic heap operations and algorithms for
the same.
13.(b).How will you resolve the collisions, while inserting elements into the hash
table using separate chaining and linear probing? Write the routines for inserting,
searching and removing elements from the hash table using the above mentioned
techniques.
14.(a).(i).Write the routine for sorting n elements in increasing order using heap
sort.
(ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort.
14.(b).(i).Explain with example about the insertion sort.
(ii).What is external sorting? Discuss the algorithms with proper examples.
15.(a).(i).Discuss and write the program to perform topological sorting.
(ii).What is single source shortest path problem? Discuss Dijikstra’s single source
shortest path algorithm with an example.
15.(b).(i).Write an algorithm to find the minimum cost spanning tree of an
undirected, weighted graph.
(ii).Find the MST for the following graph.
Data Strucutre Questions
1. What is data structure?

          A data structure is a way of organizing data that considers not only
    the items stored, but also their relationship to each other. Advance
    knowledge about the relationship between data items allows designing of
    efficient algorithms for the manipulation of data.

2. List out the areas in which data structures are applied extensively?

•    Compiler Design,

•    Operating System,

•    Database Management System,

•    Statistical analysis package,

•    Numerical Analysis,

•    Graphics,

•    Artificial Intelligence,

•    Simulation

3. What are the major data structures used in the following areas : RDBMS,
     Network data model & Hierarchical data model.

•    RDBMS – Array (i.e. Array of structures)

•    Network data model – Graph

•    Hierarchical data model – Trees

4. If you are using C language to implement the heterogeneous linked list,
     what pointer type will you use?

          The heterogeneous linked list contains different data types in its
    nodes and we need a link, pointer to connect them. It is not possible to use
    ordinary pointers for this. So we go for void pointer. Void pointer is
    capable of storing pointer to any type as it is a generic pointer type.

5. Minimum number of queues needed to implement the priority queue?

          Two. One queue is used for actual storing of data and another for
    storing priorities.
CS 1151-DATA STRUCTURES

Answer all the questions:

PART A-(10 X 2=20 marks)

1.When will you say an algorithm efficient? Give the notations for time complexity.
2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify your
answer.
3.Why is linked list used for polynomial arithmetic?
4.Write the role of stack in function call.
5.What is the minimum number of nodes in an AVL tree of height 5?
6.What is the use of sentinel value in binary heap?
7.Which is the best way of choosing the pivot element in quick sort?
8.Merge sort is better than insertion sort. Why?
9.Define a graph. How it differs from tree?
10.What is minimum spanning tree? Name any two algorithms used to find MST.

PART B-(5 X 16=80 marks)

11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 using
basic operations.
(ii).Write the routines for inserting and deleting elements from a queue. Check for
the conditions Q-empty and Q-full.(Or)
11.(b).(i).How would you implement a stack of queues? Write routines for creation
and inserting of elements into it.
(ii).Write routines to insert heterogeneous data into the list.
12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree.
(ii).A full node is a node with two children. Prove that the number of full nodes plus
one is equal to the number of leaves in a binary tree.(Or)
12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree.
(ii).Write the procedure to implement single and double rotations while inserting
nodes in an AVL tree.
13.(a).Explain with suitable examples the basic heap operations and algorithms for
the same.(Or)
13.(b).How will you resolve the collisions, while inserting elements into the hash
table using separate chaining and linear probing? Write the routines for inserting,
searching and removing elements from the hash table using the above mentioned
techniques.
14.(a).(i).Write the routine for sorting n elements in increasing order using heap
sort.
(ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort.(Or)
14.(b).(i).Explain with example about the insertion sort.
(ii).What is external sorting? Discuss the algorithms with proper examples.
15.(a).(i).Discuss and write the program to perform topological sorting.
(ii).What is single source shortest path problem? Discuss Dijikstra’s single source
shortest path algorithm with an example.(Or)
15.(b).(i).Write an algorithm to find the minimum cost spanning tree of an
undirected, weighted graph.
(ii).Find the MST for the following graph.

1. (a) Write an algorithm for stack operations. (10)

(b) Explain applications of trees with suitable examples. (10)

2. (a) Explain Heap sort with suitable example. (10)

(b) Write the algorithm for quick sort and explain with an example. (10)

3. (a) Explain the Greedy Algorithms. (10)

(b) Write the Kruskal algorithm for a minimum spanning tree. (10)

4. (a) What is linear search, binary search ? Write algorithms for both and comment

on the complexity. (15)

(b) Write short notes on graph coloring. (5)

5. (a) Explain Strassen's matrix multiplication. (10)

(b) Explain the travelling salesperson problem. (10)

6. (a) Explain Branch and Bound algorithm. (10)

(b) Discuss code optimization techniques. (10)

7. (a) Discuss in detail on hashing with examples. (10)

(b) Write an algorithm that will perform an insertion and deletion of a node in a

singly linked list. (10)

8. (a) Describe Np - Hard scheduling problems. (10)

(b) Describe Np - Hard code generation. (10)

MODEL QUESTION PAPER
B.E / B.Tech. Degree Examinations III Semester

IF 246 DATA STRUCTURES AND ALGORITHMS
PART – A
(10 x 2 = 20 Marks)
1. Take a linear search algorithms and discuss best-case time analysis.
2. Explain the basic of the Markov algorithm and discuss two ways in which such an
algorithm terminates.
3. What is the purpose of a stack in implementing a recursive procedure? Explain.
4. What is the need for using circular array to implement queues?
5. Give the tree T, find the inorder and postorder traversals.
6. Discuss the basis of the Buddy system of allocation. What type of fragmentation
still exists?
7. Discuss the timing analysis of the heap-sort algorithm.
8. What are the two broad classes of collision resolution techniques? Explain.
9. With an example explain the Huffman encoding scheme.
10. Explain how the size of a hashing table could be decreased when using (a) linear
hashing, (b) dynamic hashing.
PART – B
(5 x 16 = 80 Marks)
11. i) Implement typical stack operation when stacks are represented using (1) arrays
and (ii) using singly linked lists. (8 Marks)
ii) Define a binary tree. (2 Marks)
iii) Give the iterative algorithm for the inorder traversal of a binary tree. (6 Marks)
12a. i) Design a string manipulation algorithm for duplicating a given character string N
times. (6 Marks)
ii) Design an algorithm which trims off all the trailing blanks of a character string.
(5 Marks)
iii) Give a procedure that uses a stack in order to reverse the elements of a circular
queue which is stored in an array. (5 Marks)(OR)
12b. i) Given as input a word form assigned to the variable WORD, derive function
ORD-SEARCH which searches the ordered array of words looking for the word
form. If the word form is present, its index location is returned, else zero is
returned. Any search procedure can be used. (6 Marks)
ii) Assume we have a priority queue split into several queues.
To access these queues we have vectors of pointers to the front and rear of each
queue and one to indicate the length of each.
Thus to access the front of the queue representing priority 2, one merely starts at
PRIORITY_F[2]. This representation allows each queue to be of different length.
Given this representation, devise algorithms to insert and delete from a priority
queue. (10 Marks)
13a. i) Give an algorithm to reverse the elements of a single linked lists without using a
temporary list. (6 Marks)
ii) Write algorithms to insert into and delete elements from a doubly linked list.
(6 Marks)
iii) Write an algorithms to count the number of nodes in a given singly linked list.
(4 Marks)(OR)
13b. i) Write algorithms to allocate and free nodes in a body system of memory
allocation. (10 Marks)
ii) Write an algorithm to add two polynomials when the polynomials are represented
using singly linked lists. (6 Marks)
14a. i) Give the best case and worst case analysis of the binary search. (8 Marks)
ii) Write any one external sorting algorithm in detail. (8 Marks(OR)
14b. i) Write an algorithm to delete a node from a binary search tree. (8 Marks)
ii) Give the radix sort algorithm in detail. (8 Marks)
15a. i) Give in detail the structure of a typical Indexed Sequential file. (8 Marks)
ii) Describe the direct file organization and give the procedure to retrieve a record
from a direct file given the key. (8 Marks)(OR)
15b. Write notes on:-
i. Garbage compaction (6 Marks)
ii. VASM Files (5 Marks)
iii. Virtual Hashing (5 Marks)
Subject: Data Structures Sub Code: CS 35


Part- I
1. With examples, explain different storage classes used in C.

2. Write a note on enumeration data type.

3. Write the prefix & postfix form of the following .
1. (( A + B ) * C – ( D – E ) $ ( F+a)
2. (A + B) * (C + D -E) * F

4. Show that the detailed contents of the stack for given postfix examples. 623 + -
382 / + * 2 $ 3 +

5. Write a note on Preprocessor directives.

6. Why MACROS are needed. Explain with examples.

7. Differentiate between Structure & Unions members.

8. What is the significance of dynamic memory allocation.Explain C function that
support Dynamic allocation.

10. Write the dynamic representation of stack? For such a representations. Write the
Push & Pop routines.

11. Write the algorithm to find the maximum & minimum values singly linked list.

12. Write the algorithm to delete all the occurrences of a given value from the list.

13. List the different types of linked list & give their definitions in C.

14. Write an algorithm to count the number of nodes in a singly linked list.

15. Write an algorithm to reverse the linked list without creating new nodes.

16. Write an algorithm to append an element to the end of a list.

17.What is the advantage of Queue representing as List? For such representation
write the insertion and deletion procedure.

18.Show that output of the following assuming a = 4, b = 3, c = 10
1. d = a & b
2. d = a / b
3. d = a ^ b
4. d = a >>2
5. d = a<< 2


Part-B

1. What is Priority Queue? Explain the different methods of implementing Priority
queue & comment on the efficiency on each method.

2. What are the advantages of a doubly linked list over a singly linked list? Write a
program that inserts a given value in to an ordered doubly linked list in to its proper
positions.
3. Write a C programme to implement Circular singly linked list.

4. Write a C programme using dynamic variables & pointers to construct a singly
linked list, consisting of following information.
1. Student ID.
2. Student Name.
3. Semester.
The operations to be supported are
1. Inserting at the front
2. At the end.
3. At any position.
4. Display all the nodes in the list.

5. Write a C programme using dynamic variables & pointers to construct a singly
linked list, consisting of following information.
1. Student ID.
2. Student Name.
3. Semester.
The operations to be supported are Deleting a node based on student ID.If the
specified node is not present in the list; an error message should be displayed. Both
options should be demonstrated.

6. Write a C programme using dynamic variables & pointers to construct a singly
linked list,consisting of following information.
1. Student ID.
2. Student Name.
3. Semester.
The operations to be supported are 1. Searching a node based on student ID &
updates the information content. If the specified node is not present in the list an
error message should be displayed. Both options should be displayed.

7. Write a C programme using dynamic variables & pointers to construct

8. What is a Linked list? Compare static & dynamic implementation of linked list in C.

9. How can an ordinary Queue is represented using a singly linked list ? Give
algorithms for insertions as well as deleting elements in to a singly linked list ?

10. What are different methods to represent a binary tree and compare them?

11. Given a binary tree implement the following.
1. To compute its maximum depth.
2. To Print the nodes in ascending order assuming that the tree is a BST.
3. To count the number of nodes in a binary tree.

12. Give an algorithm for constructing a binary search tree. While constructing the
tree take care that duplicate values are not added. Trace the algorithm on
8,13,10,12,6,9,5,2.

13. Wrtie an algorithms for implementing the following:
1. To concatinate two linked list.
2. Delete the first occurrence of value X from a doubly linked list.
3. Delete all the occurrence of given value from DLL.

14. What are the advantages & disadvantages of a doubly linked list over a singly
linked list .

15. What is meant by tree traversal. Explain the different traversal techniques.
16. What are different schemes of representing a binary tree.

17. Define the following terms.
1. Strictly binary tree.
2. Complete binary tree.
3. Depth of a tree.
4. Binary search tree.
5. Almost complete binary tree.

18. What is meant by threaded binary tree? Explain the impact of such a
representation on the tree traversal procedure.

19. Write a program to insert a given value into an ordered singly linked list into its
proper position.

20. What is header node? Write a program to implement the circular singly linked
list. Perform insertion, deletion and display routines.

21. Construct a binary search tree for the following
1. 80,40,75,30,20,90,50
2. 100,50,200,25,90,80,150,300,180.

22. Construct the binary tree given the following traversals.
Pre-order : A B D G H C E I F
In-order: G D H B A E I C F

23. What is Structure? How is it different from an array? Expain the methods of
initiating the structre members with an illustrative example.

24. Distinguish between the following:
1. (*m) [5] and * m[5]
2. int ( * ptr ) and int * ptr( )

25. Develop a C program to write data of employees into a file. Each employee is a
structure with the following members: Char name[10], float salary, int id, char desig
[10]. Further read from the file and display it on the console.



26. What is stack? Indicate how stack is represented in C.

27. Write an algorithm for converting fix expression for postfix expression. Further
trace the above algorithm clearly indicating the contents of the stack for the
following expressions:
(( A – ( B + C )) * D ) $ ( E + F )


28. What is recursion? Comment on the efficiency of recursive routines.

29. Write a recursive C function to find the sum of all the elements in an array with N
integer values.

30. With an illustrative example, show a queue can be structured as a circular list.

31. Explain the working of radix sort on a suitable data set and comment on its
efficiency.

32. What is hashing? Explain various methods for resolving hash collisions.
33. What are bit fields? Summarize the rules for defining and using bit fields with
suitable examples. Consider the following:

Struct
{

int count;

float *p;

s [20], *ptr = s;

write the impact of the following statements.
1. ++ ptr -> count;
2. *ptr -> p ++;
3. ( * ptr -> p ))++;
4. *ptr ++ ->;
5. ( ++ptr ) -> count;

34. What is a circular Queue ? Write the implementation of circular queues using
arrays,& also write the routines to perform insertion,deletion & display on it.

35. What is a Union ? With an example explain the declartion & accessing of union
members.

36. Write a syntax & purpose of the following library functions:
1. fopen
2. fseek
3. ftell
4. rewind
5. fscanf

Más contenido relacionado

La actualidad más candente

Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler DesignAkhil Kaushik
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST Kathirvel Ayyaswamy
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IMohamed Loey
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and boundAbhishek Singh
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in CompilersMahbubur Rahman
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solvingPrabhakaran V M
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 

La actualidad más candente (20)

Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
single linked list
single linked listsingle linked list
single linked list
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Master theorem
Master theoremMaster theorem
Master theorem
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms I
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
Yacc
YaccYacc
Yacc
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 

Similar a Data structures question paper anna university

Ds important questions
Ds important questionsDs important questions
Ds important questionsLavanyaJ28
 
17432 object oriented programming
17432   object oriented programming17432   object oriented programming
17432 object oriented programmingsoni_nits
 
Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002SANTOSH RATH
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.organnaunivedu
 
Cs6660 compiler design may june 2017 answer key
Cs6660 compiler design may june 2017  answer keyCs6660 compiler design may june 2017  answer key
Cs6660 compiler design may june 2017 answer keyappasami
 
07 A1 Ec01 C Programming And Data Structures
07 A1 Ec01 C Programming And Data Structures07 A1 Ec01 C Programming And Data Structures
07 A1 Ec01 C Programming And Data Structuresguestac67362
 
Automata And Compiler Design
Automata And Compiler DesignAutomata And Compiler Design
Automata And Compiler Designguestac67362
 

Similar a Data structures question paper anna university (20)

Paper
PaperPaper
Paper
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
2013-June: 5th Semester CSE / ISE Question Papers
2013-June: 5th  Semester CSE / ISE Question Papers2013-June: 5th  Semester CSE / ISE Question Papers
2013-June: 5th Semester CSE / ISE Question Papers
 
5th Semester CS / IS (2013-June) Question Papers
5th Semester CS / IS (2013-June) Question Papers5th Semester CS / IS (2013-June) Question Papers
5th Semester CS / IS (2013-June) Question Papers
 
17432 object oriented programming
17432   object oriented programming17432   object oriented programming
17432 object oriented programming
 
C g.2010 supply
C g.2010 supplyC g.2010 supply
C g.2010 supply
 
Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002
 
Pcd201516
Pcd201516Pcd201516
Pcd201516
 
Oops qb cse
Oops qb cseOops qb cse
Oops qb cse
 
5th semester Computer Science and Information Science Engg (2013 December) Qu...
5th semester Computer Science and Information Science Engg (2013 December) Qu...5th semester Computer Science and Information Science Engg (2013 December) Qu...
5th semester Computer Science and Information Science Engg (2013 December) Qu...
 
Ads
AdsAds
Ads
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
 
Cs6660 compiler design may june 2017 answer key
Cs6660 compiler design may june 2017  answer keyCs6660 compiler design may june 2017  answer key
Cs6660 compiler design may june 2017 answer key
 
07 A1 Ec01 C Programming And Data Structures
07 A1 Ec01 C Programming And Data Structures07 A1 Ec01 C Programming And Data Structures
07 A1 Ec01 C Programming And Data Structures
 
7th Semester (June; July-2015) Computer Science and Information Science Engin...
7th Semester (June; July-2015) Computer Science and Information Science Engin...7th Semester (June; July-2015) Computer Science and Information Science Engin...
7th Semester (June; July-2015) Computer Science and Information Science Engin...
 
Automata And Compiler Design
Automata And Compiler DesignAutomata And Compiler Design
Automata And Compiler Design
 
7th Semester Computer Science (2013-June) Question Papers
7th Semester Computer Science (2013-June) Question Papers7th Semester Computer Science (2013-June) Question Papers
7th Semester Computer Science (2013-June) Question Papers
 
7th cs june 2013
7th cs   june 20137th cs   june 2013
7th cs june 2013
 
2013-June: 7th Semester CSE Question Papers
2013-June: 7th  Semester CSE Question Papers2013-June: 7th  Semester CSE Question Papers
2013-June: 7th Semester CSE Question Papers
 
2nd Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...
2nd  Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...2nd  Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...
2nd Semester M Tech: Computer Science and Engineering (Jun-2016) Question Pa...
 

Último

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Data structures question paper anna university

  • 1. data structures question paper anna university. CS 1151 DATASTRUCTURES PART – A (10 * 2 = 20 Marks)/ Answer ALL questions 1. Define ADT. 2. How do you push and pop elements in a linked stack? 3. Prove that the number of odd degree vertices in a connected graph should be even. 4. Define NP hard and NP complete. 5. Define binary search tree. 6. List out and define the performance measures of an algorithm. 7. What is Recursion? Explain with an example. 8. List out the various techniques of hashing. 9. What is the worst case complexity of Quick sort? 10. State the algorithmic technique used in merge sort. PART B (5 * 16 = 80 Marks) 11.(a) Derive the best, average, worst case time complexity of a linear search. (b) (i) Develop an algorithm for binary search. Validate the algorithm with a suitable data set. (10) (ii) What is Top down approach? Explain. (6) 12. (a) Write ADT operations for array implementation of polynomial addition. (b) Write ADT operations for array implementation of a queue. 13. (a) Write insertion algorithm for AVL tree. Write suitable rotation algorithms. (b) (i) Explain the algorithm for separate chaining. ( 8 ) (ii) Explain implementation of priority queue ( 8 ) 14. (a) Write ADT operations for heap sort. Using the above algorithm sort the following: 35 45 25 11 6 85 17 35 (b) (i) Explain the quick sort algorithm. ( 8 ) (ii) Explain external sorting. Give relevant example. ( 8 )15. (a) Explain Dijkstra’s algorithm using the following graph. Find the shortest path between v1, v2, v3, v4, v6 and v7. [Diagram not available] (b) (i) Write ADT operation for Prim’s algorithm. ( 8 ) (ii) Explain the topological sort algorithm. ( 8 ) 1. What do you mean by sorting? Mention the di erent types of sorting, give some examples and explain any one indetail. [16 marks] 2. Compare the advantage and disadvantage of bubble, insertion and selection sort. 3. Write a program to sort the elements whose worst and average case are O(n log n). [16 marks]
  • 2. 4. Write a program to explain selection sort . Which type of technique does it belong. [16 marks] 5. Write a program to explain selection sort . Which type of technique does it belong. [16 marks] 6. Write a program to sort the elements whose worst case is O(n2) and average case is O(n log n). [16 marks] 7. (a) Explain selection sort indetail. (b) Explain bubble sort indetail. [8+8] 8. Write an algorithm for routine merge(x,lb1,ub1,ub2) that assumes that x[lb1] through x[ub1] and x[ub1 + 1] through x[ub2] are sorted and merges the two into x[lb1] through x[ub2]. [16 marks] 9. (a) Explain Quick sort with algorithm. (b) Analyse the worst case performance of Quick sort and compare with Selection sort.[8+8 marks] 10. (a) Write a C program to sort the elements of an array using Quick sort with suitable example. (b) What is the worst case and best case time complexity of the above program? 11. Write an algorithm for quick sort. What is its time complexity. [16 marks] 12. (a) Write an algorithm for selection sort (b) Sort the following numbers using selection sort and give the required steps. 96,31,27,42,34,76,61,10,4 [8+8] 13. (a) Using linear search delete the number 26 from the list of numbers and give the steps. 10,7,17,26,32,92 (b) Write a C program to implement the same. [8+8 marks] 14. (a) Distinguish between linear and binary search methods. (b) Write an algorithm for non-recursive binary search method. [8+8 marks] 15. (a) Write a C program to sort the elements of an array using bubble sort technique with a suitable example. (b) What is the worst case and best case time complexity of bubble sort? [10+6 marks] 16. (a) Write a C program to sort given integers using partition exchange sort. (b) Derive the time complexity of partition exchange sort. [8+8] 17. Write a C program that searches a value in a stored array using binary search. What is the time complexity of binary search? [16 marks] 18. (a) Write a C program to merge two sorted arrays of integers. (b) Derive the time complexity of merge sort. [8+8 marks] 19. (a) Write and explain non-recursive algorithm for binary search with suitable example and discuss the various time complexities of binary search. (b) Suppose that the list contains the integers 1,2,8 in this order. Trace through the steps of binary search to determine what comparisons of keys are done in searching. i. To lo cate 3 ii. To lo cate 4.5 [8+8 marks] 20. Trace through the steps by hand to sort the following list in Quick sort. 28 7 39 3 63 13 61 17 50 21 [16 marks] 21. What are the advantages and disadvantages of stack ? Write a program to illustrate stack operation ? [16 marks] 22. Give an algorithm / C program to reverse a singly linked circular list inplace. [16 marks] 23. What are the advantages and disadvantages of stack ? Write a program to illustrate queue operation ? [16 marks]
  • 3. 24. Compare singly and doubly linked list to perform insertion operation . [16 marks] 25. Write a program to illustrate the various operations of singly linked list . [16 marks] 26. Write a program to delete a node in singly and doubly linked list . [16 marks] 27. Write a C program using pointers to implement Queue with all operation. [16 marks] 28. Write a routine to concatenate two singly linked lists. [16 marks] 29. What is a stack? Explain two di erent representations of a stack. List the operations performed on a stack and write functions for implementing these operations.[16 marks] 30. (a) Write a 'C' Program to convert an infix expression into prefix expression (b) Transform the following expression to prefix, using the approach (A + B) * (C$(D - E) + F) - G [8+8 marks] 31. (a) Mention and explain various types of queues and give an example for each (b) Compare various types of queues. [8+8 marks] 32. Write an algorithm to perform each of the following operations to a linked list. (a) Return the sum of the integers in a list. (b) Return the number of elements in a list. [8+8 marks] 33. Design insertion and deletion algorithms for a doubly linked circular lists. [16 marks] 34. (a) Derive a method to convert a postfix expression into its prefix form (b) Consider the following arithmetic expression in postfix notation: 7 5 2 + * 4 1 5 - / - i. Find the equivalent prefix form of the above . ii. Obtain the computed value of the expression from its postfix notation.[8+4+4 marks] 35. (a) What is a network? (b) What is a spanning tree? (c) Define minimal spanning tree . (d) What are the various traversals in a tree? [16 marks] 36. Write an algorithm to perform deletion operation in a Binary Search Tree. [16 marks] 37. (a) Define multi graph and graph with self- loop . (b) Explain connected graph with example. [8+8 marks] 38. Explain Kruskal's method of determining the minimal spanning tree. [16 marks] 39. (a) Write a program to swap nodes in a binary tree. (b) Write a program to find min and max nodes in a binary tree. [8+8 marks] 40. Explain binary search tree operations indetail. [16 marks] 41. Explain non-recursive and recursive algorithm for converse in order traversal of binary tree. [16 marks] 42. Write a C program for creating, inserting and deletion in a Binary tree. [16 marks] 43. (a) Describe di erent types of trees. (b) Write a C program to implement Binary tree. [6+10 marks] 44. (a) List and explain about the basic operations on a graph. (b) Write a C program for depth first search of a graph. [7+9 marks] 45. Write a C program for creating, inserting and deletion in a Binary tree. [16 marks] 46. (a) Write C function for minimum spanning tree of a weighted undirected graph (b) Write a C program to implement depth first traversal of graph. [10+6 marks] 47. (a) List and explain about the basic operations on a graph. (b) Write a C program for depth first search of a graph. [7+9 marks] 48. Write and explain the breath first traversal and depth first traversal in a graph with algorithm. [8+8 marks] 49. Write in detail about the following: (a) Depth first search of a graph (b) Minimum spanning trees [8+8 marks] 50. (a) Define graph. Explain the properties of a graph. (b) What is the di erence between strongly connected graph and weakly connected graph? [8+8 marks]
  • 4. Time : Three hours Maximum : 100 marks Answer ALL questions. PART A — (10 ? 2 = 20 marks) 1. Define data structure and storage structure. 2. What is iteration? Give example. 3. What are primitive data types? 4. Compare the following statement : Break and Continue. 5. Differentiate singly linked list and circularly linked list. 6. Define stack. 7. What is hashing function? 8. Define single rotation on AVL tree. 9. Define direct access in a file. 10. What is the difference between binary tree and binary search tree? PART B — (5 ? 16 = 80 marks) 11. (i) Write an algorithm for binary searching with example. Analyze the time requirement of the algorithm. (11) (ii) Explain the structure of indexed sequential files. (5) 12. (a) (i) Explain in detail about top–down approach and bottom–up approach with suitable programming examples. (10) (ii) Discuss about sequence selection iteration with examples. (6) Or (b) (i) What is recursion? Give the application of recursion with programs. (10) (ii) What are the features of structured programming methodologies? Explain. (6) 13. (a) (i) What are the I/O statements used in ‘C’? Explain with examples. (8) (ii) Write a program to compute the sum of the digits in a number and also to reverse the digits. (8) Or (b) (i) Discuss various control functions used in C. (8) (ii) Solve the following equations for and using C language : (8) 14. (a) (i) What are the various stack operations? Explain. (6) (ii) What are the various queue operations? Explain. (5) (iii) Explain the application of stack for conversion of infix to postfix. (5) Or (b) (i) What are the advantages and disadvantages of doubly linked list over singly linked list? Explain the application of doubly linked list. (9) (ii) Implement any two operations on circular linked list. (7) 15. (a) (i) Give a binary tree representation of the expression . (3) (ii) What are the various tree traversal methods? Explain. (9) (iii) Write an algorithm to convert general tree to binary tree. (4) Or (b) (i) List out the application of binary tree and explain. (6) (ii) Describe various hashing techniques. (10)
  • 5. PART A-(10 X 2=20 marks) 1.When will you say an algorithm efficient? Give the notations for time complexity. 2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify your answer. 3.Why is linked list used for polynomial arithmetic? 4.Write the role of stack in function call. 5.What is the minimum number of nodes in an AVL tree of height 5? 6.What is the use of sentinel value in binary heap? 7.Which is the best way of choosing the pivot element in quick sort? 8.Merge sort is better than insertion sort. Why? 9.Define a graph. How it differs from tree? 10.What is minimum spanning tree? Name any two algorithms used to find MST. PART B-(5 X 16=80 marks) 11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 using basic operations. (ii).Write the routines for inserting and deleting elements from a queue. Check for the conditions Q-empty and Q-full. 11.(b).(i).How would you implement a stack of queues? Write routines for creation and inserting of elements into it. (ii).Write routines to insert heterogeneous data into the list. 12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree. (ii).A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a binary tree. 12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree. (ii).Write the procedure to implement single and double rotations while inserting nodes in an AVL tree. 13.(a).Explain with suitable examples the basic heap operations and algorithms for the same. 13.(b).How will you resolve the collisions, while inserting elements into the hash table using separate chaining and linear probing? Write the routines for inserting, searching and removing elements from the hash table using the above mentioned techniques. 14.(a).(i).Write the routine for sorting n elements in increasing order using heap sort. (ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort. 14.(b).(i).Explain with example about the insertion sort. (ii).What is external sorting? Discuss the algorithms with proper examples. 15.(a).(i).Discuss and write the program to perform topological sorting. (ii).What is single source shortest path problem? Discuss Dijikstra’s single source shortest path algorithm with an example. 15.(b).(i).Write an algorithm to find the minimum cost spanning tree of an undirected, weighted graph. (ii).Find the MST for the following graph.
  • 6. Data Strucutre Questions 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. 2. List out the areas in which data structures are applied extensively? • Compiler Design, • Operating System, • Database Management System, • Statistical analysis package, • Numerical Analysis, • Graphics, • Artificial Intelligence, • Simulation 3. What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model. • RDBMS – Array (i.e. Array of structures) • Network data model – Graph • Hierarchical data model – Trees 4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type. 5. Minimum number of queues needed to implement the priority queue? Two. One queue is used for actual storing of data and another for storing priorities.
  • 7. CS 1151-DATA STRUCTURES Answer all the questions: PART A-(10 X 2=20 marks) 1.When will you say an algorithm efficient? Give the notations for time complexity. 2.What is a ‘top-down’ design? Is ‘C’ language a top down design? Justify your answer. 3.Why is linked list used for polynomial arithmetic? 4.Write the role of stack in function call. 5.What is the minimum number of nodes in an AVL tree of height 5? 6.What is the use of sentinel value in binary heap? 7.Which is the best way of choosing the pivot element in quick sort? 8.Merge sort is better than insertion sort. Why? 9.Define a graph. How it differs from tree? 10.What is minimum spanning tree? Name any two algorithms used to find MST. PART B-(5 X 16=80 marks) 11.(a).(i).Given two lists L1 and L2, write the routines to compute L1 n L2 using basic operations. (ii).Write the routines for inserting and deleting elements from a queue. Check for the conditions Q-empty and Q-full.(Or) 11.(b).(i).How would you implement a stack of queues? Write routines for creation and inserting of elements into it. (ii).Write routines to insert heterogeneous data into the list. 12.(a).(i).Write the routines to insert and remove a node from Binary Search Tree. (ii).A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a binary tree.(Or) 12.(b).(i).Show the resulting of inserting 2,1,4,5,9,3,6,7 into an empty AVL tree. (ii).Write the procedure to implement single and double rotations while inserting nodes in an AVL tree. 13.(a).Explain with suitable examples the basic heap operations and algorithms for the same.(Or) 13.(b).How will you resolve the collisions, while inserting elements into the hash table using separate chaining and linear probing? Write the routines for inserting, searching and removing elements from the hash table using the above mentioned techniques. 14.(a).(i).Write the routine for sorting n elements in increasing order using heap sort. (ii).Sort 3,1,4,1,5,9,2,6 in decreasing order using heap sort.(Or) 14.(b).(i).Explain with example about the insertion sort. (ii).What is external sorting? Discuss the algorithms with proper examples. 15.(a).(i).Discuss and write the program to perform topological sorting. (ii).What is single source shortest path problem? Discuss Dijikstra’s single source shortest path algorithm with an example.(Or)
  • 8. 15.(b).(i).Write an algorithm to find the minimum cost spanning tree of an undirected, weighted graph. (ii).Find the MST for the following graph. 1. (a) Write an algorithm for stack operations. (10) (b) Explain applications of trees with suitable examples. (10) 2. (a) Explain Heap sort with suitable example. (10) (b) Write the algorithm for quick sort and explain with an example. (10) 3. (a) Explain the Greedy Algorithms. (10) (b) Write the Kruskal algorithm for a minimum spanning tree. (10) 4. (a) What is linear search, binary search ? Write algorithms for both and comment on the complexity. (15) (b) Write short notes on graph coloring. (5) 5. (a) Explain Strassen's matrix multiplication. (10) (b) Explain the travelling salesperson problem. (10) 6. (a) Explain Branch and Bound algorithm. (10) (b) Discuss code optimization techniques. (10) 7. (a) Discuss in detail on hashing with examples. (10) (b) Write an algorithm that will perform an insertion and deletion of a node in a singly linked list. (10) 8. (a) Describe Np - Hard scheduling problems. (10) (b) Describe Np - Hard code generation. (10) MODEL QUESTION PAPER B.E / B.Tech. Degree Examinations III Semester IF 246 DATA STRUCTURES AND ALGORITHMS PART – A (10 x 2 = 20 Marks) 1. Take a linear search algorithms and discuss best-case time analysis. 2. Explain the basic of the Markov algorithm and discuss two ways in which such an algorithm terminates. 3. What is the purpose of a stack in implementing a recursive procedure? Explain. 4. What is the need for using circular array to implement queues? 5. Give the tree T, find the inorder and postorder traversals. 6. Discuss the basis of the Buddy system of allocation. What type of fragmentation still exists? 7. Discuss the timing analysis of the heap-sort algorithm. 8. What are the two broad classes of collision resolution techniques? Explain. 9. With an example explain the Huffman encoding scheme. 10. Explain how the size of a hashing table could be decreased when using (a) linear hashing, (b) dynamic hashing.
  • 9. PART – B (5 x 16 = 80 Marks) 11. i) Implement typical stack operation when stacks are represented using (1) arrays and (ii) using singly linked lists. (8 Marks) ii) Define a binary tree. (2 Marks) iii) Give the iterative algorithm for the inorder traversal of a binary tree. (6 Marks) 12a. i) Design a string manipulation algorithm for duplicating a given character string N times. (6 Marks) ii) Design an algorithm which trims off all the trailing blanks of a character string. (5 Marks) iii) Give a procedure that uses a stack in order to reverse the elements of a circular queue which is stored in an array. (5 Marks)(OR) 12b. i) Given as input a word form assigned to the variable WORD, derive function ORD-SEARCH which searches the ordered array of words looking for the word form. If the word form is present, its index location is returned, else zero is returned. Any search procedure can be used. (6 Marks) ii) Assume we have a priority queue split into several queues. To access these queues we have vectors of pointers to the front and rear of each queue and one to indicate the length of each. Thus to access the front of the queue representing priority 2, one merely starts at PRIORITY_F[2]. This representation allows each queue to be of different length. Given this representation, devise algorithms to insert and delete from a priority queue. (10 Marks) 13a. i) Give an algorithm to reverse the elements of a single linked lists without using a temporary list. (6 Marks) ii) Write algorithms to insert into and delete elements from a doubly linked list. (6 Marks) iii) Write an algorithms to count the number of nodes in a given singly linked list. (4 Marks)(OR) 13b. i) Write algorithms to allocate and free nodes in a body system of memory allocation. (10 Marks) ii) Write an algorithm to add two polynomials when the polynomials are represented using singly linked lists. (6 Marks) 14a. i) Give the best case and worst case analysis of the binary search. (8 Marks) ii) Write any one external sorting algorithm in detail. (8 Marks(OR) 14b. i) Write an algorithm to delete a node from a binary search tree. (8 Marks) ii) Give the radix sort algorithm in detail. (8 Marks) 15a. i) Give in detail the structure of a typical Indexed Sequential file. (8 Marks) ii) Describe the direct file organization and give the procedure to retrieve a record from a direct file given the key. (8 Marks)(OR) 15b. Write notes on:- i. Garbage compaction (6 Marks) ii. VASM Files (5 Marks) iii. Virtual Hashing (5 Marks)
  • 10. Subject: Data Structures Sub Code: CS 35 Part- I 1. With examples, explain different storage classes used in C. 2. Write a note on enumeration data type. 3. Write the prefix & postfix form of the following . 1. (( A + B ) * C – ( D – E ) $ ( F+a) 2. (A + B) * (C + D -E) * F 4. Show that the detailed contents of the stack for given postfix examples. 623 + - 382 / + * 2 $ 3 + 5. Write a note on Preprocessor directives. 6. Why MACROS are needed. Explain with examples. 7. Differentiate between Structure & Unions members. 8. What is the significance of dynamic memory allocation.Explain C function that support Dynamic allocation. 10. Write the dynamic representation of stack? For such a representations. Write the Push & Pop routines. 11. Write the algorithm to find the maximum & minimum values singly linked list. 12. Write the algorithm to delete all the occurrences of a given value from the list. 13. List the different types of linked list & give their definitions in C. 14. Write an algorithm to count the number of nodes in a singly linked list. 15. Write an algorithm to reverse the linked list without creating new nodes. 16. Write an algorithm to append an element to the end of a list. 17.What is the advantage of Queue representing as List? For such representation write the insertion and deletion procedure. 18.Show that output of the following assuming a = 4, b = 3, c = 10 1. d = a & b 2. d = a / b 3. d = a ^ b 4. d = a >>2 5. d = a<< 2 Part-B 1. What is Priority Queue? Explain the different methods of implementing Priority queue & comment on the efficiency on each method. 2. What are the advantages of a doubly linked list over a singly linked list? Write a program that inserts a given value in to an ordered doubly linked list in to its proper positions.
  • 11. 3. Write a C programme to implement Circular singly linked list. 4. Write a C programme using dynamic variables & pointers to construct a singly linked list, consisting of following information. 1. Student ID. 2. Student Name. 3. Semester. The operations to be supported are 1. Inserting at the front 2. At the end. 3. At any position. 4. Display all the nodes in the list. 5. Write a C programme using dynamic variables & pointers to construct a singly linked list, consisting of following information. 1. Student ID. 2. Student Name. 3. Semester. The operations to be supported are Deleting a node based on student ID.If the specified node is not present in the list; an error message should be displayed. Both options should be demonstrated. 6. Write a C programme using dynamic variables & pointers to construct a singly linked list,consisting of following information. 1. Student ID. 2. Student Name. 3. Semester. The operations to be supported are 1. Searching a node based on student ID & updates the information content. If the specified node is not present in the list an error message should be displayed. Both options should be displayed. 7. Write a C programme using dynamic variables & pointers to construct 8. What is a Linked list? Compare static & dynamic implementation of linked list in C. 9. How can an ordinary Queue is represented using a singly linked list ? Give algorithms for insertions as well as deleting elements in to a singly linked list ? 10. What are different methods to represent a binary tree and compare them? 11. Given a binary tree implement the following. 1. To compute its maximum depth. 2. To Print the nodes in ascending order assuming that the tree is a BST. 3. To count the number of nodes in a binary tree. 12. Give an algorithm for constructing a binary search tree. While constructing the tree take care that duplicate values are not added. Trace the algorithm on 8,13,10,12,6,9,5,2. 13. Wrtie an algorithms for implementing the following: 1. To concatinate two linked list. 2. Delete the first occurrence of value X from a doubly linked list. 3. Delete all the occurrence of given value from DLL. 14. What are the advantages & disadvantages of a doubly linked list over a singly linked list . 15. What is meant by tree traversal. Explain the different traversal techniques.
  • 12. 16. What are different schemes of representing a binary tree. 17. Define the following terms. 1. Strictly binary tree. 2. Complete binary tree. 3. Depth of a tree. 4. Binary search tree. 5. Almost complete binary tree. 18. What is meant by threaded binary tree? Explain the impact of such a representation on the tree traversal procedure. 19. Write a program to insert a given value into an ordered singly linked list into its proper position. 20. What is header node? Write a program to implement the circular singly linked list. Perform insertion, deletion and display routines. 21. Construct a binary search tree for the following 1. 80,40,75,30,20,90,50 2. 100,50,200,25,90,80,150,300,180. 22. Construct the binary tree given the following traversals. Pre-order : A B D G H C E I F In-order: G D H B A E I C F 23. What is Structure? How is it different from an array? Expain the methods of initiating the structre members with an illustrative example. 24. Distinguish between the following: 1. (*m) [5] and * m[5] 2. int ( * ptr ) and int * ptr( ) 25. Develop a C program to write data of employees into a file. Each employee is a structure with the following members: Char name[10], float salary, int id, char desig [10]. Further read from the file and display it on the console. 26. What is stack? Indicate how stack is represented in C. 27. Write an algorithm for converting fix expression for postfix expression. Further trace the above algorithm clearly indicating the contents of the stack for the following expressions: (( A – ( B + C )) * D ) $ ( E + F ) 28. What is recursion? Comment on the efficiency of recursive routines. 29. Write a recursive C function to find the sum of all the elements in an array with N integer values. 30. With an illustrative example, show a queue can be structured as a circular list. 31. Explain the working of radix sort on a suitable data set and comment on its efficiency. 32. What is hashing? Explain various methods for resolving hash collisions.
  • 13. 33. What are bit fields? Summarize the rules for defining and using bit fields with suitable examples. Consider the following: Struct { int count; float *p; s [20], *ptr = s; write the impact of the following statements. 1. ++ ptr -> count; 2. *ptr -> p ++; 3. ( * ptr -> p ))++; 4. *ptr ++ ->; 5. ( ++ptr ) -> count; 34. What is a circular Queue ? Write the implementation of circular queues using arrays,& also write the routines to perform insertion,deletion & display on it. 35. What is a Union ? With an example explain the declartion & accessing of union members. 36. Write a syntax & purpose of the following library functions: 1. fopen 2. fseek 3. ftell 4. rewind 5. fscanf