Month: June 2014

OOP in C++

Posted on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

THE COPY CONSTRUCTOR

The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy constructor is used to:

  • Initialize one object from another of the same type.
  • Copy an object to pass it as an argument to a function.
  • Copy an object to return it from a function.

If a copy constructor is not defined in a class, the compiler itself defines one. If the class has pointer variables and has some dynamic memory allocations, then it is a must to have a copy constructor. The most common form of copy constructor is shown here:

classname (const classname &obj){   // body of constructor}

Here, obj is a reference to an object that is being used to initialize another object.

#include<iostream>

classLine

{

public:

int getLength(void);

Line(int len );             // simple constructor

Line(constLine&obj);  // copy constructor

~Line();                     // destructor

private:

int*ptr;

};

// Member functions definitions including constructor

Line::Line(int len)

{

cout <<“Normal constructor allocating ptr”<< endl;

// allocate memory for the pointer;

ptr =newint;

*ptr = len;

}

Line::Line(constLine&obj)

{

cout <<“Copy constructor allocating ptr.”<< endl;

ptr =newint;

*ptr =*obj.ptr;// copy the value

}

Line::~Line(void)

{

cout <<“Freeing memory!”<< endl;

delete ptr;

}

intLine::getLength(void)

{

return*ptr;

}

void display(Line obj)

{

cout <<“Length of line : “<< obj.getLength()<<endl;

}

// Main function for the program

void main()

{   Line line(10);

display(line);}

When the above code is compiled and executed, it produces the following result:

Normal constructor allocating ptr

Copy constructor allocating ptr.

Length of line : 10

Freeing memory!

Freeing memory!

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Functional Dependency

Posted on Updated on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

 

·         In the process of efficiently storing data, and eliminating redundancy, tables in a database are designed and created to be in one of five possible normal forms.  Each normal form contains and enforces the rules of the previous form, and, in turn, applies some stricter rules on the design of tables.·         A set of tables in a database are initially said to be in 0 normal form. First Normal Form:

  • Tables are said to be in first normal form when:-
  • The table has a primary key.-
  • No single attribute (column) has multiple values.-
  • The non-key attributes (columns) depend on the primary key.
  • Some examples of placing a table in first normal form are:

2

In first normal form the table : –

4

 

Second Normal Form:

  • Tables are said to be in second normal form when:
  • o   The tables meet the criteria for first normal form.
  • If the primary key is a composite of attributes (contains multiple columns), the non key attributes (columns) must depend on the whole key.
  • Third Normal Form:
  •  Tables are said to be in third normal form when:
  • o   The tables meet the criteria for second normal form.
  • o   Each non-key attribute in a row does not depend on the entry in another key column. Fourth
  • Normal Form:
  • Tables are said to be in fourth normal form when:
  • o  The table meets the criteria for third normal form.
  •  Situations where non-key attributes depend on the key column exclusive of other non-key columns are eliminated. Fifth Normal
  • Form:
  • Tables are said to be in fifth normal form when:
  • o The table meets the criteria for fourth normal form.
  • o The table consists of a key attribute and a non-key attribute only.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

OOP in C++

Posted on

For the students of FYBSc (IT), SYBSc (CS), SYBCA

C++ Identifiers:

  • A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).
  • C++  does  not  allow  punctuation  characters  such  as  @,  $,  and  %  within  identifiers.
  • C++ is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C++.

 

  • Here are some examples of acceptable identifiers:

Name1                        abc                  move_name                    a_123

Myname_50                num1              num2                           temp retVal

 

C++ Keywords:

  • The following list shows the reserved words in C++.  These reserved words may not be used as constant or variable or any other identifier names.

else      new    this  Auto         enum             operator          throw             Bool    explicit

private             true    Break              export   protected   try  Case   extern   public   typedef

Catch   false   register   typeid  Char   float   reinterpret_cast    typename

Class  for  return  union Const  friend  short         unsigned const_cast   goto  signed  using

continue  If      sizeof             virtual             Default  inline  Static  void Delete  int  static_cast              volatile

Do  long          Struct              Double            mutable                      Switch                          while  dynamic_cast  namespace  Template

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

 

 

Functional Dependency

Posted on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

Functional Dependency

Functional dependency (FD) is set of constraints between two attributes in a relation. Functional dependency says that if two tuples have same values for attributes A1, A2,…, An then those two tuples must have to have same values for attributes B1, B2, …, Bn.

Functional dependency is represented by arrow sign (→) that is X→Y, where X functionally determines Y. The left hand side attributes determines the values of attributes at right hand side.

Armstrong’s Axioms

If F is set of functional dependencies then the closure of F, denoted as F+, is the set of all functional dependencies logically implied by F. Armstrong’s Axioms are set of rules, when applied repeatedly generates closure of functional dependencies.

  • Reflexive rule: If alpha is a set of attributes and beta is_subset_of alpha, then alpha holds beta.
  • Augmentation rule: if a → b holds and y is attribute set, then ay → by also holds. That is adding attributes in dependencies, does not change the basic dependencies.
  • Transitivity rule: Same as transitive rule in algebra, if a → b holds and b → c holds then a → c also hold. a → b is called as a functionally determines b.

Trivial Functional Dependency

  • Trivial: If an FD X → Y holds where Y subset of X, then it is called a trivial FD. Trivial FDs are always hold.
  • Non-trivial: If an FD X → Y holds where Y is not subset of X, then it is called non-trivial FD.
  • Completely non-trivial: If an FD X → Y holds where x intersect Y = Φ, is said to be completely non-trivial FD.

Normalization

If a database design is not perfect it may contain anomalies, which are like a bad dream for database itself. Managing a database with anomalies is next to impossible.

  • Update anomalies: if data items are scattered and are not linked to each other properly, then there may be instances when we try to update one data item that has copies of it scattered at several places, few instances of it get updated properly while few are left with there old values. This leaves database in an inconsistent state.
  • Deletion anomalies: we tried to delete a record, but parts of it left undeleted because of unawareness, the data is also saved somewhere else.
  • Insert anomalies: we tried to insert data in a record that does not exist at all.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

Trees in Data structures

Posted on

USEFUL FOR FYBSC (IT), FYBCA STUDENTS  

 

Trees

 Binary Trees

The simplest form of tree is a binary tree. A binary tree consists of

  1. a node (called the root node) and
  2. left and right sub-trees.
    Both the sub-trees are themselves binary trees.

03

A binary tree

The nodes at the lowest levels of the tree (the ones with no sub-trees) are called leaves.

In an ordered binary tree,

  1. the keys of all the nodes in the left sub-tree are less than that of the root,
  2. the keys of all the nodes in the right sub-tree are greater than that of the root,
  3. the left and right sub-trees are themselves ordered binary trees.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

OOP in C++

Posted on

OBJECT ORIENTED PROGRAMMING

 

  • OOPstands for Object Oriented Programming. This is a technique used to develop programs revolving around the real world entities. In OOPs programming model, programs are developed around data rather than actions and logics.
  • In OOPs, every real life object has properties and behavior, which is achieved through the class and object creation. They contain properties (variables of some type) and behavior (methods). OOPs provide a better flexibility and compatibility for developing large applications.
  • Reusability of Code:  In object oriented programming one class can easily copied to another application if we want to use its functionality .E.g.  When we work with hospital application and railway reservation application .In both application we need person class  so we have to write only one time the person class  and it can easily use in other application.
  • Easily Discover a bug: When we work with procedural programming it take a lot of time to discover a bug and resolve it .But in object   Oriented Programming   due to modularity of classes we can easily discover the bug and we have to change in one class only and this change make in all the application only by changing it one class only.
  • Object- Oriented Programming enables us to easily model our applications based on the real world which help us to easily identify the requirements, what code is to be written and how different classes interact with each other which have same properties and behaviors.

APPLICATIONS OF OOPS

  • OOP has become one of the programming buzz words today. There appears to be a great deal of excitement and interest among software engineers in using OOP.
  • Applications of OOP are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as window. Hundreds of windowing systems have been developed, using the OOP techniques. Real-business system are often much more complex and contain many more objects with complicated attributes and method. OOP is useful in these types of application because it can simplify a complex problem. The promising areas of application of OOP include:
  •   Real-time system
  •   Simulation and modeling
  •   Object-oriented data bases
  •   Hypertext, Hypermedia, and expertext
  •   AI and expert systems
  •   Neural networks and parallel programming
  •   Decision support and office automation systems
  •   CIM/CAM/CAD systems

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

