Single Linked List and Postfix to Infix Conversion with C Programming, Exams of Data Structures and Algorithms

Solutions to three programming questions related to data structures. The first question involves generating an output using a single linked list, the second question deals with converting postfix to infix notation, and the third question is about writing a c program to generate a specific pattern. The program code and its corresponding output.

Typology: Exams

2017/2018

Uploaded on 10/20/2018

music-world-1
music-world-1 ๐Ÿ‡ฎ๐Ÿ‡ณ

4 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
INTRODUCTION
NAME :R.SURESH
REG NO :BU170509
DEPARTMENT :BS.C COMPUTER SCIENCE
SUBJECT :DATA STRUCTURE
SUBMIT TO :MR.M.SARLINRAJ
DATE :9/10/2018
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Single Linked List and Postfix to Infix Conversion with C Programming and more Exams Data Structures and Algorithms in PDF only on Docsity!

INTRODUCTION

NAME :R.SURESH

REG NO :BU1705 09

DEPARTMENT :BS.C COMPUTER SCIENCE

SUBJECT :DATA STRUCTURE

SUBMIT TO :MR.M.SARLINRAJ

DATE :9/10/

QUESTION NO:

GENERATE THE FOLLOWING OUTPUT USING SINGLE

LINKED LIST

Enter a number:

Want to continue[y/n]:y

Enter a number:

Want to continue[y/n]:y

Enter a number:

Want to continue[y/n]:n

The values of the linked list are:

PROGRAM: #include<stdio.h> #include<conio.h> struct node { int number; struct nodep; }h,f,t;

scanf(โ€œ%cโ€,&c); }while(c==โ€™yโ€™); t->p=NULL; t=f; printf(โ€œ\n the values of the linked list are:โ€); while(t!=NULL) { printf(โ€œ%dโ€,t->number); t=t->p; } printf(โ€œ\n|---------------------------------------------------------------------|โ€); printf(โ€œ\n|<<<<<<<<<<<<<<BU17050 9 >>>>>>>>>>>>>>>>>>>|โ€); printf(โ€œ\n|<<<<<<<<<<<<<<R.SURESH>>>>>>>>>>>>>>>>>>|โ€); printf(โ€œ\n|---------------------------------------------------------------------|โ€); } OUTPUT:

<<<<<<<<<<<<<>>>>>>>>>>>>>

Enter a number:

Want to continue[y/n]:y

Enter a number:

Want to continue[y/n]:y

Enter a number:

Want to continue[y/n]:n

The values of the linked list are:

<<<<<<<<<<<<<<<<<<BU1705 09 >>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<R.SURESH>>>>>>>>>>>>>>>>

QUESTION NO:

CONVERSION OF POSTFIX TO INFIX

CONVERSION: ijk+-lm-no-p+/*

โ€œl-mโ€ โ€œi-j+kโ€ /* โ€œn-o+pโ€ โ€œl-mโ€ โ€œi-j+kโ€

  • โ€œ(l-m)/(n-o+p)โ€ โ€œi-j+kโ€ NULL (i-j+k)(l-m)/(n-o+p) ANSWER:(i-j+k)(l-m)/(n-o+p)


QUESTION NO:

C PROGRAM TO GENERATE THE FOLLOWING PATTERN

PROGRAM: #include<stdio.h> main() { printf(โ€œ\n|_______________________________________________|โ€); printf(โ€œ\n|<<<<<<<<>>>>>>>>>>>|โ€); printf(โ€œ\n|_______________________________________________|โ€); int i,j,rows,cols; printf(โ€œ\nenter number of rows:โ€); scanf(โ€œ%dโ€,&rows); printf(โ€œ\nenter number of colums:โ€); scanf(โ€œ%dโ€,&rows); for(i=1;i<=rows;i++) { for(j=1;j<=cols;j++) { if(i==1||i==rows||j==1||j==cols) { printf(โ€œ1โ€); } else

<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<R.SURESH>>>>>>>>>>>>>>>>>>

QUESTION NO:

THE AVERAGE OF N GIVEN NUMBERS USING

POINTER

PROGRAM: #include<stdio.h> #include<conio.h> void main()

printf(โ€œ\n|-----------------------------------------------------------------------|โ€); printf(โ€œ\n|<<<<<<<<>>>>>>>>>>>|โ€); printf(โ€œ\n|-----------------------------------------------------------------------|โ€); int n,p,sum=0,i; float avg; printf(โ€œ\nhow many numbers:โ€); scanf(โ€œ%dโ€,&n); p=(int)malloc(n2); if(p==NULL) { printf(โ€œ\nmemory allocation unsuccessful.โ€); } for(i=0;i<n;i++) { printf(โ€œ\nenter number %dโ€,i+1); scanf(โ€œ%dโ€,(p+i)); } for(i=0;i<n;i++) sum=sum+(p+i); avg=(float)sum/n;

THANK

YOU