ProblemWe are required to write a JavaScript function that takes in a number n as the only input. Suppose a sequence u for which,u1 = 0 and u1 = 2Our function should find the of un for which,6unun+1- 5unun+2+un+1un+2 = 0ExampleFollowing is the code − Live Democonst num = 13; const sequenceSum = (num = 1) => { const res = Math.pow(2, num); return res; }; console.log(sequenceSum(num));Output8192
In this post, we will understand the difference between PGH and S/MIME −PGPIt has been designed to process plain text.It is not expensive in comparison to S/MIME.It can be used personally as well as at offices.It is less efficient in comparison to S/MIME.It depends on the key exchange made by the user.It is less convenient in comparison to S/MIME.It contains 4096 public keys.It is considered as the standard for strong encryption.It can be used in VPNs.It uses Diffie-Hellman digital signature.S/MIMEIt has been designed to process email and multimedia files.It is relatively expensive.It is used in industrial purposes.It is more efficient ... Read More
In this post, we will understand the difference between system calls fork and vfork −The ‘fork’ system callIn this system call, the child and parent process have separate memory spaces.The child and parent process are executed simultaneously.This call uses the copy-on-write as alternative.Child process doesn’t have the ability to suspend execution of the parent process in this system call.The page of one process doesn’t get affected by the page of other process.It is more frequently used.No address space is wasted.If the child process alters the page in the address space, it is not visible to the parent process.The ‘vfork’ system ... Read More
ProblemWe are required to write a JavaScript function that takes in a string which has integers inside it separated by spaces.The task of our function is to convert each integer in the string into an integer and return their sum.ExampleFollowing is the code − Live Democonst str = '1 5 12 76 2'; const sumStringNumbers = (str = '') => { const findSum = (arr = []) => { const sum = arr.reduce((acc, val) => acc + val); return sum; }; let sum = 0; const arr = str .split(' ') .map(Number); sum = findSum(arr); return sum; }; console.log(sumStringNumbers(str));Output96
ProblemWe are required to write a JavaScript function that takes in a 2-Dimensional array of m X n order of numbers containing the same number of rows and columns.For this array, our function should count and return the following sum−$\sum_{i=1}^m \sum_{j=1}^n (-1)^{i+j}a_{ij}$ExampleFollowing is the code − Live Democonst arr = [ [4, 6, 3], [1, 8, 7], [2, 5, 9] ]; const alternateSum = (arr = []) => { let sum = 0; for(let i = 0; i < arr.length; i++){ for(let j = 0; j < arr[i].length; j++){ const multiplier = (i + j) % 2 === 0 ? 1 : -1; sum += (multiplier * arr[i][j]); }; }; return sum; }; console.log(alternateSum(arr));Output7
In this post, we will understand the difference between symmetric and asymmetric multiprocessing −Asymmetric MultiprocessingIn this kind of multiprocessing, the processors are not considered as equal.The task of the operating system is done by the master processor.There is no communication between the processors since they are controlled by the master processor only.In this multiprocessing, process follow the master-slave pattern.The systems are relatively inexpensive.This kind of multiprocessing systems are easier to design.Symmetric MultiprocessingIn this kind of multiprocessing, all the processors are considered equal.The tasks of the operating system are done by individual processors.All the processors communicate with each other since they ... Read More
ProblemWe are required to write a JavaScript function that takes in an array of number. Our function should return that first number from the array whose value and 0-based index are the same given that there exists at least one such number in the array.ExampleFollowing is the code − Live Democonst arr = [9, 2, 1, 3, 6, 5]; const findFirstSimilar = (arr = []) => { for(let i = 0; i < arr.length; i++){ const el = arr[i]; if(el === i){ return i; }; }; }; console.log(findFirstSimilar(arr));Output3
ProblemWe are required to write a JavaScript function that takes in a string and encrypts it based on the following algorithm −The string contains only space separated words.We need to encrypt each word in the string using the following rules−The first letter needs to be converted to its ASCII code.The second letter needs to be switched with the last letter.Therefore, according to this, the string ‘good’ will be encrypted as ‘103doo’.ExampleFollowing is the code − Live Democonst str = 'good'; const encyptString = (str = '') => { const [first, second] = str.split(''); const last = str[str.length - 1]; ... Read More
In this post, we will understand the difference between microkernel and monolithic kernel −MicrokernelIt is smaller in size.In this kernel, the services are kept in a separate address space.It executes slowly in comparison to monolithic kernel.It can be extended easily.If a service crashes, it effects the working of the microkernel.The code to build a microkernel is large.Examples of microkernel include: QNX, Symbian, L4Linux, Singularity, K42, Integrity, PikeOS, HURD, Minix, Mac OS X, and Coyotos.Monolithic KernelIn monolithic kernel, both user services and kernel services are kept in the same address space.Monolithic kernel is larger than microkernel.It executes quickly in comparison to ... Read More
ProblemWe are required to write a JavaScript function that takes in a string and encrypts it based on the following algorithm −The string contains only space separated words.We need to encrypt each word in the string using the following rules −The first letter needs to be converted to its ASCII code.The second letter needs to be switched with the last letter.Therefore, according to this, the string ‘good’ will be encrypted as ‘103doo’.ExampleFollowing is the code − Live Democonst str = 'good'; const encyptString = (str = '') => { const [first, second] = str.split(''); const last = str[str.length - ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP