You are on page 1of 5

Data Structure Practical Questions

Arrays:
1. Consider two single dimensional Array of size 20 and 30 respectively.
Write a program in C to find out the elements which are common in
both arrays.

2. Write a program in C to find out whether a matrix is symmetric or not.

3. An array A contains 25 positive integers. Write a program in C which


will find out all pairs of elements whose sum is 30.

4. An array A contains 25 positive integers. Write a program in C which


will find out the number of odd and even numbers in that array.

5. Write a program in C which will input an integer array of various sizes


and compute the average value of elements in each array.

6. Write a program that determines the first occurrence of a given sub-


array within it.

7. Suppose an array contains n elements. Given a number x that may


occur several times in the array. Write a program to find

i. The number of occurrences of x in the array

ii. The position of first occurrence of x in the array.

8. Write a program that implements insertion sort for a linked list of


integers.

9. The name roll number and marks of 10 students are stored in an array
named marks. Write a program to find the Name of first, second and
third rank holder.

10. The mode of an array of numbers is the number m in the array that is
repeated most frequently. If more than one number is repeated with
same maximal frequencies, there is no mode. Write a program in C
that accepts an array of numbers and returns the mode or an
indication that the mode does not exist.

11. Write a program in C to delete duplicate elements from an array


of 20 integers.
12. Build array called chess to represent a chess board and write a
function that would be capable of displaying position of each coin in
the chess board.

13. A magic square of 5×5 contains different elements. Write a function to


verify whether the sum of each individual column elements, sum of
each individual row elements and sum of elements is equal or not.

Searching:
1. Twenty five numbers are entered from the keyboard into an array. The
number to be searched is entered through the keyboard by the user. WAP to
find if the number to be searched is present in the array and if it is present,
display the number of times it appears in the array.

Sorting:
1. Given are two one-dimensional arrays A and B which are stored in ascending order.
Write a program to merge them into a single sorted array C that contains every item from
arrays A and B, in ascending order.

Stacks:
1. Write a program in C to implement Stack using Array.

2. Write a program in C to implement Stack using Linked List.

3. Write a program in C using dynamic memory allocation by which stack


can be implemented.

4. Write a program in C using stack to determine GCD of given numbers.

5. Write a program in C using stack to determine LCM of given numbers.

6. Write a program in C using stack to determine nth element of a


Fibonacci series.

7. WAP to copy the content of one stack to another stack.

8. WAP to transform the following infix expression to postfix expression:

(A+B^D)*(D/E)
Queues:
1. Write a program in C to implement Queue using Array.

2. Write a program in C to implement Queue using Linked List.

3. Write a program in C using dynamic memory allocation by which queue


can be implemented.

4. Wap to keep track of patients as they check into a clinic, assigning


them to doctors on a first-come-first-serve basis.

Linked Lists:
1. Consider that a single linked list contains the following elements:

Roll number: Name: string of max Avg no:


integer, 25 char, float

Write a program in C to represent a single linked list with the above


elements.

2. Consider that a doubly linked list contains the following elements:

EMP number: Name: string of max Salary:


integer, 25 char, float

Write a program in C to represent a doubly linked list with the above


elements.

3. WAP that reads the name, age and salary of 10 persons and maintain
them in a linked list sorted by name.

4. There are two linked lists A and B containing the following data:

A: 3, 7,10,15,16,9,22,17,32

B: 16,2,9,13,47,8,10,1,28

WAP to create A linked list C that contains only those elements that are
common in linked list A and B.

WAP to create a linked list D which contains all elements of A as well as B


ensuring that there is no repetition of elements.

5. Assume a singly linked list containing integers. WAP function move()


which would move a node forward n position in the linked list.
6. There are two linked list A and B containing the following data:

A: 7,5,3,1,20

B: 6,25,32,11,9

Write a function to combine the two lists such that the resulting list
contains nodes in the following elements:

7,6,5,25,3,32,1,11,20,9

7. A linked list contains some positive numbers and some negative


numbers. Using this linked list write a program in C to create two more
linked lists, one containing all positive numbers and another containing
all negative numbers.

Trees:
1. Write a program in C to insert new nodes to a binary search tree and
delete a node from binary search tree.

2. Write a program in C and find the time complexity for pre-order


traversal of a binary tree.

3. Write a program in C and find the time complexity for post-order


traversal of a binary tree.

4. Write a program in C and find the time complexity for in-order traversal
of a binary tree.

5. Write a program in C that maintains a dictionary of words as a binary


tree.

6. Write a program in C to find the height of a binary tree.

7. Write a program in C that counts the number of nodes in a binary tree


and number of leaves in that tree.

8. Given any number, find whether that number is present in the binary
tree. If present then find the level at which it is present.

Files:
1. Write a program in C to append some text after the contents of a
simple text file “text.txt”.
2. Write a program in C for insertion and deletion records from a
sequential file.

You might also like