C++ program for hashing with chaining

sudhir sharma
Updated on 19-Sep-2019 07:13:39

2K+ Views

Hashing is the method by which we can map any length data element to a fixed size key. hashing works as key-value pairs.Hashing function is the function that does the mapping in a hash map. the data elements that are given as input to the Hash Function may get same hash key. In this case the elements may overlap. To avoid overlapping of elements which have the same hash key the concept of chaining was introduced.Creating a hashmapIn order to create a hashmap we need hashing function that will define the index value of the data element.We have a hash ... Read More

C++ Mathematical Functions

sudhir sharma
Updated on 19-Sep-2019 07:05:50

3K+ Views

Mathematical calculations can be done in C++ programming language using the mathematical functions which are included in math or cmath library. These mathematical functions are defined to do complex mathematical calculations. Let’s learn each of them one by one −sineThe sin method is used to calculate the sin of the angle given as an argument in degrees. This function accepts one double integer as an argument and returns a double integer which is the value of sin(x°).double sin(double)Calling syntaxdouble x = sin(23.4);Example Live Demo#include #include using namespace std; int main(){    double x = 45.3;    cout

Why is using “for…in” with array iteration a bad idea in javascript?

Ayush Gupta
Updated on 19-Sep-2019 06:57:52

95 Views

Using for..in loops in JavaScript with array iteration is a bad idea because of the following behavior −Using normal iteration loops −Examplelet arr = [] arr[4] = 5 for (let i = 0; i < arr.length; i ++) {    console.log(arr[i]) }Outputundefined undefined undefined undefined 5If we had iterated over this array using the for in construct, we'd have gotten −Examplelet arr = [] arr[4] = 5 for (let i in arr) {    console.log(arr[i]) }Output5Note that the length of the array is 5, but this still iterates over only one value in the array.This happens because the purpose of ... Read More

C++ map having key as a user defined data type

sudhir sharma
Updated on 19-Sep-2019 06:52:55

885 Views

A map is a data structure that stores information in the form of key and value pairs. In C++, map is defined in STL (standard template library) and store keys in an ordered form.Syntax to define a map −map map_name;The data type of any of these two data of the map can be any of the data types. We can have any of the primary data types or derived data types as key or value data types in a map.We can use any of the data types as the data type of the key of the map. Even a user-defined ... Read More

C++ interview questions on virtual function and abstract class

sudhir sharma
Updated on 19-Sep-2019 06:44:52

918 Views

What is a virtual function?A virtual function is a method that does not have a definition when defined in the base class. This method is left black in the parent class and it is redefined in the child class.What is an abstract class?An abstract class is a class that has abstract members or at least one pure virtual function in its definition. An abstract class can never be instanced (creating an object). It can only be inherited and the methods could be overwritten.Can there be any virtual Destructors?Yes, These are legal in C++, but these are destructors are for base ... Read More

What is the differences between TreeMap, HashMap and LinkedHashMap in Java?

Nitin Sharma
Updated on 18-Sep-2019 14:36:22

1K+ Views

HashSet and ArrayList both are one of the most important classes of the Java Collection framework.The following are the important differences between TreeMap, HashMap and LinkedHashMap.Sr. No.KeyTreeMapHashMapLinkedHashMap1Ordering of elementsThe elements inserted in TreeMap are sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.In case of HashMap it does not guarantees as to the order of the map also it does not guarantee that the order will remain constant over time.LinkedHashMap follows the insertion order of elements and also maintaining an order of elements inserted into ... Read More

What is the differences between HashMap and HashTable in Java

Nitin Sharma
Updated on 18-Sep-2019 14:35:37

724 Views

HashMap and HashTable both are one of the most important classes of Java Collection framework. Both HashMap and HashTable stores the data in key value pair and at the time storing data hashing is used to hash the key and the resulting hash code is used as the index at which the value is stored within the table. But still, there are many differences between both these classes which we would discuss below.The following are the important differences between HashMap and HashTable.Sr. No.KeyHashMapHashTable1IntroductionHashmap is the advanced version of HashTable and is introduced as a new class in JDK 1.2.HashTable on ... Read More

Difference between throw and throws in Java

Nitin Sharma
Updated on 18-Sep-2019 14:29:22

9K+ Views

Both throw and throws are the concepts of exception handing in which throw is used to explicitly throw an exception from a method or any block of code while throws are used in the signature of the method to indicate that this method might throw one of the listed type exceptions.The following are the important differences between throw and throws.Sr. No.Keythrowthrows1DefinitionThrow is a keyword which is used to throw an exception explicitly in the program inside a function or inside a block of code.Throws is a keyword used in the method signature used to declare an exception which might get ... Read More

Difference between Thread.start() and Thread.run() in Java.

Nitin Sharma
Updated on 18-Sep-2019 14:28:24

6K+ Views

As we know that start() and run() are the two important methods of multithreading and one is used to create a new thread while other is used to start executing that thread.Following are the important differences between Thread.start() and Thread.run().Sr. No.Keystart()run()1Implementationstart method of thread class is implemented as when it is called a new Thread is created and code inside run() method is executed in that new Thread.While if run method is executed directly than no new Thread is created and code inside run() will execute on current Thread and no multi-threading will take place.2Definitionstart method is defined in thread ... Read More

Difference between String and Character array in Java.

Nitin Sharma
Updated on 18-Sep-2019 14:27:27

5K+ Views

On technical groud, we can say that both a character array and string contain the sequence of characters and used as a collection of characters. But there are significant differences between both which we would discuss below.The following are the important differences between String and Character array.Sr. No.KeyStringCharacter array1ImplementationString is implemented to store sequence of characters and to be represented as a single data type and single entity.Character Array on the other hand is a sequential collection of data type char where each element is a separate entity.2Internal implementationString internal implementation makes it immutable in nature.Character array is mutable in ... Read More

Advertisements