Data Structure module 1 (3) (1)
Data Structure module 1 (3) (1)
1. What is data structure? How are they classified? what are the various operations on data structures.
2. How do we allocate memory dynamically? Give code snippets for each of the dynamic memory
allocation functions.
4. What is pointer variable? How to declare and initialize a pointer variable. Write a program to swap two
5. Write a program to dynamically allocate memory for a one dimensional integer array
8. Define structure. Develop a structure to represent the countries in the world. Each country has fields for
the country’s name, its population, and the number of official languages spoken. Place items in each of
the fields for the countries: India and Canada. Write a program to read and print the details of the
countries
10. Write a program to dynamically allocate memory for a one dimensional (1D) integer array, and display
from 1 to 25, and the test scores are assigned in the 25X4 matrix called SCORE. Suppose Base
(SCORE) =200 w=4 and the programming language uses row-major order to store this 2D array, then
find the address of 3rd test of 12th student i.e. SCORE (12,3).
12. Write a C Program to Create 1D and 2D Arrays using dynamic memory Allocations. & also freeing the
memory. (OR) What is dynamically allocated arrays? Explain with suitable examples.
14. What is pointer variable? How to declare and initialize a pointer variable. Write a program to swap two
15. int a=8; int b=9; int *p=&a; int *q=&b; What is the value of each of the following expression? ++a, ++
16. Define structure. with example show to declare and initialize a structure
17. Write a structure definition to store the usn and name of students. Write a program to read and print the
details of n students
18. Give nested structure definition to store the following data of the employee (emp-name, emp_id, date of
19. Define Structures .Illustrate different ways of declaring structures with Example
21. Write appropriate structure definition and variable declarations to store following information about 50
students: Name, USN, GENDER, DOB and Marks in 3 subjects S1, S2, S3. Date of birth should be a
22. Develop a structure to represent the planets in the solar system. Each planet has fields for the planet’s
name, its distance from the sun (in miles), and the number of moons it has. Place items in each the fields
Marital status should be an enumerated type with fields: single, married, widowed, divorced. Use a
24. Define Union. with example show to declare and initialize a union
27. With a neat diagram show how the two polynomials, A(x)= 3x3 +5 and B(X)= 5x3 + 2x2 +4x+7 can be
stored in an array.
28. What is Sparse Matrix? Show with a suitable example sparse matrix representation storing as triples.
30. Give the triplet representation and the transpose for the sparse matrix given below. Write a function to
35. Define Stacks. Write the stack implementations for push and pop functions using arrays (using dynamic
doubling is used to increase the stack’s capacity (i.e. dynamically reallocate twice the memory)
whenever an element is added to full stack. Implement the operations push, pop and display.
37. Write a menu driven program in C for the following operations on STACK of integers,
38. Convert the following infix expressions to postfix manually and using a stack.
A+B*C
A+B C
(A+B)*(C D)
A$B*C D+E/F/(G+H)
A B/(C*D$E)
(a+b) * d - e / (f + a * d) +c
A/b–c+d*e–a*c
a+(b+c)+(b/d)*a+z*u