Posts

SLL, DLL, CLL Operations(class work)

 /*Syntax or Node structure of Single linked list*/ struct node { int data; struct node *link; }; struct node *root=NULL; (here root value intially NULL) /*Creating nodes in single linked list*/ void create() {  struct node *second,*third,*fourth,*fifth;  clrscr();  root=malloc(sizeof(struct node));  second=malloc(sizeof(struct node));  third=malloc(sizeof(struct node));  fourth=malloc(sizeof(struct node));  fifth=malloc(sizeof(struct node));  root->data=10;  second->data=20;  third->data=30;  fourth->data=40;  fifth->data=50;  root->link=second;  second->link=third;  third->link=fourth; fourth->link=fifth; fifth->link=NULL; } /*insert at an end in SLL*/ void append() { struct node *temp;     temp=(struct node*)malloc(sizeof(struct node));     printf("enter node data:");     scanf("%d",&temp->data);     temp->link=NULL;   ...

Circular Linked List Lab program

 #include <stdio.h> #include <stdlib.h> struct node {     int data;     struct node *link; }; struct node *root=NULL; void create() {  struct node *second,*third,*fourth,*fifth;  clrscr();  root=malloc(sizeof(struct node));  second=malloc(sizeof(struct node));  third=malloc(sizeof(struct node));  fourth=malloc(sizeof(struct node));  fifth=malloc(sizeof(struct node));  root->data=10;  second->data=20;  third->data=30;  fourth->data=40;  fifth->data=50;  root->link=second;  second->link=third;  third->link=fourth; fourth->link=fifth; fifth->link=root ; } void addFirst(int val) { struct node *temp=malloc(sizeof(struct node)); temp->data=val; if(root==NULL) { temp->link=temp; root=temp; } else { struct node *p; p=root; while(p->link!=root) { p=p->link; } p->link=temp; temp->link=root; root=temp; } } void addEnd(int val) { struct node...

Double Linked List lab program

 #include <stdio.h> #include <stdlib.h> struct node {     struct node *left;     int data;     struct node *right; }; struct node *root=NULL; void create() {  struct node *second,*third,*fourth,*fifth;  clrscr();  root=malloc(sizeof(struct node));  second=malloc(sizeof(struct node));  third=malloc(sizeof(struct node));  fourth=malloc(sizeof(struct node));  fifth=malloc(sizeof(struct node));  root->data=10;  second->data=20;  third->data=30;  fourth->data=40;  fifth->data=50; root->left=NULL; root->right=second; second->left=root; second->right=third; third->left=second; third->right=fourth; fourth->left=third; fourth->right=fifth; fifth->left=fourth; fifth->right=NULL; } void addFirst(int val) { struct node *temp=malloc(sizeof(struct node)); temp->data=val; if(root==NULL) { temp->left=NULL; temp->right=NULL; root=temp; } else { ...

Single linked List Lab program

 #include<stdio.h> #include<stdlib.h> struct node {     int data;     struct node *link; }; struct node *root=NULL; void create() {  struct node *second,*third,*fourth,*fifth;  clrscr();  root=malloc(sizeof(struct node));  second=malloc(sizeof(struct node));  third=malloc(sizeof(struct node));  fourth=malloc(sizeof(struct node));  fifth=malloc(sizeof(struct node));  root->data=10;  second->data=20;  third->data=30;  fourth->data=40;  fifth->data=50;  root->link=second;  second->link=third;  third->link=fourth; fourth->link=fifth; fifth->link=NULL; } void addFirst(int val) { struct node *temp=malloc(sizeof(struct node)); temp->data=val; temp->link=root; root=temp; printf("new node is inserted at beginning"); } void addEnd(int val) { struct node *temp=malloc(sizeof(struct node)); temp->data=val; temp->link=NULL; if(root==NULL) { root=tem...

Implementation of List using Arrays lab program

 #include<stdio.h> #include<conio.h> int n,a[20]; void create(); int insert(int,int); void display(); void find(int); int  del(int); void update(int,int); void count(); int main() { int choi,ele,pos,val; clrscr(); printf("enter no ele in list \n"); scanf("%d",&n); while(1) { clrscr(); printf("\t\t List Adt using arrays \n"); printf("1.create \n"); printf("2.insert \n"); printf("3.display \n"); printf("4.find \n"); printf("5.delete \n"); printf("6.update\n"); printf("7.count\n"); printf("8.exit \n"); printf("enter choice \n"); scanf("%d",&choi); switch(choi) { case 1:create(); break; case 2:printf("enter at what position u want to enter\n"); scanf("%d",&pos); printf("enter at value u want to insert\n"); scanf("%d",&val); n=insert(pos,val); break; case 3:display(); break; case 4:...

Data Structures UNIT-1 Chapter-1

Image
  Unit 1 Algorithm Analysis:- Algorithm Analysis : Introduction to Algorithm, Algorithm Analysis, Asymptotic Notations. Introduction to arrays and Abstract Data Type (ADT) Lists : List using arrays and linked list- Singly Linked List, Doubly Linked List, Circular Linked List. Introduction to Algorithm Algorithm Definition: - An algorithm is a set of instructions that are used to solve a problem. (Or) An algorithm is a Step By Step process to solve a problem, where each step indicates an intermediate task. Algorithm contains finite number of steps that leads to the solution of the problem. Properties/Characteristics of an algorithm:- Algorithm has the following basic properties 1. Input: - An algorithm has zero (0) or more inputs. 2. Output: - An algorithm must produce one (1) or more outputs. 3. Finiteness:- An algorithm must contain a finite/countable number of steps. 4. Definiteness: - Each step of an algorithm must be stated clearly and unambiguously. ...