Declare a 2D array −int[] a = new int[] { 65, 45, 32, 97, 23, 75, 59 };Let’s say you want the Kth smallest i.e, 5th smallest integer. Sort the array first −Array.Sort(a);To get the 5th smallest element −a[k - 1];Let us see the complete code −Exampleusing System; using System.IO; using System.CodeDom.Compiler; namespace Program { class Demo { static void Main(string[] args) { int[] a = new int[] { 65, 45, ... Read More
Firstly, set a jagged array.int[][] arr = new int[][] { new int[] { 0, 0 }, new int[] { 1, 2 }, new int[] { 2, 4 }, new int[] { 3, 6 }, new int[] { 4, 8 } };Now, use the GetLowerBound(), GetUpperBound() and Rank property to get the lenth and rank of the array as shown in the following code ... Read More
Mobile Computing deals with human computer interaction using mobile devices. It contains mobile hardware and software as well as mobile computing devices. A mobile computing infrastructure usually uses ad-hoc networks and communication protocols. This is considerably different than a traditional computing structure as it uses fixed topology and protocols.An image describing mobile computing architecture is as follows −As seen above, the mobile computing architecture contains various mobile devices such as mobile phones, mobile tablets, laptops etc. These devices are connected to the mobile network which is a part of the internet. All the data is linked to cloud computing data ... Read More
Firstly, set the two numbers to be multiplied.val1 = 10; val2 = 20;Now cal the method to find the product.product(val1, val2);Under the product method, a recursive call will get you the product.val1 + product(val1, val2 – 1)Let us see the complete code to find the product of 2 numbers using recusion.Exampleusing System; class Calculation { public static void Main() { int val1, val2, res; // the two numbers val1 = 10; val2 = 20; // finding product Demo d = new ... Read More
To find the rank of an array, use the Rank property.Firstly, declare and initialize an array.int[,] myArr = new int[3,3];Now, get the rank.myArr.RankLet us see the complete code −Example Live Demousing System; class Demo { static void Main() { int[,] myArr = new int[3,3]; Console.WriteLine("Rank of Array : " + myArr.Rank); } }OutputRank of Array : 2
Hashing is the process of generating a value from a text or a list of numbers using a mathematical function known as a hash function.There are many hash functions that use numeric numeric or alphanumeric keys. Different hash functions are given below:Hash FunctionsThe following are some of the Hash Functions −Division MethodThis is the easiest method to create a hash function. The hash function can be described as −h(k) = k mod nHere, h(k) is the hash value obtained by dividing the key value k by size of hash table n using the remainder. It is best that n is ... Read More
For volume and surface area of a sphere, firstly declare a variable with the value of radius.int r = 15;Get the volume f the sphere.// calculating volume of sphere cal_volume = (4.0 / 3) * (22 / 7) * r * r * r;Now the surface area of the sphere is calculated −cal_area = 4 * (22 / 7) * r * r;Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { double cal_area, cal_volume, r; // radius ... Read More
Declare and initialize a list.var products = new List (); products.Add("Accessories"); products.Add("Clothing"); products.Add("Footwear");To get the size, use the Capacity property.products.CapacityNow let us see the complete code to find the size of a list.Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { var products = new List (); products.Add("Accessories"); products.Add("Clothing"); products.Add("Footwear"); Console.WriteLine("Our list...."); foreach(var p in products) { Console.WriteLine(p); } Console.WriteLine("Size of list = " + products.Capacity); } }OutputOur list.... Accessories Clothing Footwear Size of list = 4
To find whether a number is divisibe by 2 is not, check what happens when the number is divisible by 2.If the remainder is 0, then the number is divisible by 2, else it is false −if (num % 2 == 0) { Console.WriteLine("Divisible by 2 "); } else { Console.WriteLine("Not divisible by 2"); }The following is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Test { static void Main(string[] args) { int num; num = 18; ... Read More
Let’s say our string is −String s = "HeathLedger!";Now create a new array.int []cal = new int[maxCHARS];Create a new method and pass both the string and the new array in it. Find the maximum occurrence of a character.static void calculate(String s, int[] cal) { for (int i = 0; i < s.Length; i++) cal[s[i]]++; }Let us see the complete code −Example Live Demousing System; class Demo { static int maxCHARS = 256; static void calculate(String s, int[] cal) { for (int i = 0; i < s.Length; i++) cal[s[i]]++; } ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP