Posts

To convert hexadecimal to decimal numbers.

#include #include #include #include void main() {             char hex[' '], c;             int i,len,dec[' '],total;             clrscr();             do             {                         printf("Enter hexadecimal number:\t");                         gets(hex);                         len=strlen(hex);       ...

To convert hexadecimal to decimal numbers.

#include #include #include #include void main() {             char hex[' '], c;             int i,len,dec[' '],total;             clrscr();             do             {                         printf("Enter hexadecimal number:\t");                         gets(hex);                         len=strlen(hex);       ...

Write a program to solve the problem of tower of Hanoi with 3 pegs and N discs

#include #include class hanoi { int n; char peg_a, peg_b, peg_c; public: void towers_hanoi(int n, char peg_a, char peg_b, char peg_c); }; void hanoi::towers_hanoi(int n, char peg_a, char peg_b, char peg_c) { if (n<=0) { cout << "\nIllegal operation" ; } else if (n==1) { cout << "\nMove disk from :\t" << peg_a << "\tto\t" << peg_c; } else { towers_hanoi(n-1, peg_a, peg_c, peg_b); towers_hanoi(1, peg_a, peg_b, peg_c); towers_hanoi(n-1, peg_b, peg_a, peg_c); } } void main() { hanoi obj; int n; clrscr(); cout << "\nEnter numbers of disk :\t" ; cin >> n; obj.towers_hanoi(n, 'A', 'B', 'C'); getch(); }

Write a menu driven program to a) Find the length of a string b) concatenate two strings c) to extract a substring from a given string d) Finding and replacing a string by another string in a text (Use pointers and user-defined functions)

#include #include #include #include #include class string_manipulation { public: void lenstr(char *); void concatenate(char *, char *, char *); int str_rep(char *, char *, int c[]); void extract(); }; void string_manipulation::lenstr(char *p) { int len = 0; while (*p++) { len ++; } cout << "The length of the string is : " < }

Write a program to convert the given infix expression into its postfix form

#include #include #include #include int TOP = -1, rank = 0; char STACK[50]; class infix_exp { public: void PUSH(char item); char POP(); int F(char symbol); int G(char symbol); int RANK(char symbol); int infix_postfix(char infix[ ], char postfix[ ]); };

explain classification of PRAM model

explain classification of PRAM model The PRAM model is an extension of the familiar RAM model of sequential computation that is used in algorithm analysis. We will use the synchronous PRAM which is defined as follows. 1. There are p processors connected to a single shared memory. 2. Each processor has a unique index 1 <=   i <=   p called the processor id . 3. A single program is executed in single-instruction stream, multiple-data stream (SIMD) fashion. Each instruction in the instruction stream is carried out by all processors simultaneously and requires unit time, regardless of the number of processors.

Gustafson’s law

Image
Gustafson’s law :- Gustafson's Law says that if you apply   P   processors to a task that has serial fraction   f , scaling the task to take the same amount of time as before, the speedup is Gustafson demonstrated with a 1024-processor system that the basic presumptions in Amdahl’s Law are inappropriate for massive parallelism [Gustafson88]. Gustafson found that the underlying principle that “the problem size scales with the number of processors, or with a more powerful processor, the problem expands to make use of the increased facilities is inappropriate” [Gustafson88]. Gustafson’s empirical results demonstrated that the parallel or vector part of a program scales with the problem size. Times for vector start-up, program loading, serial bottlenecks, and I/O that make up the serial component of the run do not grow with the problem size