Sai Subramanyam

Sai Subramanyam

67 Articles Published

Articles by Sai Subramanyam

Page 2 of 7

Search Element in an Javascript Hash Table

Sai Subramanyam
Sai Subramanyam
Updated on 15-Jun-2020 456 Views

We've kind of already implemented this in our put method. Let us look at it again in isolation.Exampleget(key) {    let hashCode = hash(key);    for(let i = 0; i < this.container[hashCode].length; i ++) {       // Find the element in the chain       if(this.container[hashCode][i].key === key) {          return this.container[hashCode][i];       }    }    return undefined; }You can test it using.Examplelet ht = new HashTable(); ht.put(10, 94); ht.put(20, 72); ht.put(30, 1); ht.put(21, 6); ht.put(15, 21); ht.put(32, 34); console.log(ht.get(20)); console.log(ht.get(21)); console.log(ht.get(55)); console.log(ht.get(32));OutputThis will give the output.{ key: 20, ...

Read More

Loop through a hash table using Javascript

Sai Subramanyam
Sai Subramanyam
Updated on 15-Jun-2020 2K+ Views

Now let us create a forEach function that'll allow us to loop over all key-value pairs and call a callback on those values. For this, we just need to loop over each chain in the container and call the callback on the key and value pairs.ExampleforEach(callback) {    // For each chain    this.container.forEach(elem => {       // For each element in each chain call callback on KV pair       elem.forEach(({ key, value }) => callback(key, value));    }); }You can test this using.Examplelet ht = new HashTable(); ht.put(10, 94); ht.put(20, 72); ht.put(30, 1); ht.put(21, 6); ...

Read More

The HashTable Class in Javascript

Sai Subramanyam
Sai Subramanyam
Updated on 15-Jun-2020 197 Views

Here is the complete implementation of the HashTable class. This could of course be improved by using more efficient data structures and collision resolution algorithms.Exampleclass HashTable {    constructor() {       this.container = [];       // Populate the container with empty arrays       // which can be used to add more elements in       // cases of collisions       for (let i = 0; i < 11; i++) {          this.container.push([]);       }    }    display() {       this.container.forEach((value, index) => ...

Read More

Binary Tree in Javascript

Sai Subramanyam
Sai Subramanyam
Updated on 15-Jun-2020 295 Views

Binary Tree is a special data structure used for data storage purposes. A binary tree has a special condition that each node can have a maximum of two children. A binary tree has the benefits of both an ordered array and a linked list as search is as quick as in a sorted array and insertion or deletion operation are as fast as in the linked list.Here is an illustration of a binary tree with some terms that we've discussed below −Important TermsFollowing are the important terms with respect to the tree.Path − Path refers to the sequence of nodes ...

Read More

Source code of ABAP reports without restriction

Sai Subramanyam
Sai Subramanyam
Updated on 14-Feb-2020 577 Views

If you have to use RFC, you can write RFC enabled function module. You can write a new FM that allows you to retrieve program source code. To start with, you need to create a structure as shown in below and based on which you have to create a table type. This table can be passed to a RFC function.Here shows a table type that you can use in Function Module:Next step is to create a function module with RFC-enabled. You have to pass parameters while creating function module.function zsrcex_extractor . *"---------------------------------------------------------------------- *"*"Local Interface: *"  IMPORTING *"     VALUE(PACKAGE_SIZE) ...

Read More

How can we create multicolumn UNIQUE indexes?

Sai Subramanyam
Sai Subramanyam
Updated on 28-Jan-2020 165 Views

For creating multicolumn UNIQUE indexes we need to specify an index name on more than one column. Following example will create a multicolumn index named ‘id_fname_lname’ on the columns ‘empid’, ’first_name’, ’last_name’ of ‘employee’ table −mysql> Create UNIQUE INDEX id_fname_lname on employee(empid, first_name, last_name); Query OK, 0 rows affected (0.41 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> describe employee; +------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+-------+ | empid | int(11) | YES | MUL | NULL | | | first_name | varchar(20) | YES | | NULL | | | ...

Read More

How to create array of strings in Java?

Sai Subramanyam
Sai Subramanyam
Updated on 19-Dec-2019 2K+ Views

In Java, you can create an array just like an object using the new keyword. The syntax of creating an array in Java using new keyword −type[] reference = new type[10];Where, type is the data type of the elements of the array.reference is the reference that holds the array.And, if you want to populate the array by assigning values to all the elements one by one using the index −reference [0] = value1; reference [1] = value2;You can declare an array of Strings using the new keyword as &mius;String[] str = new String[5]; And then, you can populate the string ...

Read More

How to unset a JavaScript variable?

Sai Subramanyam
Sai Subramanyam
Updated on 13-Sep-2019 18K+ Views

To unset a variable in JavaScript, use the undefined. After that, use delete operator to completely remove it.Let’s try the code snippet again.var str = “Demo Text”; window.onscroll = function() {    var y = this.pageYOffset;    if(y > 200) {       document.write(nxt);       nxt = undefined; // unset      delete(nxt); // this removes the variable completely      document.write(nxt); // the result will be undefined } }

Read More

The Maximum Data Rate of a Channel

Sai Subramanyam
Sai Subramanyam
Updated on 05-Aug-2019 13K+ Views

Data rate refers to the speed of data transfer through a channel. It is generally computed in bits per second (bps). Higher data rates are expressed as Kbps ("Kilo" bits per second, i.e.1000 bps), Mbps ("Mega" bits per second, i.e.1000 Kbps), Gbps ("Giga" bits per second, i.e. 1000 Mbps) and Tbps ("Tera" bits per second, i.e. 1000 Gbps).One of the main objectives of data communications is to increase the data rate. There are three factors that determine the data rate of a channel:Bandwidth of the channelNumber of levels of signals that are usedNoise present in the channelData rate can be ...

Read More

Python Vs Ruby, which one to choose?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 196 Views

First thing comes in my mind, why to compare these two language only? This may be because both are interpreted, agile languages with an object oriented philosophy and very huge communities support. However, though both languages share some ideas, syntax elements and have almost the same features the two communities have nothing in common.Both the languages are very popular among the developer’s community (This is also one of the reasons to compare). Below are the top ten most popular languages in 2018 on GitHub based on opened pull request −Top 10 most popular languages on GitHub based on opened pull ...

Read More
Showing 11–20 of 67 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements