Aim :- To find shortest path (Using Dijkstra Algorithm in Networking).

Size: px
Start display at page:

Download "Aim :- To find shortest path (Using Dijkstra Algorithm in Networking)."

Transcription

1 Aim :- To find shortest path (Using Dijkstra Algorithm in Networking). #include <iostream.h> #include <conio.h> class graph public: char a; char b; int e; ; class dijkstra public: int n,p,t,f; char c[10]; void get_data(); void get_connection(graph g[]); void shortest(graph g[]); void display(graph g[]); int minm(int [],int,char []); int findu(graph g[],int,int,char []); ; void dijkstra::get_data() cout<<"enter number of nodes in your network:"; cin>>n; cout<<endl<<"write the name of each node"<<endl; for(int i=0;i<n;i++) cout<<"name of node "<<i+1<<":"; cin>>c[i]; void dijkstra::get_connection(graph g[]) clrscr(); cout<<endl<<endl<<"now ITS TIME TO CONNECT THE NODES...!"; cout<<endl<<"enter 1 if there is connection between consicutive nodes otherwise enter 0"<<endl; p=0; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++)

2 cout<<c[i]<<" & "<<c[j]<<" :"; int t; cin>>t; if(t==1) g[p].a=c[i]; g[p].b=c[j]; cout<<"enter distance:"; cin>>g[p].e; p++; void dijkstra::display(graph g[]) clrscr(); cout<<"your NETWORK IS LIKE THIS:"<<endl; for(int i=0;i<p;i++) cout<<g[i].a<<" & "<<g[i].b<<" :"<<g[i].e<<endl; void dijkstra::shortest(graph g[]) char s,c[10]; int q,d[10]; cout<<endl<<endl<<"now ENTER NODE from which you want to find shortest distance:"; cin>>s; t=0; f=0; //function to get distance & node array (Initialization) for(int r=0;r<n;r++) if(s!=c[r]) C[f]=c[r]; for(int i=0;i<p;i++) if((g[i].a==s && g[i].b==c[f]) (g[i].a==c[f] && g[i].b==s)) D[f]=g[i].e; q=0; break;

3 if(q!=0) D[f]=32767; f++; int w,u,v; //greedy loop for(q=0;q<n-2;q++) v=minm(d,f,c); for(w=0;w<f;w++) if(c[w]!=null && C[w]!=C[v]) u=findu(g,w,v,c); D[w]=(D[w]<(u+D[v])?D[w]:(u+D[v])); C[v]=NULL; cout<<"the sortest distance from node "<<s<<":"; for(int z=0;z<f-1;z++) cout<<d[z]<<","; cout<<d[f-1]; int dijkstra::findu(graph g[],int w,int v,char C[]) for(int z=0;z<p;z++) if((g[z].a==c[w] && g[z].b==c[v]) (g[z].a==c[v] && g[z].b==c[w])) return g[z].e; return 32676; int dijkstra::minm(int j[],int t,char c[]) int o=32766,q; for(int i=0;i<t;i++) if(o>j[i] && c[i]!=null)

4 o=j[i]; q=i; return q; void main () clrscr(); graph g[15]; dijkstra d; d.get_data(); d.get_connection(g); d.display(g); d.shortest(g); getch(); Output:

5 // Distances from a to other nodes in sequence (A->B,C,D,E) If distance is from C then read output as (C->A,B,D,E)

6 Kruskal s algorithm #include <iostream.h> #include <conio.h> class graph public: char a; char b; int e; ; class nodes public: char a; char b; ; class node public: char o[10]; ; class kruskal public: int n,p,k[10],u; char c[10]; void get_data(); void get_connection(graph g[]); void shorti(graph g[]); void display(graph g[]); void krush(graph g[],nodes N[],node E[]); int findcomp(char,node E[],int []); ; void kruskal::get_data() cout<<"how much node is their in your network?"; cin>>n; cout<<endl<<"write the name of each node"<<endl; for(int i=0;i<n;i++) cout<<"name of "<<i<<" th node :"; cin>>c[i]; void kruskal::get_connection(graph g[])

7 clrscr(); cout<<endl<<endl<<"now ITS TIME TO CONNECT THE NODES...!"; cout<<endl<<"enter 1 if their is connection between consicutiv node other wise enter 0"<<endl; p=0; for(int i=0;i<n;i++) k[i]=-1; for(int j=i+1;j<n;j++) cout<<c[i]<<" & "<<c[j]<<" :"; int t; cin>>t; if(t==1) g[p].a=c[i]; g[p].b=c[j]; cout<<"enter distance"; cin>>g[p].e; p++; void kruskal::display(graph g[]) for(int i=0;i<p;i++) cout<<g[i].a<<" & "<<g[i].b<<" :"<<g[i].e<<endl; void kruskal::shorti(graph g[]) int key; char x,y; for(int j=1;j<p;j++) int i=j-1; key=g[j].e; x=g[j].a; y=g[j].b; while(i>=0 && key<g[i].e) g[i+1].e=g[i].e; g[i+1].a=g[i].a; g[i+1].b=g[i].b; i--;