DATA BASE ARCHITECTURE

Posted on Updated on

USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS

 

DATABASE MODEL

  •  A database model defines the logical design of data. The model describes the relationships between different parts of the data.
  • Basically three models are  –

(i)                Hierarchical model

(ii)              Network model

(iii)            Relational model

  •  Hierarchical model

In his model each entity has only one parent but can have several children. At the top of hierarchy there is only one entity which is called ROOT.

2

  • Network model

In the network model, entities are organized in a graph, in which some entities can be accessed through several paths.

3

  • Relational model

In this model, data is organized in two-dimensional tables called relations. The tables or relation are related to each other.

4

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Interview Questions in Data structures

Posted on

USEFUL FOR FYBSC (IT), FYBCA STUDENTS  

1.)  Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.

i.)      Prefix Notation: – * +ABC ^ – DE + FG

ii.)    Postfix Notation: AB + C * DE – FG + ^ –

2.)  Sorting is not possible by using which of the following methods? (Insertion, Selection, Exchange, Deletion)

An.) Sorting is not possible in Deletion. Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can be done just using deletion.

3.)  List out few of the applications that make use of Multilinked Structures?

(i)                Sparse matrix,

(ii)              Index generation.

4.)  In tree construction which is the suitable efficient data structure? (Array, Linked list, Stack, Queue)

An.)Linked list is the suitable efficient data structure

5.)  Classify the Hashing Functions based on the various methods by which the key value is found.

  1. Direct method,
  2. Subtraction method,
  3. Modulo-Division method,
  4. Digit-Extraction method,
  5. Mid-Square method,
  6. Folding method,
  7. Pseudo-random method

6.)  What are the types of Collision Resolution Techniques and the methods used in each of the type?

  • Open addressing (closed hashing),the methods used include: Overflow block.
  • Closed addressing (open hashing),The methods used include: Linked list, Binary tree

7.)  Whether Linked List is linear or Non-linear data structure?

An.)

According to Access strategies Linked list is a linear one.
According to Storage Linked List is a Non-linear one

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Classes and Objects in C++

Posted on

Introduction to Classes and Objects

 

  •  The classes are the important feature of C++ that leads to Object  Oriented Programming (OOP).
  •  Class is user defined data type, which holds its own data  members(member function and member variable), which can be  accessed and used by creating instance of that class
  •  Object – Objects have states and behaviors.
  •  Example:  A  dog  has  states  –  color,  name,  breed  as  well  as  behaviors – wagging, barking, eating. An object is an instance of a  class.
  •  Class – A class can be defined as a template/blueprint that describes  the behaviors/states that object of its type support.
  •  Methods – A method is basically a behavior. A class can contain  many methods. It is in methods where the logics are written, data is  manipulated and all the actions are executed.

Instant Variables – Each object has its unique set of instant variables. An object’s state is created by the values assigned to these instant variables.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

 

Application of Zener diode as voltage regulator:

Posted on

3

  • Zener diode works on reverse bias or in zener region the voltage across it is substantially constant for a large change of current through it. This characteristic permits the zener diode to be used as a voltage regulator.
  •  The zener diode maintains a constant voltage across the load spite of any change in load current or input voltage. Above figure is a very simple voltage regulator circuit requiring just one zener diode and one resistor. As long as the input voltage is a few volts more than the desired output voltage, the voltage across the zener diode will b stable.
  • As the input voltage increase the current through the zener diode increases but the voltage drop remains constant-a feature of zener diodes.
  • Review Questions

1)      Define semiconductor.

2)      What is meant by biasing of p-n junction diode?

3)      What is meant by the term “barrier potential”? What is its value for silicon and germanium diodes?

4)      Explain the formation of Depletion region in the unbiased p-n junction.

5)      Explain the working and characteristics of p-n junction diode.

6)      Compare ideal and practical diode.

7)       Compare zener and p-n junction diode.

8)      Zener diode can be used as voltage regulator. Justify.

9)      What is rectifier? With the help of neat circuit diagram and waveform explain the operation of a half rectifier circuit. Why this circuit is called ‘half wave’ circuit?

10)  Compare HW, FW and bridge rectifier.

 

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com