Posts

Showing posts from October, 2023

Programs to be practiced in the Lab

Image
 Programs to be practiced in the Lab. These programs will help u in your theory and practical exams. A) Write a C program to swap m and n element of single linked list. #include<stdio.h> #include<conio.h> struct list { int data; struct list *link; }*start=NULL; void creat(int); void swap(); void disp(); void main() { int ch,i,n,m; clrscr(); do { printf(“\n1.create”); printf(“\n2.display”); printf(“\n3.Swap”); printf(“\n4.exit”); printf(“\nenter ur choice”); scanf(“%d”,&ch); switch(ch) { case 1: printf(“\nHow many nodes”); scanf(“%d”,&n); for(i=0;i<n;i++) { printf(“\nEnter the data”); scanf(“%d”,&m); creat(m); } break; case 2: disp(); break; case 4: exit(0); case 3: swap(); break; } } while(ch!=4); getch(); } void creat(int m) { struct list *tmp,*q; tmp=(struct list *)malloc(sizeof(struct list)); tmp->data=m; tmp->link=NULL; if(start==NULL) start=tmp; else { q=start; while(q->link!...

Data Structure Practical Slips from 1 to 15

Data Structure Practical Slips SLIP 1  Q.1. Data Structure A) Write menu driven program using ‘C’ for Binary Search Tree. The menu includes - Create a Binary Search Tree - Insert element in a Binary Search Tree - Display [20 M] B) Write a ‘C’ program to evaluate a given polynomial using function. (Use array). [10 M] SLIP 2 Q.1. Data Structure A) Write a ‘C’ program to accept a string from user and reverse it using Static implementation of Stack. [20 M] B) Write a ‘C’ program to create Circularly Doubly Linked list and display it. [10 M] SLIP 3 Q.1. Data Structure A)Write a program to create two singly linked list of elements of type integer and find the union of the linked lists. (Accept elements in the sorted order) [20 M] B) Write a ‘C’ program to read the adjacency matrix of directed graph and convert it into adjacency list. [10 M] SLIP 4 Q.1. Data Structure A) Write menu driven program using ‘C’ for Binary Search Tree. The menu includes - Create a Binary Search Tree - Traverse ...

Solutions for Questions in Practical Slips from 1 to 5

                                                       Slip 1 A) Write menu driven program using ‘C’ for Binary Search Tree. The menu includes - Create a Binary Search Tree - Insert element in a Binary Search Tree - Display  #include <stdlib.h> #include<stdio.h> #include <string.h> typedef struct node { struct node *leftchild; int info; struct node *rightchild; } NODE; NODE * get_node(int val) { NODE *p; p = (NODE*)malloc(sizeof(NODE)); Name: Class: Roll No: p->info=val; p->leftchild = p->rightchild = NULL; return p; } NODE* insert(NODE *h, int key) { NODE *p,*q; q = get_node(key); if(h==NULL) h = q; else { p = h; while(1) { if(p->info>q->info) { if(p->leftchild==0) { p->leftchild = q; break; } else p=p->leftchild; } else { if(p->rightchild==0) { p->rightchild = q; brea...