8 g[i+1].e=key; g[i+1].a=x; g[i+1].b=y; void kruskal::krush(graph g[],nodes N[],node E[]) E[0].o[0]=g[0].a; E[0].o[1]=g[0].b; N[0].a=E[0].o[0]; N[0].b=E[0].o[1]; k[0]=2; int i=1,z=1,v=0,x; u=1; //To Initialize n nodes for(int m=0;m<n;m++) if(c[m]!=g[0].a && c[m]!=g[0].b) E[u].o[0]=c[m]; k[u]=1; u++; while(z<n-1) v=findcomp((char)g[i].a,e,k); x=findcomp((char)g[i].b,e,k); if(v!=x) N[z].a=g[i].a; N[z].b=g[i].b; int j; for(j=0;j<k[x];j++) E[v].o[k[v]+j]=E[x].o[j]; k[v]=k[v]+j; k[x]=0; z++; i++; else i++;

9 cout<<endl<<"the spanning tree is like:"<<endl; for(int r=0;r<z;r++) cout<<n[r].a<<" & "<<N[r].b<<endl; int kruskal::findcomp(char a,node E[],int k[]) for(int i=0;i<u;i++) for(int j=0;j<k[i];j++) if(e[i].o[j]==a) return i; return 0; void main () clrscr(); graph g[15]; kruskal d; nodes N[10]; node E[10]; d.get_data(); d.get_connection(g); clrscr(); cout<<"your NETWORK IS LIKE THIS:"<<endl; d.display(g); d.shorti(g); cout<<"shorted ages is like"<<endl; d.display(g); d.krush(g,n,e); getch(); Output:

10

11

12 Program for Greedy Algorithm: #include<iostream.h> #include<conio.h> int a[10]; class greedy public: static int n,n,l; void make_money(); int get_money(); void avail_coins(); void sort(); ; int greedy::n; int greedy::n; int greedy::l; void greedy::make_money() int A,i=0,b; n=get_money(); avail_coins(); sort(); N=n; while(n!=0) A=N/(int(a[i])); cout<<"\n"<<a[i]<<" amount of coin is"<<a; b=n-(a*a[i]); i++; N=b; void greedy::sort() int j; for(int i=1;i<l;i++) int key=a[i]; j=i-1; while(j+1>0 && a[j]<key) a[j+1]=a[j]; j--; a[j+1]=key;

13 int greedy::get_money() int n; cout<<"enter the amount of bill :"; cin>>n; return n; void greedy::avail_coins() int i=0; cout<<"how many coins u want to take? "; cin>>l; cout<<"\n enter the values for coins :\n"; while(i<l) cin>>a[i]; i++; void main() clrscr(); greedy p; p.make_money(); getch(); Output:

14 Bubble Sort Code: #include<iostream.h> #include<conio.h> class array public: void get_data(int [],int); void ins_sort(void); void display(int [],int,int); void bbl_sort(void); ; void array::get_data(int a[],int n) for(int i=0;i<n;i++) cout<<" enter element"<<i+1<<": "; cin>>a[i]; void array::bbl_sort(void) int i,j,key,a[100],k=0,t,n; cout<<"\nhow many number you want to sort? "; cin>>n; get_data(a,n); for(i=0;i<n-1;i++) for(j=n-1;j>i;j--) key=j-1; if(a[key]>a[j]) t=a[j]; a[j]=a[key]; a[key]=t; k++; cout<<"\n the sorted elements are:"; display(a,n,k);

15 void array::display(int a[],int n,int k) for(int i=0;i<n;i++) cout<<"\n"<<a[i]; cout<<"\nthenumber of iteration is:"<<k; void main() clrscr(); array p; p.bbl_sort(); getch(); Output :

16 Aim: Quick Sort Algoritham #include<stdio.h> void QuickSort(int A[],int p, int r); int Partition(int A[],int p,int r); int main() int A[8],p=0,r=7,i=0; printf("enter 8 Numbers to Sort Using Quick Sort\n"); for(i=0;i<8;i++) scanf("%d",&a[i]); // Calling Quick Sort Function QuickSort(A,p,r); //Printing Sorted Array printf("sorted Array is As Below:\n"); for(i=0;i<8;i++) printf("%d\n",a[i]); return 0; void QuickSort(int A[],int p, int r) int q; if(p<r) q=partition(a,p,r); QuickSort(A,p,q-1); QuickSort(A,q+1,r); int Partition(int A[],int p,int r) int x=a[r]; int i=p-1; int j,temp; for(j=p;j<r;j++) if(a[j]<=x)

17 i=i+1; // Exchange A[i] with A[j] temp=a[j]; A[j]=A[i]; A[i]=temp; // Exchange A[i+1] with A[r] temp=a[r]; A[r]=A[i+1]; A[i+1]=temp; return i+1; Output:

