Posts

Pr13

 Pizza parlor accepting maximum M orders. Orders are served in first come first served basis. Order once placed cannot be cancelled. Write C++ program to simulate the system using circular queue using array. Objectives:- 1. To understand concept of circular queue. #include <iostream> #include <string> using namespace std; class PizzaParlor { private:     string* orders;    // Array to store pizza orders     int front;         // Front pointer (for serving orders)     int rear;          // Rear pointer (for placing orders)     int capacity;      // Maximum capacity (M orders)     int size;          // Current number of orders public:     // Constructor to initialize the queue with a given capacity     PizzaParlor(int M) {         capacity = M;         orders = new ...

Pr12

 A double-ended queue (deque) is a linear list in which additions and deletions may be made at either end. Obtain a data representation mapping a deque into a one-dimensional array. Write C++ program to simulate deque with functions to add and delete elements from either end of the deque. Objectives:- 1. To understand concept of double ended queue. 2. To study the different types of double ended queues. #include <iostream> using namespace std; class Deque { private:     int* arr;       // Array to store deque elements     int front;      // Front pointer     int rear;       // Rear pointer     int capacity;   // Maximum size of deque     int size;       // Current size of deque public:     // Constructor to initialize deque with a given capacity     Deque(int cap) {         capacity = cap;     ...

Pr11

 Queues are frequently used in computer programming, and a typical example is the creation of a job queue by an operating system. If the operating system does not use priorities, then the jobs are processed in the order they enter the system. Write C++ program for simulating job queue. Write functions to add job and delete job from queue Objectives:- 1. To understand concept of queue. 2. To study the different types of queues. 3. To study the job scheduling problem as queue application. #include <iostream> #include <string> using namespace std; // Define a structure for a job node struct JobNode {     string jobID;  // Job identifier (could be a string or any type of ID)     JobNode* next; // Pointer to the next job node          JobNode(string id) : jobID(id), next(nullptr) {} }; // Class to represent a job queue class JobQueue { private:     JobNode* front; // Front pointer of the queue     JobNode*...

Pr10

 Implement C++ program for expression conversion as infix to postfix and its evaluation using stack based on given conditions: 1. Operands and operator, both must be single character. 2. Input Postfix expression must be in a desired format. 3. Only '+', '-', '*' and '/ ' operators are expected. OBJECTIVE: 1. Understand Stack ADT. 2. Understand stack application for Expression conversion and evaluation. #include <iostream> #include <stack> #include <cctype> #include <string> using namespace std; // Function to check if the character is an operator bool isOperator(char c) {     return (c == '+' || c == '-' || c == '*' || c == '/'); } // Function to get the precedence of the operator int precedence(char op) {     if (op == '+' || op == '-') {         return 1; // lower precedence     }     if (op == '*' || op == '/') {         return 2; // higher precedence     }   ...

pr9

 A palindrome is a string of character that‘s the same forward and backward. Typically, punctuation, capitalization, and spaces are ignored. For example, “Poor Dan is in a droop” is a palindrome, as can be seen by examining the characters “poor danisina droop” and observing that they are the same forward and backward. One way to check for a palindrome is to reverse the characters in the string and then compare with them the original-in a palindrome, the sequence will be identical. Write C++ program with functionsa)To print original string followed by reversed string using stack b)To check whether given string is palindrome or not #include <iostream> #include <stack> #include <string> #include <cctype> using namespace std; // Function to print original string followed by reversed string using stack void printOriginalAndReversed(const string& str) {     stack<char> s;     // Push each character of the string to the stack   ...

pr8

 Write C++ program for storing binary number using doubly linked lists. Write functions a)To compute 1‘s and 2‘s complement b)Add two binary numbers OBJECTIVES: 1. To understand concept of OOP. 2. To understand class structures for DLL in C++. 3. To understand primitive operations on DLL. #include <iostream> #include <string> using namespace std; // Define a structure for a doubly linked list node struct Node {     int bit;     Node* next;     Node* prev;          Node(int b) : bit(b), next(nullptr), prev(nullptr) {} }; // Class to represent a binary number using a doubly linked list class BinaryNumber { private:     Node* head;  // Head pointer for the doubly linked list     Node* tail;  // Tail pointer for the doubly linked list      public:     BinaryNumber() : head(nullptr), tail(nullptr) {}     // Function to add a bit at the end of the list (repr...

pr7

 Department of Computer Engineering has student's club named 'Pinnacle Club'. Students of Second, third and final year of department can be granted membership on request. Similarly one may cancel the membership of club. First node is reserved for president of club and last node is reserved for secretary of club. Write C++ program to maintain club member‘s information using singly linked list. Store student PRN and Name. Write functions to a) Add and delete the members as well as president or even secretary. b) Compute total number of members of club c) Display members d) Display list in reverse order using recursion e) Two linked lists exists for two divisions. Concatenate two lists #include <iostream> #include <string> using namespace std; // Define a structure for a student node struct Student {     string prn;     string name;     Student* next; }; // Define a class for managing the club's members class PinnacleClub { private:   ...