Binary Search Tree

# include <iostream> # include <cstdlib> using namespace std; struct nod//node declaration { int info; struct nod *l; struct nod *r; }*r; class BST { public://functions declaration void search(nod *, int); void find(int, nod **, nod **); void insert(nod *, nod *); void del(int); void casea(nod *,nod *); void caseb(nod *,nod *); void casec(nod *,nod... Continue Reading →

Binary Heap

#include <iostream> #include <cstdlib> #include <vector> #include <iterator> using namespace std; class BHeap { private: vector <int> heap; int l(int parent); int r(int parent); int par(int child); void heapifyup(int index); void heapifydown(int index); public: BHeap() {} void Insert(int element); void DeleteMin(); int ExtractMin(); void showHeap(); int Size(); }; int main() { BHeap h; while (1)... Continue Reading →

Programming Principles

•Problem specification –our approach must be to determine overall goals, but precise ones, and then slowly divide the work into smaller problems until they become of manageable size. •Program design –Each part of a large program must be well organized, clearly written, and thoroughly understood, •Choice of  data structures –How they are arranged in relation... Continue Reading →

Sum of elements of array

#include <iostream> using namespace std; int main (){ int arr[] = {6,12,4,7,9 }; int n = 7, sum = 0; for(int i = 0; i<n ; i++){ sum+=arr[i]; } cout<<"The array sum is "<<sum; return 0; }

Tower of Hanoi

Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: 1) Only one disk can be moved at a time.2) Each move consists of taking the upper disk from one of... Continue Reading →

Linked Lists

Menu Driven Program For All Operations #include <stdio.h> #include <iostream> #include <limits.h> #include <stdlib.h> #include <bits/stdc++.h> using namespace std; struct node { int data; struct node *next; }; struct header { float avg; int max1,min1,max2,min2,totalnode; struct node *next; }; void headerfunc(struct header *); void insertf(struct header *); void deletef(struct header *); void bubble_sort(struct header *);... Continue Reading →

Arrays

Menu Driven Program For All Operations #include <stdio.h> #include <iostream> #include <limits.h> #include <stdlib.h> using namespace std; void insert(int *ar,int*n); void deletef(int *ar,int*n); void bubble_sort(int *ar,int*n); void display(int *ar,int*n); void avg(int *ar,int*n); void max_min(int *ar,int*n); void max2_min2(int *ar,int*n); void disp_odd(int *ar,int*n); void disp_even(int *ar,int*n); int main(void) { int n=0,ar[1000],i=0,c=0; cout<<"Enter size of array(max. 999) :... Continue Reading →

Book class 2

Imagine a publishing company that markets both books and audio- cassette version of its works. Create a class Publication in C++ that stores the title (a string) and price (type float) of a publication. From this class derive two classes: Book, which adds a page count and Tape, which adds playing time in minutes. These... Continue Reading →

Distance Measure

Define two classes Distance1 and Distance2 in C++. Distance1 stores distance in miles and Distance2 in kmeters & meters. Reads values of the class objects and adds one object of Distance1 with the object of Distance2 class. The display should be in the format of miles or kmeters & meters depending on the type of... Continue Reading →

Volume of box 1

Design a class named Box whose dimensions are integers and private to the class. The dimensions are labelled: length l, breadth b, and height h. The default constructor of the class should initialize l, b, h and to 0. The parameterized constructor Box(int length, int breadth, int height) should initialize Box's l, b and h... Continue Reading →

ComputerUserAccess 1

Users of the computer have profile which consists of Name, Password, and Access Rights. Access rights take on values X, R, W, and A. It is possible to have default values for Password and Access rights which are the first three letters of the Name and ALL respectively. Users can change their password and access... Continue Reading →

Class and Objects 3

Create a class Employees which have a number, rank, and salary. When an employee is first recruited then all these are given values of 0. Upon confirmation, the actual values of these are entered for the employee. At the time of promotion their rank can be incremented by 1 and an employee gets an increment... Continue Reading →

BankAccountClass 2

Define a class in C++ to represent a bank account. Include the following members: Data members: a) Name of the depositor containing charecters and space only b) Account number as of integer type of 4 digit c) Type of account as either saving or current d) Balance amount in the account positive integer Member functions:... Continue Reading →

You have been given a set of complex number. It is desired to add and substract the complex number.

Input Format First line contains one integer representing the real part of first complex number. Second line contains one integer representing the imaginary part of first complex number. Third line contains one integer representing the real part of second complex number. Fourth line contains one integer representing the imaginary part of second complex number. Constraints... Continue Reading →

C++ & Object Oriented Programming

“C++: where friends have access to your private members.” — Gavin Russell Baker. C++ is an object oriented computer language created by extraordinary computer scientist Bjorne Stroustrop as part of the evolution of the C family of languages. It is a general purpose programming language and is widely used these days for competitive programming. It has... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started