18 Aim: Algorithm for Merge Sort. #include<stdio.h> #include<math.h> void Merge_Sort(int A[],int p, int r); void Merge(int A[],int p, int q,int r ); int main() int A[8],p=0,r=7,i=0; printf("enter 8 Numbers to Sort Using Merge Sort\n"); for(i=0;i<8;i++) scanf("%d",&a[i]); // Calling Merge Sort Function Merge_Sort(A,p,r); //Printing Sorted Array printf("sorted Array is As Below:\n"); for(i=0;i<8;i++) printf("%d\n",a[i]); return 0; void Merge_Sort(int A[],int p, int r) int q; if(p<r) q=floor((p+r)/2); Merge_Sort(A,p,q); Merge_Sort(A,q+1,r); Merge(A,p,q,r); void Merge(int A[],int p, int q,int r) int n1=q-p+1; int n2=r-q; int L[n1+1],R[n2+1]; int i,j,k; // Counter Variable

19 for(i=1;i<=n1;i++) L[i]=A[p+i-1]; for(j=1;j<=n2;j++) R[j]=A[q+j]; // Infinite means most larger number that is not in Array A L[n1+1]=32000; R[n2+1]=32500; i=1; j=1; for(k=p;k<=r;k++) if(l[i]<=r[j]) A[k]=L[i]; i=i+1; else A[k]=R[j]; j=j+1; Output:

Algorithms Lab (NCS 551)

Algorithms Lab (NCS 551) DRONACHARYA GROUP OF INSTITUTIONS, GREATER NOIDA Affiliated to Utter Pradesh Technical University Noida Approved by AICTE Algorithms Lab (NCS 551) SOLUTIONS 1. PROGRAM TO IMPLEMENT INSERTION SORT. #include

More information

Downloaded from

Downloaded from Unit-II Data Structure Arrays, Stacks, Queues And Linked List Chapter: 06 In Computer Science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

More information

Chapter4: Data Structures. Data: It is a collection of raw facts that has implicit meaning.

Chapter4: Data Structures. Data: It is a collection of raw facts that has implicit meaning. Chapter4: s Data: It is a collection of raw facts that has implicit meaning. Data may be single valued like ID, or multi valued like address. Information: It is the processed data having explicit meaning.

More information

DELHI PUBLIC SCHOOL TAPI

DELHI PUBLIC SCHOOL TAPI Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed

More information

Sample Paper - II Subject Computer Science

Sample Paper - II Subject Computer Science Sample Paper - II Subject Computer Science Max Marks 70 Duration 3 hrs Note:- All questions are compulsory Q1) a) What is significance of My Computer? 2 b) Explain different types of operating systems.

More information

List of Programs included 1. Insertion sort 2. Bubble sort 3. Selection sort 4. Circular Queue 5. Stack implementation using array 6.

List of Programs included 1. Insertion sort 2. Bubble sort 3. Selection sort 4. Circular Queue 5. Stack implementation using array 6. List of Programs included 1. Insertion sort 2. Bubble sort 3. Selection sort 4. Circular Queue 5. Stack implementation using array 6. Linear search 7. Binary search (non recursive) 8. Fibonacci with recursion

More information

DE122/DC106 Object Oriented Programming with C++ DEC 2014

DE122/DC106 Object Oriented Programming with C++ DEC 2014 Q.2 a. Distinguish between Procedure-oriented programming and Object- Oriented Programming. Procedure-oriented Programming basically consists of writing a list of instructions for the computer to follow

More information

CSE202- Lec#6. (Operations on CSE202 C++ Programming

CSE202- Lec#6. (Operations on CSE202 C++ Programming Arrays CSE202- Lec#6 (Operations on Arrays) Outline To declare an array To initialize an array Operations on array Introduction Arrays Collection of related data items of same data type. Static entity

More information

Arrays. Elementary Data Representation Different Data Structure Operation on Data Structure Arrays

Arrays. Elementary Data Representation Different Data Structure Operation on Data Structure Arrays Arrays Elementary Data Representation Different Data Structure Operation on Data Structure Arrays Elementary Data Representation Data can be in the form of raw data, data items and data structure. Raw

More information

Sample Paper -V Subject Computer Science Time: 3Hours Note. (i) All questions are compulsory. Maximum Marks: 70 Q.No.1 a. Write the header file for the given function 2 abs(), isdigit(), sqrt(), setw()

More information

Programming in C++ (Educational Support)

Programming in C++ (Educational Support) Programming in C++ (Educational Support) http:// 1. WRITE A PROGRAM TO TRAVERSING OF AN ARRAY. #include # include void main () int a [10], lb = 1, ub, k, I; cout

More information

Q2: Write an algorithm to merge two sorted arrays into a third array? (10 Marks) Ans Q4:

Q2: Write an algorithm to merge two sorted arrays into a third array? (10 Marks) Ans Q4: Model Answer Benha University 1 st Term (2013/2014) Final Exam Class: 2 nd Year Students Subject: Data Structures Faculty of Computers & Informatics Date: 26/12/2013 Time: 3 hours Examiner: Dr. Essam Halim

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins

More information

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition) Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.

More information

PROGRAM 1 AIM: Write a program to find the number of vertices, even vertices, odd vertices and the number of edges in a graph.

PROGRAM 1 AIM: Write a program to find the number of vertices, even vertices, odd vertices and the number of edges in a graph. PROGRAM 1 AIM: Write a program to find the number of vertices, even vertices, odd vertices and the number of edges in a graph. CODE: #include using namespace std; #include #define MAX

More information

APPLIED GRAPH THEORY FILE. 7 th Semester MCE MCDTU.WORDPRESS.COM

APPLIED GRAPH THEORY FILE. 7 th Semester MCE MCDTU.WORDPRESS.COM APPLIED GRAPH THEORY FILE 7 th Semester MCE MCDTU.WORDPRESS.COM INDEX S.No. TOPIC DATE TEACHER S SIGNATURE 1. Write a program to find the number of vertices, even vertices, odd vertices and the number

More information

Dm507 project 1. Emil Sjulstok Rasmussen Hold: M1

Dm507 project 1. Emil Sjulstok Rasmussen Hold: M1 Dm507 project 1 Emil Sjulstok Rasmussen - 050391 Hold: M1 Problem 1 In assignment 1 I have used an ArrayList to store the int s from the text file, while in assignment 2 I have just used an int array.

More information

ARRAY FUNCTIONS (1D ARRAY)

ARRAY FUNCTIONS (1D ARRAY) ARRAY FUNCTIONS (1D ARRAY) EACH QUESTIONS CARRY 2 OR 3 MARKS Q.1 Write a function void ChangeOver(int P[ ], int N) in C++, which re-positions all the elements of the array by shifting each of them to the

More information

Downloaded from

Downloaded from Unit I Chapter -1 PROGRAMMING IN C++ Review: C++ covered in C++ Q1. What are the limitations of Procedural Programming? Ans. Limitation of Procedural Programming Paradigm 1. Emphasis on algorithm rather

More information

Practical 1. flag=linear_search(array,array_size,searching_element);

Practical 1. flag=linear_search(array,array_size,searching_element); Practical 1 AIM: Write a program in C++ to implement Linear Search. #include #include int linear_search(int [],int,int); main() clrscr(); constint array_size=10; int array[array_size]=0;

More information

Developed By Strawberry

Developed By Strawberry Experiment No. 3 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To study below concepts of classes and objects 1. Array of Objects 2. Objects as a function argument 3. Static Members P1: Define a

More information

1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms.

1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms. PROBLEM: 1. FIBONACCI SERIES Write a C++ program to generate the Fibonacci for n terms. AIM: To write a C++ program to generate the Fibonacci for n terms. PROGRAM CODING: #include #include

More information

Unit-4 Sorting PROGRAM:

Unit-4 Sorting PROGRAM: Unit-4 Sorting : Sorting Techniques- Sorting by Insertion: Straight Insertion sort- List insertion sort- Binary insertion sort- Sorting by selection: Straight selection sort- Heap Sort- Sorting by Exchange-

More information

DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering. Algorithm lab- PCS-553 LAB MANUAL

DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering. Algorithm lab- PCS-553 LAB MANUAL DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering Year: 3rd Semester: 5th Algorithm lab- PCS-553 LAB MANUAL Prepared By: HOD (CSE) 1 DEV BHOOMI INSTITUTE OF TECHNOLOGY DEV

More information

c++ Solutions eedsohag.epizy.com Ahmed Ali

c++ Solutions eedsohag.epizy.com Ahmed Ali c++ s Ahmed Ali int main(int argc, char *argv[]) int age; age=10; cout

More information

Prepared by: Shraddha Modi

Prepared by: Shraddha Modi Prepared by: Shraddha Modi Introduction In looping, a sequence of statements are executed until some conditions for termination of the loop are satisfied. A program loop consist of two segments Body of

More information

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,

More information

Selection / making decision If statement if-else, if-else-if or nested if Switch Case

Selection / making decision If statement if-else, if-else-if or nested if Switch Case SPM 2102 PROGRAMMING LANGUAGE 1 C++ Programming Structure By NORAH MD NOOR 1 Selection / making decision If statement if-else, if-else-if or nested if Switch Case 2 Introduction: Flow of control Normal

More information

Unit 2: Data Structures

Unit 2: Data Structures Unit 2: Data Structures 2.1: Arrays ARRAYS Introduction to data structure, Arrays, One Dimensional Array, Basic operations on 1-D array: traversal, Searching- linear, binary search, insertion, deletion,

More information

Software Testing Laboratory Lab Assignments

Software Testing Laboratory Lab Assignments Problem Statement 01 (Week 01) Software Testing Laboratory Lab Assignments Consider an automated banking application. The user can dial the bank from a personal computer, provide a six-digit password,

More information

Control Structure and Loop Statements

Control Structure and Loop Statements Control Structure and Loop Statements A C/C++ program executes in sequential order that is the way the instructions are written. There are situations when we have to skip certain code in the program and

More information

Introduction to Arrays

Introduction to Arrays Introduction to Arrays One Dimensional Array. Two Dimensional Array. Inserting Elements in Array. Reading Elements from an Array. Searching in Array. Sorting of an Array. Merging of 2 Arrays. What is an

More information

IV Year I SEMESTER. Software Testing Lab

