C PROGRAMMING AND DATA STRUCTURES Important Questions _________________________________________________________________________

UNIT –VI Linear DataStructures : Introduction to DataStructures, representing stacks and queues in C using arrays, Infix, Postfix and Prefix programs, circular queues

5. 5.

Write a routine reduce that accepts an infix string and forms an equivalent infix string with all superfluous parentheses removed. Write a recursive function that accepts a prefix expression consisting of binary operators and single-digit integer operands and returns the value of expression Write a program in C to convert a given infix expression into its postfix equivalent. Distinguish between sequential and linked allocation for representing linear lists.

4.a) b)

4. 5. 5. 5. 5. 7.

Write a C program that uses a stack to convert a given infix expression into its postfix form. Declare two stacks of varying length in a single array. Write C routines push1, push2, pop1 and pop2 to manipulate the two stacks. Declare two stacks of varying length in a single array. Write C routines push1, push2, pop1 and pop2 to manipulate the two stacks. Write a program to convert a given prefix expression to postfix expression using stacks. Write a program to convert a given postfix expression to prefix expression using stacks. Give the storage representation of following list using adjacency matrix and list structure a) (a,(b,(c,d)),e,f) b) ((x),y,A,z) where A= (a,b,(c,d))

_________________________________________________________________________

Computer Programming and Data structures

1

C PROGRAMMING AND DATA STRUCTURES Important Questions _________________________________________________________________________
UNIT – VII Linked Lists : Singly linked list, Doubly linked list, Circular List, representing stacks and Queues in C using linked lists Non-Linear Data Structures : Binary trees: Representation, tree traversals, graph representation, graph traversal, Spanning trees.

7. 6. 6. 6. 7. 6.

Explain the representation of graph using adjacency matrix. Give the necessary algorithm. Write a function in ‘C’ to form a list containing the union of the elements of two lists. Write a function in ‘C’ to form a list containing the intersection of the elements of two lists. Write a function in ‘C’ to insert an element after the nth element of a list Write and explain the breath first traversal and depth first traversal in a graph with algorithm How can a polynomial in three variables (x,y and z) be represented by a singly linked list? Each node should represent a term and should contain the powers of x, y, and z as well as coefficient of that term. Write a C program to add two such polynomials. Write notes on spanning tree. Write and explain the algorithm for minimal cost. Write C functions to perform the following operations: (i) insert an integer into deque (ii) delete an integer from deque. Write a recursive function in C to find the greatest common divisor of two given positive integers. Explain with a suitable example how a binary tree in threaded. Explain with an example how the deletion operation is performed on a binary search tree. Write a C function to copy a binary tree. Write notes on any TWO of the following: a) Collison resolution techniques in Hashing b) Spanning trees c) Traversals of a binary tree. Explain the different ways of representing the graphs in the memory. Write an algorithm (or C program) for breadth first search of a given graph. Distinguish between sequential and linked allocation for representing linear list. Write a C function to reverse a linked list with first node pointed to by list. Do not copy the list elements; rather, reset links and pointers so that list points to the last node and all links between nodes are reversed. Write a C Program to exchange two nodes of a singly linked list.

7. 3.a) b) 5.a) b) c) 8.

6.a) b) 3.a) b)

6.

_________________________________________________________________________

Computer Programming and Data structures

2

C PROGRAMMING AND DATA STRUCTURES Important Questions _________________________________________________________________________

6.

Represent a doubly linked list using an array. Write routines to inset and delete elements for this representation.

6.
6.a) b)

Write a routine to concatenate two doubly linked lists.
Write recursive functions in C for preorder and post order traversals of a binary tree. Explain with an example how an element is deleted from a binary search tree.

6.

Write a routine to concatenate two singly linked lists.

5. 6. 6. 7.

Write a program to evaluate a postfix expression using stack. Write a function in ‘C’ to combine two ordered lists in to a single ordered list. Write a function in ‘C’ to remove duplicate elements in a singly linked list. Write an algorithm for determining whether two binary trees A and B are similar based on the traversal method.

7.
7. 7.a) b) 7.

Formulate non-recursive and recursive algorithm for converse in order traversal of binary tree.
Formulate non-recursive and recursive algorithm for Postorder traversal of binary tree. Explain the different ways of representing graphs in memory. Write an algorithm for depth first search of a given graph. Formulate non-recursive and recursive algorithm for converse in order traversal of binary tree.

7.
6. 6.

Explain the preorder sequential representation and postorder sequential representation of a binary tree with example.
Write a C Program to exchange two nodes of a singly linked list. Write a function in ‘C’ for a singly linked list, which reverses the direction of links.

_________________________________________________________________________

Computer Programming and Data structures

3

C PROGRAMMING AND DATA STRUCTURES Important Questions _________________________________________________________________________

7.

Formulate non-recursive and recursive algorithm for converse in order traversal of binary tree. Formulate non-recursive and recursive algorithm for preorder traversal of binary tree.

7.

7.

Formulate non-recursive and recursive algorithm for preorder traversal of binary tree.
Write a recursive function in C to find the greatest common divisor of two integers. Write C functions for insertion and deletion operations for a queue implemented as a linked list. Declare deque of integers where left and right indicate two ends. Write routines remvleft, remvright, insrtleft, insrtright to remove and insert elements at left and right ends of deque.

5.a) b)

5.

5. Define input-restricted deque as deque in which insertion is restricted to one end and deletion can be made at either end. Write routines to implement operations on this deque. 5. Define output-restricted deque as deque in which deletion is restricted to one end and insertion can be made at either end. Write routines to implement operations on this deque.

5. 6. 7.

Write a routine REVERSEQ that will reverse all elements in a queue . Represent a circular linked list using an array. Write routines to insert and delete elements for this representation. Formulate non-recursive and recursive algorithm for Postorder traversal of binary tree.

_________________________________________________________________________

Computer Programming and Data structures

4

C PROGRAMMING AND DATA STRUCTURES Important Questions _________________________________________________________________________
UNIT – VIII Sorting & Searching : Searching Methods- Linear and binary search methods, Sorting methodsEx: Bubble sort, Selection sort, Insertion sort, heap sort, quick sort.

8. 8.a)

Explain heap sort with example. Write necessary algorithms. By hand, trace the action of heap sort on the following lists. Draw the initial tree to which the list corresponds. Show how it is converted into heap and show how the resulting heap as each entry is removed from the top and the new entry inserted. 12 20 34 27 30 36 23 Discuss the advantages and disadvantage of all sorting techniques with example. Trace through the steps by hand to sort the following list in Quick sort 28 7 39 3 63 13 61 17 50 21 Write a C function to create Heap for the given list of integers. Write a recursive function in C to search for an integer element in an array of sorted integers using binary search. Design an algorithm that will delete the entry with the largest key from the top of the heap and restore the heap properties of the resulting smaller list. Write insertion sort algorithm for sorting a given array of integers in ascending order. Write a recursive function in C to search for an integer in a given sorted array of integers using binary search. Explain the algorithm for exchange sort with a suitable example. Compare sort and exchange sort. Explain the algorithm for selection sort and give a suitable example. Write and explain linear search procedure with a suitable example. Formulate recursive algorithm for binary search with its timing analysis. Write and explain non-recursive algorithm for binary search with suitable example and discuss the various time complexities of binary search. 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 locate 3 (ii) to locate 4.5

b) 8. 8.a) b) 8. 7.a) b) 8.a) b) 8. 8.a) b) 8.a) b)

_________________________________________________________________________

Computer Programming and Data structures

5

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.