DSA Lab Manual 2024-25
DSA Lab Manual 2024-25
Scheme: 2023
Prepared by:
Dr. Pooja Nayak S
Associate Professor
Mrs. Sridevi G M
Assistant Professor
Mrs. Kavyashree G M
Assistant Professor
1. Creating an academic environment to develop the younger generation and providing quality
professional engineering education at an affordable cost.
2. Create necessary infrastructure on a continuous basis the professional education with the
changing needs of society.
3. Optimum utilization of the infrastructure and resources to achieve excellence in the
engineering courses.
4. Monitor continuously the growth in technology parts of the world and address all aspects of
development of human resource (both from academic and supporting staff) and students to be in
tune with state of the art technology and engineering practices.
5. Facilitate greater Industry, Institute, and Interaction so as to empower the students with
practical knowledge.
6. Institute various quality assurance systems.
7. Adopting learning beyond curriculum process.
8. Initiate systems of learning which are based on enable students to acquire skills relevant to their
career.
9. To continuous monitor, asses evaluate the various academic programs adopting outcome-based
education.
7 Develop a program in C to create a Doubly Linked List (DLL) of Student data with
the fields: Name, USN, Sem, and CGPA supporting different operations and display 19
the status after each operation.
8 Implement a program in C to store ‘n’ integers in a Binary Search Tree (BST).
Search the BST for a given element (KEY) and display the number of accesses
24
required to find the key. Display the elements of the BST using inorder, preorder,
and postorder traversal.
9 Develop a C program to implement a road map for N Cities. Display the Depth-First
29
Search(DFS) and Breadth-First Search(BFS) traversals for the graph.
10 Develop a C program to store employee details (Employee ID: eid and Employee
Name: ename) into a hash table using a hash function H: K →L as H(K)=K mod m
32
(remainder method) where K is the Key(eid) and m is the Hash Table size.
Implement linear probing to resolve any collisions.
Open ended Programs
Consider two players - A and B. ‘N’ Pots of gold are arranged in a line, each containing some
gold coins. The players can see how many coins are in each gold pot, and each player gets turns
1 in which the player can pick the coins from a pot from either end of the line. The winner is the
player who has a higher number of coins at the end. Develop a program to solve the pots of gold
game problem.
You are given a set of n jobs where each has a deadline and profit associated with it. Each job
takes one unit of time to complete, and only one job can be scheduled at a time. We earn the
profit associated with the job if and only if the job is completed by its deadline. Find the job
scheduling of the given jobs that ensure maximum profit.
Input
2
Job id 1 2 3 4 5
deadline 2 1 2 1 3
profit 100 19 27 25 15
Implement Back/Forward Navigation such that choosing back should take the user to the
previous page and forward should take to the next page visited in the web browser.
CIE for Data Structures Laboratory (Integrated Professional Core Course (IPCC)):
This Course refers to Professional Theory Core Course Integrated with Practical Component Credit for this
course can be 03 and its Teaching Learning hours (L: T: P: PJ) can be considered as (2: 0: 2: 0).
Note: L- Theory Lecture, T- Tutorial, P-Practical, PJ-Project, CIE: Continuous Internal Evaluation, SEE:
Semester End Examination.
PROGRAM-1
Develop a C Program to store movie Data with the fields: Title, Genre, Actor, Actress, and
rating in an appropriate data structure.
#include<stdio.h>
struct movie
{
char title[15];
char genre[15];
char actor[15];
char actress[15];
float rating;
};
void main()
{
struct movie m[10];
int n,i;
printf("Enter number of movies: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter details for movie %d\n",i+1);
printf("Enter title:");
scanf("%s",m[i].title);
printf("Enter genre:");
scanf("%s",m[i].genre);
printf("Enter actor:");
scanf("%s",m[i].actor);
printf("Enter actress:");
scanf("%s",m[i].actress);
printf("Enter rating:");
scanf("%f",&m[i].rating);
printf("\n");
}
printf("The movie details are");
for(i=0;i<n;i++)
{
printf("Movie:%d\n Title:%s\n Genre:%s\n Actor:%s\n Actress:%s\n
Rating:%f\n",i+1,m[i].title,m[i].genre,m[i].actor,m[i].actress,m[i].rating);
printf("\n");
}
}
Sample Output:
enter number of movies: 2
Movie:2
Title:abcd2
Genre:dance
Actor:punith
Actress:shraddha
Rating:5.000000
PROGRAM-2
Given a mathematical expression exp, write a program to examine whether the parentheses
in the expression are balanced.
#include<stdio.h>
#define MAX 10
char stack[MAX];
int top=-1;
void push(char symbol)
{
top++;
stack[top]=symbol;
}
char check_balance(char symbol)
{
char popped;
if((stack[top]=='(' && symbol==')')||(stack[top]=='{' && symbol=='}')||(stack[top]=='['
&& symbol==']'))
{
popped= stack[top--];
return popped;
}
else
return '0';
}
void main()
{
char exp[15],sym;
int i;
printf(“Enter a mathematical Expression: ”);
scanf("%s", exp);
for(i=0; exp[i]!='\0';i++)
{
if(exp[i]=='{'|| exp[i]=='('|| exp[i]=='[')
push(exp[i]);
else if(exp[i]=='}'|| exp[i]==')'|| exp[i]==']')
{
sym=check_balance(exp[i]);
if(sym=='0')
break;
}
else;
}
if(top==-1 && sym!='0')
printf("Parentheses are balanced\n");
else
printf("Parentheses are not balanced\n");
}
Sample Output
Enter a mathematical Expression: ))(({}
Parentheses are not balanced
Enter a mathematical Expression: ({}[])
Parentheses are balanced
PROGRAM-3
Implement a program in C to convert an Infix Expression to a Postfix Expression. The
program should support both parenthesized and free parenthesized expressions with the
operators: +, -, *, /, % (Remainder), ^ (Power), and alphanumeric operands
#include <ctype.h>
#include <stdio.h>
#define SIZE 50
char s[SIZE];
int top = -1; /* Global declarations */
void push(char elem) /* Function for PUSH operation */
{
s[++top] = elem;
}
}
}
Solution 2:
#include<stdio.h>
#include<string.h>
case '+':
case '-': return 1;
case '*':
case '/': return 3;
case '^':
case '$': return 6;
case '(': return 9;
default: return 7;
}
}
}
while(s[top] != '#')
{
postfix[j++] = s[top--];
}
postfix[j] = '\0';
}
void main()
{
char infix[20],
postfix[20];
printf("\nEnter a valid infix expression\n");
gets(infix);
infix_postfix(infix,postfix);
printf("\nThe infix expression is:\n");
printf ("%s",infix);
printf("\nThe postfix expression is:\n");
printf ("%s",postfix);
}
Sample Output:
Enter a valid infix expression (a+(b-c)*d)
The infix expression is: (a+(b-c)*d)
The postfix expression is: abc-d*+
PROGRAM-4
}
}
void main()
{
double s[20], res, op1, op2;
int top, i;
char postfix[20], symbol;
printf("\nEnter the postfix expression:\n");
gets(postfix);
top=-1;
for(i=0; i<strlen(postfix); i++)
{
symbol = postfix[i];
if(isdigit(symbol))
}
}
res = s[top--];
Sample Output:
RUN1:
Enter the postfix expression: 23+
The result is: 5.000000
RUN2:
Enter the postfix expression: 23+7*
The result is: 35.000000
b. Assume we have three rods (A, B, and C) and N disks of different diameters. Initially, all
the disks are on rod A, so the smaller disk is always on top of the larger disk. The objective
of the puzzle is to move all the disks to another rod (here considered C), obeying the
following simple rules:
i. Only one disk can be moved at a time.
ii. Each move consists of taking the topmost disk from one of the rods and placing it on
top of another rod.
iii. No disk may be placed on top of a smaller disk.
#include<stdio.h>
void tower(int n, int source, int temp,int destination)
{
if(n == 0)
return;
tower(n-1, source, destination, temp);
printf("\nMove disc %d from %c to %c", n, source, destination);
tower(n-1, temp, source, destination);
}
void main()
{
int n;
printf("\nEnter the number of discs: \n");
scanf("%d", &n);
tower(n, 'A', 'B', 'C');
printf("\n\nTotal Number of moves are: %d", (int)pow(2,n)-1);
}
Sample Output:
Enter the number of discs: 3
Move disc 1 from A to C
Move disc 2 from A to B
Move disc 1 from C to B
Move disc 3 from A to C
Move disc 1 from B to A
Move disc 2 from B to C
Move disc 1 from A to C
Total Number of moves are: 7
PROGRAM-5
Develop a C program to simulate the working of a multi-player game.
i. Each player gets n turns.
ii. Each player rolls a die during his turn.
iii. The number rolled by the die is added for each player.
iv. At the end of n turns, the player with the maximum total wins.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX_PLAYERS 10 // You can change this to allow more players
// Function to roll a die and return a value between 1 and 6
int rollDie() {
return (rand() % 6) + 1;
}
int main() {
int players, turns;
printf("Enter the number of players: ");
scanf("%d", &players);
printf("Enter the number of turns for each player: ");
scanf("%d", &turns);
if (players > MAX_PLAYERS || players <= 0) {
printf("Number of players must be between 1 and %d.\n", MAX_PLAYERS);
return 1;
}
int scores[MAX_PLAYERS] = {0};
for (int i = 0; i < players; i++)
{
printf("\nPlayer %d's turns:\n", i + 1);
for (int j = 0; j < turns; j++)
{
int roll = rollDie();
printf("Turn %d: Rolled a %d\n", j + 1, roll);
scores[i] += roll;
}
printf("Total score for Player %d: %d\n", i + 1, scores[i]);
}
int maxScore = scores[0], winner = 0;
for (int i = 1; i < players; i++) {
if (scores[i] > maxScore) {
maxScore = scores[i];
winner = i;
}
}
printf("\nPlayer %d wins with a total score of %d!\n", winner + 1, maxScore);
return 0;
}
Sample Output:
Enter the number of players: 3
Enter the number of turns for each player: 3
Player 1's turns:
Turn 1: Rolled a 4
Turn 2: Rolled a 6
Turn 3: Rolled a 5
Total score for Player 1: 15
Turn 3: Rolled a 1
Total score for Player 2: 5
PROGRAM - 6
Develop a program in C to read a polynomial of the form anxn + an-1xn-1 +an-2xn-2 +
………… + a1x + a0 (Ex: 6x4+3x3+3x2+2x+1) using a Singly Linked List (SLL). Implement
functions to display and evaluate the polynomial by taking the value of ‘x’ from the user.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
}
temp = temp->next;
}
printf("\n");
}
int main() {
struct Node* poly = createPolynomial();
printf("\nThe polynomial is: ");
displayPolynomial(poly);
int x;
printf("\nEnter the value of x to evaluate the polynomial: ");
scanf("%d", &x);
int result = evaluatePolynomial(poly, x);
printf("\nThe result of the polynomial evaluation is: %d\n", result);
return 0;
}
Sample Output:
Enter the number of terms in the polynomial: 5
Enter coefficient and exponent for term 1: 6 4
Enter coefficient and exponent for term 2: 3 3
Enter coefficient and exponent for term 3: 3 2
Enter coefficient and exponent for term 4: 2 1
Enter coefficient and exponent for term 5: 1 0
PROGRAM-7
Develop a program in C to create a Doubly Linked List (DLL) of Student data with the
fields: Name, USN, Sem, and CGPA supporting different operations and display the status
after each operation.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define the structure for a student node
struct Student {
char name[50];
char usn[15];
int sem;
float cgpa;
struct Student* prev;
struct Student* next;
};
struct Student * first = NULL;
// Function to create a new student node
struct Student* createStudent( )
{
struct Student* newStudent = (struct Student*)malloc(sizeof(struct Student));
printf("Enter Name: ");
scanf("%s", newStudent->name);
printf("Enter USN: ");
scanf("%s", newStudent->usn);
printf("Enter Semester: ");
scanf("%d", & newStudent->sem);
printf("Enter CGPA: ");
scanf("%f", & newStudent->cgpa);
newStudent->prev = NULL;
newStudent->next = NULL;
return newStudent;
}
// Function to insert a student at the beginning of the list
void insertAtBeginning( ) {
struct Student* newStudent = createStudent( );
if (first == NULL)
{
first = newStudent;
}
else {
newStudent->next = first;
first->prev = newStudent;
first = newStudent;
}
}
// Function to insert a student at the end of the list
void insertAtEnd( )
{
struct Student* newStudent = createStudent();
if (first == NULL) {
first = newStudent;
} else {
struct Student* temp = first;
while (temp->next != NULL) {
temp = temp->next;
}
temp->next = newStudent;
newStudent->prev = temp;
}
}
// Function to delete a student node by USN
struct Student* deleteByUSN(char usn[]) {
if (first == NULL) {
printf("List is empty, nothing to delete.\n");
return;
}
struct Student* temp = first;
while (temp != NULL && strcmp(temp->usn, usn) != 0) {
temp = temp->next;
}
if (temp == NULL) {
printf("Student with USN %s not found.\n", usn);
return;
}
if (temp->prev != NULL)
temp->prev->next = temp->next;
else
first = temp->next; // If deleting the first node
if (temp->next != NULL)
temp->next->prev = temp->prev;
free(temp);
printf("Student with USN %s deleted.\n", usn);
}
// Function to display the list of students
void displayList()
{
if (first == NULL)
{
printf("The list is empty.\n");
return;
}
printf("\nStudent List:\n");
struct Student* temp = first;
while (temp != NULL) {
printf("Name: %s, USN: %s, Sem: %d, CGPA: %.2f\n", temp->name, temp->usn, temp-
>sem, temp->cgpa);
temp = temp->next;
}
}
int main() {
int choice, sem;
float cgpa;
char name[50], usn[15];
do {
printf("\nDoubly Linked List Operations:\n");
printf("1. Insert at Beginning\n");
printf("2. Insert at End\n");
printf("3. Delete by USN\n");
printf("4. Display List\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
insertAtBeginning( );
displayList( );
break;
case 2:
insertAtEnd( );
displayList( );
break;
case 3:
printf("Enter the USN of the student to delete: ");
scanf("%s", usn);
deleteByUSN(usn);
displayList();
break;
case 4:
displayList( );
break;
case 5:
printf("Exiting...\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
} while (choice != 5);
return 0;
}
Sample Output:
Doubly Linked List Operations:
1. Insert at Beginning
2. Insert at End
3. Delete by USN
4. Display List
5. Exit
Enter your choice: 1
Enter Name: kumar
Enter USN: 1DT23IS001
Enter Semester: 3
Enter CGPA: 9.0
Student List:
Name: kumar, USN: 1DT23IS001, Sem: 3, CGPA: 9.00
Student List:
Name: Vinay, USN: 1DT23IS002, Sem: 3, CGPA: 9.50
Name: kumar, USN: 1DT23IS001, Sem: 3, CGPA: 9.00
1. Insert at Beginning
2. Insert at End
3. Delete by USN
4. Display List
5. Exit
Enter your choice: 2
Enter Name: Kalyan
Enter USN: 1DT23IS003
Enter Semester: 3
Enter CGPA: 8.5
Student List:
Name: Vinay, USN: 1DT23IS002, Sem: 3, CGPA: 9.50
Name: kumar, USN: 1DT23IS001, Sem: 3, CGPA: 9.00
Name: Kalyan, USN: 1DT23IS003, Sem: 3, CGPA: 8.50
Student List:
Name: Sowmya, USN: 1DT23IS004, Sem: 3, CGPA: 7.50
Name: Vinay, USN: 1DT23IS002, Sem: 3, CGPA: 9.50
Name: kumar, USN: 1DT23IS001, Sem: 3, CGPA: 9.00
Name: Kalyan, USN: 1DT23IS003, Sem: 3, CGPA: 8.50
Name: Shyla, USN: 1DT23IS005, Sem: 3, CGPA: 7.20
Student List:
Name: Sowmya, USN: 1DT23IS004, Sem: 3, CGPA: 7.50
Name: Vinay, USN: 1DT23IS002, Sem: 3, CGPA: 9.50
Name: kumar, USN: 1DT23IS001, Sem: 3, CGPA: 9.00
Name: Kalyan, USN: 1DT23IS003, Sem: 3, CGPA: 8.50
Name: Shyla, USN: 1DT23IS005, Sem: 3, CGPA: 7.20
Student List:
Name: Sowmya, USN: 1DT23IS004, Sem: 3, CGPA: 7.50
Name: Vinay, USN: 1DT23IS002, Sem: 3, CGPA: 9.50
Name: Kalyan, USN: 1DT23IS003, Sem: 3, CGPA: 8.50
Name: Shyla, USN: 1DT23IS005, Sem: 3, CGPA: 7.20
3. Delete by USN
4. Display List
5. Exit
Enter your choice: 5
Exiting...
PROGRAM-8
Implement a program in C to store ‘n’ integers in a Binary Search Tree (BST). Search the
BST for a given element (KEY) and display the number of accesses required to find the
key. Display the elements of the BST using inorder, preorder, and postorder traversal.
#include <stdio.h>
#include <stdlib.h>
// Function to search a key in the BST and return the number of accesses
int searchBST(struct Node* root, int key, int* accesses) {
*accesses = 0;
struct Node* current = root;
while (current != NULL) {
(*accesses)++;
if (key == current->data) {
return 1; // Key found
}
if (key < current->data) {
current = current->left;
} else {
current = current->right;
}
}
return 0; // Key not found
}
}
}
int main() {
struct Node* root = NULL;
int n, i, element, key, accesses;
// Input: number of elements to insert into the BST
printf("Enter the number of elements to insert in the BST: ");
scanf("%d", &n);
// Inserting 'n' elements into the BST
for (i = 0; i < n; i++) {
printf("Enter element %d: ", i + 1);
scanf("%d", &element);
root = insertNode(root, element);
}
// Traversals of the BST
printf("\nInorder Traversal: ");
inorderTraversal(root);
printf("\nPreorder Traversal: ");
preorderTraversal(root);
printf("\nPostorder Traversal: ");
postorderTraversal(root);
// Search for a key in the BST
printf("\n\nEnter the key to search in the BST: ");
scanf("%d", &key);
if (searchBST(root, key, &accesses)) {
printf("Key found in %d accesses.\n", accesses);
} else {
printf("Key not found after %d accesses.\n", accesses);
}
return 0;
}
Sample Output:
Enter the number of elements to insert in the BST: 5
Enter element 1: 50
Enter element 2: 30
Enter element 3: 70
Enter element 4: 20
Enter element 5: 40
Inorder Traversal: 20 30 40 50 70
Preorder Traversal: 50 30 20 40 70
Postorder Traversal: 20 40 30 70 50
PROGRAM-9
Develop a C program to implement a road map for N Cities. Display the Depth-First
Search(DFS) and Breadth-First Search(BFS) traversals for the graph.
#include<stdio.h>
int a[10][10], n, m, i, j, source, s[10], vis[10], visited[10], count;
void create()
{
printf("\nEnter the number of vertices of the digraph: ");
scanf("%d", &n);
printf("\nEnter the adjacency matrix of the graph:\n");
for(i=1; i<=n; i++)
{
vis[i]=0;
visited[i]=0;
for(j=1; j<=n; j++)
scanf("%d", &a[i][j]);
}
}
void bfs()
{
int q[10], u, front=0, rear=-1;
{
u = q[front++];
for(i=1; i<=n; i++)
{
if(a[u][i] == 1 && visited[i] == 0)
{
q[++rear] = i;
visited[i] = 1; printf("\n%d", i);
}
}
}
}
void dfs(int i)
{
int j;
vis[i] = 1;
for(j=1; j<=n; j++)
if(a[i][j] == 1 && vis[j] == 0)
{
printf("\t %d",i);
dfs(j);
}
}
void main()
{
int ch;
while(1)
{
printf("\n1.Create\n2.BFS\n3.DFS\n4.Exit");
printf("\nEnter your choice: ");
scanf("%d", &ch);
switch(ch)
{
case 1: create();
break;
case 2: bfs();
break;
case 3: printf("\n Enter the source vertex: ");
scanf("%d", &source);
printf("\nThe reachable vertices are: ");
dfs(source);
break;
default: exit(0);
}
}
}
Sample Output:
1.Create
2.BFS
3.DFS
4.Exit
Enter your choice:1
Enter the number of vertices of the digraph: 5
Enter the adjacency matrix of the graph:
01001
00110
00000
00000
00000
1.Create
2.BFS
3.DFS
4.Exit
Enter your choice:2
Enter the source vertex:1
The reachable vertices are:
2 5 3 4
1.Create
2.BFS
3.DFS
4.Exit
Enter your choice:3
Enter the source vertex:1
The reachable vertices are:
2 3 4 5
PROGRAM-10
Develop a C program to store employee details (Employee ID: eid and Employee Name:
ename) into a hash table using a hash function H: K →L as H(K)=K mod m (remainder
method) where K is the Key(eid) and m is the Hash Table size. Implement linear probing to
resolve any collisions.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 3
struct employee
{
int flag;
int eid;
char ename[15];
};
if(emp[i].flag!= -1)
i=(i++)%M;
else
break;
}
if(i!=addr)
return i;
else
return -1;
}
void insert()
{
int id,addr;
char name[15];
printf("\nEnter emp id: ");
scanf("%d",&id);
printf("\nEnter emp name: ");
scanf("%s",name);
addr=hash(id);
printf("addr=%d",addr);
if(emp[addr].flag==-1)
{
emp[addr].eid=id;
emp[addr].flag=1;
strcpy(emp[addr].ename,name);
}
else
{
printf("\nCollision detected..");
addr=linear_prob(addr);
if(addr!=-1)
{
emp[addr].eid=id;
emp[addr].flag=1;
strcpy(emp[addr].ename,name);
}
else
{
printf("\nHash Table is full.. Cannot insert");
return;
}
}
}
void display()
{
int i;
printf("\nThe hash table is:\n");
printf("\nHTKey\tEmpID\tEmpName");
for(i=0;i<M;i++)
{
if(emp[i].flag!=-1)
{
printf("\n%d\t%d\t%s",i,emp[i].eid,emp[i].ename);
continue;
}
}
void main()
{
int i,ch;
SAMPLE OUTPUT:
Collision handling by linear probing Enter emp id: 3
1. Insert Enter emp name: jkl
2.Display addr=0
Collision detected..
VIVA QUESTIONS
1. What is a Register?
Ans- A register is a small amount of memory within the CPU that is used to temporarily store
instructions and data.
Ans-abstract
Integer, Floating-Type, Character & Boolean are the four different data type groups
Explanation: You determine the amount of memory to reserve by determining the appropriate
abstract data type group to use and then deciding which abstract data type within the group is
right for the data. The different abstract data type groups are Integer, Floating-Type,
Character & Boolean
4.Which of the following abstract data types are NOT used by Integer Abstract Data
type group?
A) Short
B) Int
C) float
D) long
Explanation: The integer abstract data type group consists of four abstract data types used to
reserve memory to store whole numbers: byte, short, int , and long
The answer is the void pointer. The heterogeneous linked list contains different data types in
it's nodes and we need a link, pointer, to connect them. Since we can't use ordinary pointers
for this, we use the void pointer. Void pointer is a generic pointer type, and capable of storing
pointer to any type.
6.What is the minimum number of queues needed to implement the priority queue?
Two. One queue is used for the actual storing of data, and the other one is used for storing the
priorities.
The answer is Stack. Stack has the LIFO (Last In First Out) property; it remembers it's
‘caller’. Therefore, it knows to whom it should return when the function has to return. On the
other hand, recursion makes use of the system stack for storing the return addresses of the
function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when
such equivalent iterative procedures are written explicit, stack is to be used.
8. What are some of the applications for the tree data structure?
9. Which data structures algorithm used in solving the eight Queens problem?
Backtracking
If the "pivotal value", or the "height factor", is greater than one or less than minus one.
11. There are 8, 15, 13, and 14 nodes in four different trees. Which one of them can form
a full binary tree?
The answer is the tree with 15 nodes. In general, there are 2^n-1 nodes in a full binary tree.
By the method of elimination:
Full binary trees contain odd number of nodes, so there cannot be full binary trees with 8 or
14 nodes. Moreover, with 13 nodes you can form a complete binary tree but not a full binary
tree. Thus, the correct answer is 15.
13. List out the areas in which data structures are applied extensively?
Answer: The names of areas are:
a. Compiler Design,
b. Operating System,
c. Database Management System,
d. Statistical analysis package,
e. Numerical Analysis,
f. Graphics,
g. Artificial Intelligence,
h. Simulation
14. What are the major data structures used in the following areas: RDBMS,
Network data model & Hierarchical data model.
The major data structures used are as follows:
a. RDBMS - Array (i.e. Array of structures)
b. Network data model - Graph
c. Hierarchical data model - Trees
d.
15. 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.
18. What are the notations used in Evaluation of Arithmetic Expressions using
prefix and postfix forms?
Polish and Reverse Polish notations.
20. How many null branches are there in a binary tree with 20 nodes?
Answer: 21
Let us take a tree with 5 nodes (n=5)
i ii iii iv v
In general:
If there are n nodes, there exist 2n-n different trees.
24. List out few of the applications that make use of Multilinked Structures?
Answer: The applications are listed below:
Sparse matrix,
Index generation.
26. What is the type of the algorithm used in solving the 8 Queens problem?
Answer: Backtracking
28. What is the bucket size, when the overlapping and collision occur at same time?
Answer: One. If there is only one entry possible in the bucket, when the collision occurs,
there is no way to accommodate the colliding value. This results in the overlapping of values.
29. Traverse the given tree using Inorder, Preorder and Postorder traversals.
Answer:
Inorder : D H B E A F C I G J
Preorder: A B D H E C F G I J
Postorder: H D E B F I J G C A
30. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could
have formed a full binary tree?
Answer: 15.
In general:
There are 2n-1 nodes in a full binary tree.
By the method of elimination:
Full binary trees contain odd number of nodes. So there cannot be full binary trees with 8 or
14 nodes, so rejected. With 13 nodes you can form a complete binary tree but not a full
binary tree. So the correct answer is 15.
31. In the given binary tree, using array you can store the node 4 at which location?
Answer: At location 6
1 2 3 - - 4 - - 5
where LCn means Left Child of node n and RCn means Right Child of node n