IV Year I SEMESTER. Software Testing Lab IV Year I SEMESTER Software Testing Lab T P C 0 3 2 Lab Assignments Problem Statement 01 Consider an automated banking application. The user can dial the bank from a personal computer, provide a six-digit

More information

Programming Fundamentals

Programming Fundamentals Programming Fundamentals Programming Fundamentals Instructor : Zuhair Qadir Lecture # 11 30th-November-2013 1 Programming Fundamentals Programming Fundamentals Lecture # 11 2 Switch Control substitute

More information

Searching an Array: Linear and Binary Search. 21 July 2009 Programming and Data Structure 1

Searching an Array: Linear and Binary Search. 21 July 2009 Programming and Data Structure 1 Searching an Array: Linear and Binary Search 21 July 2009 Programming and Data Structure 1 Searching Check if a given element (key) occurs in the array. Two methods to be discussed: If the array elements

More information

UNIT III ARRAYS AND STRINGS

UNIT III ARRAYS AND STRINGS UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.

More information

Recurrences and Divide-and-Conquer

Recurrences and Divide-and-Conquer Recurrences and Divide-and-Conquer Frits Vaandrager Institute for Computing and Information Sciences 16th November 2017 Frits Vaandrager 16th November 2017 Lecture 9 1 / 35 Algorithm Design Strategies

More information

Important Questions 2010 Class-XII-Computer Science

Important Questions 2010 Class-XII-Computer Science Important Questions 2010 Class-XII-Computer Science I Q.1. Differentiate between primary memory and secondary memory. Give examples of each type of memory. a) The memory inside the CPU is primary memory

More information

An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store

An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store either all integers, all floating point numbers, all characters,

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies 1. Explain Call by Value vs. Call by Reference Or Write a program to interchange (swap) value of two variables. Call By Value In call by value pass value, when we call the function. And copy this value

More information

Functions. Introduction :

Functions. Introduction : Functions Introduction : To develop a large program effectively, it is divided into smaller pieces or modules called as functions. A function is defined by one or more statements to perform a task. In

More information

2. ARRAYS What is an Array? index number subscrip 2. Write array declarations for the following: 3. What is array initialization?

2. ARRAYS What is an Array? index number subscrip 2. Write array declarations for the following: 3. What is array initialization? 1 2. ARRAYS 1. What is an Array? Arrays are used to store a set of values of the same type under a single variable name. It is a collection of same type elements placed in contiguous memory locations.

More information

A.1 Computer Code for Calculation of Permanent Function of a Matrix

A.1 Computer Code for Calculation of Permanent Function of a Matrix Appendix Computer Codes A.1 Computer Code for Calculation of Permanent Function of a Matrix #include #include /*************************************************************************

More information

VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS

VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS 1. Write C++ programs to interchange the values of two variables. a. Using with third variable int n1, n2, temp; cout

More information

BRAIN INTERNATIONAL SCHOOL. Term-I Class XI Sub: Computer Science Revision Worksheet

BRAIN INTERNATIONAL SCHOOL. Term-I Class XI Sub: Computer Science Revision Worksheet BRAIN INTERNATIONAL SCHOOL Term-I Class XI 2018-19 Sub: Computer Science Revision Worksheet Chapter-1. Computer Overview 1. Which electronic device invention brought revolution in earlier computers? 2.

More information

Examination for the Second Term - Academic Year H Mid-Term. Name of student: ID: Sr. No.

Examination for the Second Term - Academic Year H Mid-Term. Name of student: ID: Sr. No. Kingdom of Saudi Arabia Ministry of Higher Education Course Code: ` 011-COMP Course Name: Programming language-1 Deanship of Preparatory Year Jazan University Total Marks: 20 Duration: 60 min Group: Examination

More information

Administrivia. HW on recursive lists due on Wednesday. Reading for Wednesday: Chapter 9 thru Quicksort (pp )

Administrivia. HW on recursive lists due on Wednesday. Reading for Wednesday: Chapter 9 thru Quicksort (pp ) Sorting 4/23/18 Administrivia HW on recursive lists due on Wednesday Reading for Wednesday: Chapter 9 thru Quicksort (pp. 271-284) A common problem: Sorting Have collection of objects (numbers, strings,

More information

Sorting & Searching. Hours: 10. Marks: 16

Sorting & Searching. Hours: 10. Marks: 16 Sorting & Searching CONTENTS 2.1 Sorting Techniques 1. Introduction 2. Selection sort 3. Insertion sort 4. Bubble sort 5. Merge sort 6. Radix sort ( Only algorithm ) 7. Shell sort ( Only algorithm ) 8.

More information

Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory.

Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory. Sample Paper Class I Subject Computer Science Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory. 1 a) What are the different functions of operating system? 2 b) How the information

More information

Set I Sample Paper Class XI Subject Computer Science Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory.

Set I Sample Paper Class XI Subject Computer Science Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory. Set I Sample Paper Class XI Subject Computer Science Time: 3Hours Maximum Marks: 70 Note. (i) All questions are compulsory. 1 a) What are the different functions of operating system? 2 b) How the information

More information

C++ 8. Constructors and Destructors

C++ 8. Constructors and Destructors 8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of

More information

C++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different.

C++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different. C++ Character Set a-z, A-Z, 0-9, and underscore ( _ ) C++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different. Identifier and Keywords:

More information

Q (Quaternary) Search Algorithm

Q (Quaternary) Search Algorithm Q (Quaternary) Search Algorithm Taranjit Khokhar Abstract In computer science, there are many ways to search the position of the required input value in an array. There are algorithms such as binary search

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session: Merge Sort in C++ and Its Analysis Dr. Deepak B. Phatak & Dr. Supratik Chakraborty,

More information

BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI. Unit Wise Marks

BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI. Unit Wise Marks BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI Unit Wise Marks Unit No. Unit Name Marks 1. COMPUTER FUNDAMENTAL 10 2. PROGRAMMING METHODOLOGY 12 3. INTRODUCTION TO C++ 1. INTRODUCTION TO C++ 3 TOTAL

More information

2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them.

2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them. 1. Why do you think C++ was not named ++C? C++ is a super set of language C. All the basic features of C are used in C++ in their original form C++ can be described as C+ some additional features. Therefore,

More information

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES Polymorphism: It allows a single name/operator to be associated with different operations depending on the type of data passed to it. An operation may exhibit different behaviors in different instances.

More information

If the numbers are 5 and 2,

If the numbers are 5 and 2, Chapter : 4 Functions Examples 1. An example for functions.[pg-94] int fact(int num) int factorial = 1; for(inta=1;a

More information

ECS122A Lecture Notes on Algorithm Design and Analysis

ECS122A Lecture Notes on Algorithm Design and Analysis ECS122A Lecture Notes on Algorithm Design and Analysis Winter 2018 http://www.cs.ucdavis.edu/ bai/ecs122a Professor Zhaojun Bai 1 / 12 Overview I. Introduction and getting started II. Growth of functions

More information

To store the total marks of 100 students an array will be declared as follows,

To store the total marks of 100 students an array will be declared as follows, Chapter 4 ARRAYS LEARNING OBJECTIVES After going through this chapter the reader will be able to declare and use one-dimensional and two-dimensional arrays initialize arrays use subscripts to access individual

More information

BRAIN INTERNATIONAL SCHOOL Term-II Class-XI Sub:- Computer Science Revision Sheet

BRAIN INTERNATIONAL SCHOOL Term-II Class-XI Sub:- Computer Science Revision Sheet BRAIN INTERNATIONAL SCHOOL Term-II Class-XI 2018-19 Computer Organisation Sub:- Computer Science Revision Sheet 1. Which electronic device invention brought revolution in earlier computers? 2. Which memory

More information

Object Oriented Pragramming (22316)

Object Oriented Pragramming (22316) Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data

More information

EXP 1.1 Operator Precedence. #include <iostream.h> Int main() { int a = 20, b = 10, c = 15,d = 5, e; e = (a + b) * c / d;

EXP 1.1 Operator Precedence. #include <iostream.h> Int main() { int a = 20, b = 10, c = 15,d = 5, e; e = (a + b) * c / d; EXP 1.1 Operator Precedence #include Int main() int a = 20, b = 10, c = 15,d = 5, e; e = (a + b) * c / d; cout

More information

CSE 2123 Sorting. Jeremy Morris

CSE 2123 Sorting. Jeremy Morris CSE 2123 Sorting Jeremy Morris 1 Problem Specification: Sorting Given a list of values, put them in some kind of sorted order Need to know: Which order? Increasing? Decreasing? What does sorted order mean?

More information

COMPUTER SCIENCE PRACTICAL GUIDE [ ENGLISH MEDIUM ]

COMPUTER SCIENCE PRACTICAL GUIDE [ ENGLISH MEDIUM ] +2 COMPUTER SCIENCE PRACTICAL GUIDE 2018-19 [ ENGLISH MEDIUM ] NAME : SUBJECT: SCHOOL : Sastra Matriculation Higher Secondary School 1 Kilpennathur, Tiruvannamalai INSTRUCTIONS FOR THE CONDUCT OF PRACTICAL

More information

Scientific Computing. Algorithm Analysis

Scientific Computing. Algorithm Analysis ECE257 Numerical Methods and Scientific Computing Algorithm Analysis Today s s class: Introduction to algorithm analysis Growth of functions Introduction What is an algorithm? A sequence of computation

More information

OOP THROUGH C++(R16) int *x; float *f; char *c;

OOP THROUGH C++(R16) int *x; float *f; char *c; What is pointer and how to declare it? Write the features of pointers? A pointer is a memory variable that stores the address of another variable. Pointer can have any name that is legal for other variables,

More information

Kareem Naaz (KN) Encryption and Decryption using Sorting

Kareem Naaz (KN) Encryption and Decryption using Sorting Kareem Naaz (KN) Encryption and Decryption using Sorting Shaik Kareem Basha Asst. Professor CSE Abstract: In Computer networks, Messages are transmitted from sender to receiver with high security. Encryption

More information

KENDRIYA VIDYALAYA SANGATHAN, GUWAHATI REGION HALF-YEARLY EXAMINATION-2015 CLASS XI : COMPUTER SCIENCE Time Allotted : 3 hrs. Max.

KENDRIYA VIDYALAYA SANGATHAN, GUWAHATI REGION HALF-YEARLY EXAMINATION-2015 CLASS XI : COMPUTER SCIENCE Time Allotted : 3 hrs. Max. KENDRIYA VIDYALAYA SANGATHAN, GUWAHATI REGION HALF-YEARLY EXAMINATION-2015 CLASS XI : COMPUTER SCIENCE Time Allotted : 3 hrs. Max. Marks : 70 Q.1..... operator in C++, requires three operands. [1] Q.2

More information

ARRAYS. Part II Answers to all the questions (2 Marks):

ARRAYS.   Part II Answers to all the questions (2 Marks): Unit - III Arrays and Structures CHAPTER - 12 ARRAYS PART I Choose the correct answer. 1. Which of the following is the collection of variables of the same type that an referenced by a common name? a)

More information

Some important concept in oops are 1) Classes 2) Objects 3) Data abstraction & Encapsulation. 4) Inheritance 5) Dynamic binding. 6) Message passing

Some important concept in oops are 1) Classes 2) Objects 3) Data abstraction & Encapsulation. 4) Inheritance 5) Dynamic binding. 6) Message passing Classes and Objects Some important concept in oops are 1) Classes 2) Objects 3) Data abstraction & Encapsulation. 4) Inheritance 5) Dynamic binding. 6) Message passing Classes i)theentiresetofdataandcodeofanobjectcanbemadeauserdefineddatatypewiththehelpofaclass.

More information

QUESTION BANK UNIT III

QUESTION BANK UNIT III QUESTION BANK UNIT III DEPARTMENT: CSE SUB NAME: OBJECT ORIENTED PROGRAMMING SEMESTER III SUB CODE: CS2203 PART A (2 MARKS) 1. What are templates? (AUC DEC 2009) Template is one of the features added to

More information

CHAPTER 9 FLOW OF CONTROL

CHAPTER 9 FLOW OF CONTROL CHAPTER 9 FLOW OF CONTROL FLOW CONTROL In a program statement may be executed sequentially, selectively or iteratively. Every program language provides constructs to support sequence, selection or iteration.

More information

1. Answer the following : a) What do you mean by Open Source Software. Give an example. (2)

1. Answer the following : a) What do you mean by Open Source Software. Give an example. (2) THE AIR FORCE SCHOOL Class XI First Terminal Examination 2017-18 Computer Science (083) Time: 3 hrs. M. Marks : 70 General Instructions : (i) All the questions are compulsory. (ii) Programming Language

More information

EECS 2011M: Fundamentals of Data Structures

EECS 2011M: Fundamentals of Data Structures M: Fundamentals of Data Structures Instructor: Suprakash Datta Office : LAS 3043 Course page: http://www.eecs.yorku.ca/course/2011m Also on Moodle Note: Some slides in this lecture are adopted from James

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may

More information

C C++ C++! "# C++ ++

C C++ C++! # C++ ++ C++ C+ ++ C++ C++.. C++. Brace. " ". /* */ // 31.. Case Sensitive (if, char, while, ). C. char a ; float pi=3.14; : : = ; ; : : . char Character or small integer 1byte short int Short Integer 2bytes int

More information

C++ PROGRAMMING SKILLS Part 2 Programming Structures

C++ PROGRAMMING SKILLS Part 2 Programming Structures C++ PROGRAMMING SKILLS Part 2 Programming Structures If structure While structure Do While structure Comments, Increment & Decrement operators For statement Break & Continue statements Switch structure

More information

خ ث ح 13:10 14:00 خ ث ح 51:51 16:11 ر ن 09:41 11:11 ر ن

خ ث ح 13:10 14:00 خ ث ح 51:51 16:11 ر ن 09:41 11:11 ر ن Philadelphia University Faculty of Engineering Department of Computer Engineering Programming Language (630263) Date:- 07/02/2015 Allowed time:- 2 Hours Final Exam Student Name: -... ID: - Instructor:

More information

Design and Analysis of Algorithms Assignment-2 Solutions (Hints) REMARK: Quicksort

Design and Analysis of Algorithms Assignment-2 Solutions (Hints) REMARK: Quicksort Design and Analysis of Algorithms Assignment-2 Solutions (Hints) REMARK: The codes given below are just a guide, this is not the only way to write programs for these algorithms. What is important is that

More information

Inheritance: Single level inheritance:

Inheritance: Single level inheritance: Inheritance: The mechanism of deriving a new class from old one is called inheritance. The old class is referred to as the base class or parent class and the new class is called the derived class or child

More information

Function with default arguments

Function with default arguments Function with default arguments A function can be called without specifying all its arguments. This can be achieved only if the function declaration provides default values for those arguments that are

More information

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE a) Mention any 4 characteristic of the object car. Ans name, colour, model number, engine state, power b) What

More information

Unit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION

Unit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION INTRODUCTION Decision Making and Looping Unit 5 In the previous lessons we have learned about the programming structure, decision making procedure, how to write statements, as well as different types of

More information

PROGRAM 1. Write a program to implement Caesar Cipher.

PROGRAM 1. Write a program to implement Caesar Cipher. PROGRAM 1 Write a program to implement Caesar Cipher. #include #include #include #include using namespace std; int main() char str[50],ch[50],z[50]; int e,x,i,key;

More information

Types of Data Structures

Types of Data Structures DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data

More information

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

More information

CS101 Computer Programming and Utilization

CS101 Computer Programming and Utilization CS101 Computer Programming and Utilization Milind Sohoni June 13, 2006 Milind Sohoni () CS101 Computer Programming and Utilization June 13, 2006 1 / 25 1 So far 2 What is sorting 3 Bubble Sort 4 Other

More information

This can be thrown by dynamic_cast. This is useful device to handle unexpected exceptions in a C++ program

This can be thrown by dynamic_cast. This is useful device to handle unexpected exceptions in a C++ program Abstract class Exception handling - Standard libraries - Generic Programming - templates class template - function template STL containers iterators function adaptors allocators -Parameterizing the class

More information

Lab Manual on Soft Computing [CS-801]

Lab Manual on Soft Computing [CS-801] 2014 Lab Manual on Soft Computing [CS-801] Ms. ShiIpi Jain Ms. Rakhi Arora INSTITUTE OF INFORMATION TECHNOLOGY & MANAGEMENT, GWALIOR 01-Feb-2014 1 SOFTWARE REQUIREMENT : 1. Turbo C++ IDE (TurboC3) 2. Borland

More information

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer: Chapter-11 POINTERS Introduction: Pointers are a powerful concept in C++ and have the following advantages. i. It is possible to write efficient programs. ii. Memory is utilized properly. iii. Dynamically

More information

Program. SUBJECT: ACP (C - Programming) Array Program. // Find the minimum number from given N element. Prepared By : Dhaval R.

Program. SUBJECT: ACP (C - Programming) Array Program. // Find the minimum number from given N element. Prepared By : Dhaval R. Program // Find the minimum number from given N element. #include #include void main() int a[50],i,n,min; clrscr(); printf("\n Enter array size : "); scanf("%d",&n); printf("\n Enter

More information

F.E. Sem. II. Structured Programming Approach

F.E. Sem. II. Structured Programming Approach F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 13 [Marks : 80 Q.1(a) Explain the purpose of following standard library functions : [3] (i)

More information

CS2205 OS Programming Assignments. Name : Han Jian ID:

CS2205 OS Programming Assignments. Name : Han Jian ID: CS2205 OS Programming Assignments Name : Han Jian ID: 6029693 CPU scheduling First- Come, First-Served (FCFS) Scheduling #include using namespace std; int main() int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;

More information

LABORATORY MANUAL. (CSE-103F) FCPC Lab

LABORATORY MANUAL. (CSE-103F) FCPC Lab LABORATORY MANUAL (CSE-103F) FCPC Lab Department of Computer Science & Engineering BRCM College of Engineering & Technology Bahal, Haryana Aim: Main aim of this course is to understand and solve logical

More information

UNIT-4 Statements:- Null Statement:- Compound Statement :- Statement Flow Control:- Sequence Construct:- Selection Construct

UNIT-4 Statements:- Null Statement:- Compound Statement :- Statement Flow Control:- Sequence Construct:- Selection Construct UNIT-4 Programming in C++ Statements:-Statements are the instructions given to the Computer to perform any kind of action. Null Statement:-A null statement is useful in those case where syntax of the language

More information

BE III Semester ISE Page 1 of 1

BE III Semester ISE Page 1 of 1 Scheme of Valuation Date : 29-09-2015 Max Marks : 50 Marks Subject & Code: Object Oriented Programming with C++ (10CS36) Semester & Section: III A & B Name of Faculty: Prof.Sandesh & Mrs.Saritha Time :

More information

Lab 10: Disk Scheduling Algorithms

Lab 10: Disk Scheduling Algorithms 1. Objective Lab 10: Disk Scheduling Algorithms Understand Disk Scheduling Algorithm and read its code for SSTF, SCAN, CSCAN in C, 2. Syllabus try to write other kinds of disk scheduling algorithms such

More information

b) Give the output of the following program: 6,70,70 2,70 210,282,59290

b) Give the output of the following program: 6,70,70 2,70 210,282,59290 Set II 1. a) Name the header file for the following built-in functions: i) fabs() math.h ii) isalpha() ctype.h iii) toupper() ctype.h iv) cos() math.h b) Give the output of the following program: 6,70,70

More information

Contents. Sr. No. Title of the Practical: Page no Signature. Gate. OR gate. EX-OR gate. gate. identifying ODD and EVEN number.

Contents. Sr. No. Title of the Practical: Page no Signature. Gate. OR gate. EX-OR gate. gate. identifying ODD and EVEN number. Contents Sr. No. Title of the Practical: Page no Signature 01. To Design and train a perceptron for AND Gate. 02. To design and train a perceptron training for OR gate. 03. To design and train a perceptron

More information