Briefly explain the steps to connect to Salesforce with Server-Side Controllers when working with aura components in Salesforce. Assume that you have already accomplished the following:
Write the steps in a doc file and upload the same.
Problem Statement
In this problem,you are given a sample of 3 years medical data. It is divided into Cancer, Stroke and Cardio vascular as columns and index respectively. In order to get an insight into this data, you need to find a correlation of each column against other columns in this dataset.
Your final answer would be to find out the maximum correlation of each column against other columns.
Consider a supervised training of a machine learning model where 80% of the training samples are of class C1 and the remaining are of class C2. The training accuracy of this classifier is computed as the ratio of “number of correct prediction” to “total number of predictions made”.
In which of these circumstances could the accuracy of the model be trusted the most?
A dog trainer wants to use reinforcement learning to teach new tricks to a dog at her home. She emulates a situation, and the dog tries to respond in many different ways. If the dog’s response is in the desired way, a treat is given.
Whenever the dog is exposed to the same situation, the dog executes a similar action with even more enthusiasm in expectation of getting more treats. The dog also learns what not do when faced with negative experiences.
In the given scenario, who could be the agent?
Problem Statement
You are working as a data analyst for the sports column of a leading News Paper Firm. As the 2016 Olympics has recently concluded, you need to publish the medal tally for each country as a bar graph for tomorrow’s sports column.
In this problem, you are given a data set containing medal tally of 21 countries. You need to analyze the data and plot a bar graph of the medals tally under each country.
You are given a 0-indexed array A of length N. You make an array B from A by inserting all the elements of A into a stack and removing the elements one by one in order. Similarly, you make an array C from A by inserting all the elements of A into a queue and removing the items one by one in order. Calculate sum(abs(Ci–Bi)) over all i from 0 to N-1 modulo 10^9+7.
Note, that due to the fixed order of addition and removal from a stack and a queue, B and C are uniquely determined.
You have defined a data structure that allows you to store a collection of elements in non-contiguous locations linearly. This is done by adding a reference to the next element in the current element i.e. The ith element stores the location for the (i+1)th element and so on.
Which of these data structures is being referred to in the given context?
You are asked to create a data managing system for a package delivery firm in MySQL. It is given that the firm manages salesmen who deliver packages to destination listed by the customer for a particular delivery. You have created the following tables in order to do so.
CREATE TABLE Salesman ( salesman_id INT NOT NULL, name VARCHAR(255) NOT NULL, city VARCHAR(255), comission DOUBLE(255, 2), PRIMARY KEY (salesman_id) ); CREATE TABLE Customer ( customer_id INT NOT NULL, cust_name VARCHAR(255) NOT NULL, city VARCHAR(255), grade INT, salesman_id INT, PRIMARY KEY (customer_id), FOREIGN KEY (salesman_id) REFERENCES Salesman(salesman_id) ); CREATE TABLE Orders ( ord_no INT NOT NULL, purch_amt DOUBLE(255, 2) NOT NULL, ord_date DATE, customer_id INT, PRIMARY KEY (ord_no), FOREIGN KEY (customer_id) REFERENCES Customer(customer_id) FOREIGN KEY (sales_id) REFERENCES Salesman(salesman_id) );
Orders
Customer
Salesman
Create a package as follows
1.Write a function that returns the level of the customer based on the grade(G) as follows:
Level is Silver if 50 <= G <= 150
Level is Gold if 151 <= G <= 300
Level is Diamond if 301 <= G <= 500
2.Write individual stored procedures to do the following
a. List out all the names of all customers with salesman_id equal to 5001, in alphabetical order.
b. Display the details of orders on 5th October 2012.
c. Increase the commission of a salesman by 0.2% if he/she works for a customer in a different city than the one he resides in.
3.Write a function with parameter argument given as sales_id and find the net purchase for the customer whose sales_id is equal to the parameter that is passed to the function.
Perform the above given tasks in your system and upload a doc file containing the solutions for the respective tasks.
Problem Statement
There exists a function “X” such that it accepts two input parameters A & B and whose output depends on the operation you decide to perform on A & B.
Write a program to display the operation of X using the two string inputs provided by the user.
Suppose you have two classes “B” and “C” which inherits the class “A” using public derivation. Now, you have created a class “D” by inheriting both “B” and “C”. When you tried to access the methods of class “A” using object of “D”, you found an ambiguity problem.
Which of the following will help you solve this problem?
The network given below takes state as an input and produces the probability distribution of actions.
What is the relation between the statement given below in this context?
Statement1: The given network is not entirely similar to a Deep Q Network
Statement2: The given network is a classification problem
A non-increasing sub-sequence is a sequence in which each subsequent element is not greater than the previous element.
You are given a number N. Calculate the number of numbers <= N whose decimal representation forms a non-increasing sub-sequence.
Example – 531 has a non-increasing decimal representation while 591 does not have a non-increasing decimal representation because 5<9.
You have been given an array and you have to find the length of the maximum zigzag subsequence. A Zig-Zag subsequence is a subsequence such that the elements are alternatingly increasing and decreasing.
You have been given the following pseudocode for finding the maximum length of zigzag sequence in a given array.
get the input in an array named arr initialise the a 2d array named Z[length of array][2] for base case make all entries as 1 /* Note: Z[i][0] = Length of the longest Zig-Zag subsequence ending at index i and last element is greater than its previous element Z[i][1] = Length of the longest Zig-Zag subsequence ending at index i and last element is smaller than its previous element */ loop 1: for i = 1 to length of array loop 2: for j = 0 to i if (X) Z[i][0] = Z[j][1] + 1 if( arr[j] > arr[i] && Z[i][1] < Z[j][0] + 1) Y find max of all entries and return the value
What can be used in place of X and Y to complete the pseudocode given above?
You have been given an array and a parameter k. You have to output the starting index of the subarray with size k, that has the minimum sum among all subarrays of size k present in the given array.
The pseudocode for doing the same is given below.
find the cumulative sum and store that in an array named carr: for int i = 0 to length of array csum[i] = arr[i] for int i = 1 to length of array X initialise the min_sum as csum[k-1] // first sub array initialise the index as 0 // starting index of first sub array for int i = k to length of array subarray_sum = csum[i] - csum[i-k-1] if( Y ): update min_sum update the index return index
What can be used in place of X and Y to complete the pseudocode?
You have written the following pseudocode to find the symmetric elements in an array.
get the input of array in an array named array initialise another array and store the reverse of previous array in an array name rev_array declare a counter variable now run a loop from i = 0 to end of array X update counter print this element end loop if counter == 0: print no symmetric element found
You need to display any symmetric elements found and display an appropriate message if there are no symmetric elements found. However a part X in the pseudo code is missing. Analyze the snippet and determine the appropriate statement to be placed in X?
[Note: A symmetric element is an element that does not change its position even if the array is reversed]
You have a text file called demo containing the following lines of text in a Linux system.
1. This is the first line of an experiment.
2. It is a text with experiment.
3. Lots of errors are present.
4. So much errors, all these errors are making me sick.
5. This is a line not containing any errors.
6. This is the last line of my experiment.
Now, you are asked to find all the lines containing the search pattern ‘experiment’ and print the lines matching the pattern in the shell. Which of these shell commands can you use for doing so?
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank5 to quit the whole browser session?
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank4 to replace the value of the header row with an empty string?
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank3 to get all the Columns of table with tag ‘td’?
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank2 to Get all the Rows of table with tag ‘tr’?
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank1 to create the object of the first table using the xpath “//div[@id=’mw-content-text’]//table[1]” to locate the table?
Consider the given code snippet.
class Product { private: string type; Product(string type) { this->type = type; } int getBasePrice() { switch (this->type) { case food: return 10; case drinks: return 7; case books: return 3; default: return 0; } } int getTaxPercent() { switch (this->type) { case food: case drinks: return 24; case books: return 8; default: return 0; } } string getProductCategory() { switch (this->type) { case food: case drinks: return 'Food and Beverages'; case books: return 'Education'; default: return '-'; } } }
You notice that when introducing a new product type in the code, you’ll have to make changes in three different methods of the class. Which of these design smells does the given snippet have?
Which of these functions in the given code snippet depicts a lazy code smell?
#include <iostream> using namespace std; int remainder(int a, int b) //Fun1 { return(a % b); } int add(int a, int b) //Fun2 { return (a + b); } int multiply(int a, int b) //Fun3 { return (a * b); } int main() { int sum; sum = add(100, 78); cout << "100 + 78 = " << sum << endl; mul = multiply(10, 78); cout << "10 * 78 = " << mul << endl; return 0; }
You are given an array A of N elements. You want to sort it in non-decreasing order using merge-sort algorithm. It involves using a recursive function mergeSort(A,l,r):
The initial call made is mergeSort(A,0,N). Find the number of times mergeSort function is called to sort the given array in non-decreasing order.
Consider an unbalanced tree (not necessarily a Binary Tree) of n nodes. You have to update weight of the n1th edge to n2 and print the maximum edge weight on the path from node n1 to node n2.
To achieve the above, you create a tree using an adjacency matrix representation of the tree (tree[][]).
Assume that you have found the sub-tree size, depth and the parent of each node using an appropriate graph algorithm and you could successfully decompose the tree into disjoint chains. What should be your next step towards achieving the above task?
You are using the algorithm given below to create a simple implementation of a Huffman tree.
loop a = EXTRACTMIN(N); if N = ∅ then return a endif; ν = EXTRACTMIN(N); create node κ with children a and b and weight w(k) = w(a) + w(b); add k to N
Analyze the algorithm and predict the worst case running time complexity for the same.
A famous chess grandmaster was analyzing one of his games in his head and… he suddenly forgot the positions of two important pieces.
However, he is sure about some facts:
In other words, he doesn’t remember the exact positions of the pieces, however, for every piece, he is sure about the part of the board where it can be. Part of the board here is just a rectangular submatrix described by 4 coordinates.
Note: obviously, two pieces can’t be in the same location.
Now the grandmaster is wondering, how many placements of this two pieces are possible if he remembers everything correctly?
A server has to serve n customers(labelled 1 through n). The service time required to serve ith customer is t(i) and is known in advance and there is no parallelism. If the customers are served in order, i.e., i1, i2,….in, the waiting time for customer i1 is t(i1), for customer i2 is t(i1)+t(i2), and so on.
What strategy should be used to serve all the customers in a minimum total time?
You are using the following algorithm to implement a queue by reusing two stacks.
A(q, x)
1) Push x to stack1
B(q)
1) If both stacks are empty then error.
2) If stack2 is empty
While stack1 is not empty, X
3) Pop the element from stack2 and return it.
What can be used in place of X to complete the algorithm?
[Assume that the size of stacks is unlimited.]
Consider the tables advisors and students given below.
CREATE TABLE `advisors` ( `advisor_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(255) NOT NULL, `last_name` varchar(255) NOT NULL, PRIMARY KEY (`advisor_id`) ) CREATE TABLE `students` ( `student_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(255) NOT NULL, `last_name` varchar(255) NOT NULL, `advisor_id` int(11) DEFAULT NULL, PRIMARY KEY (`student_id`), KEY `advisor_id` (`advisor_id`), CONSTRAINT `students_ibfk_1` FOREIGN KEY (`advisor_id`) REFERENCES `advisors` (`advisor_id`) );
Which of the following query can you use to get the information on students and their advisors, excluding students who are not assigned to an advisor?
You have created an Employee table as follows.
CREATE TABLE Employees ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, TerminationDate DATE, HireDate DATE, Primary Key(ID) );
In the given context, which of these is a correct way to define a constraint that says that the TerminationDate must be after the HireDate?
You are tasked to design an encryption system which accepts 2 parameters below:
The values for the locale parameter are as follows:
The encryption techniques followed by each locale is described below:
You are given N messages that need to be encrypted with respect to their locale parameter.
using System; using System.Collections.Generic; public class Example { public static void Main() { IDictionary<string, string> openWith = new Dictionary<string, string>(); openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); openWith.Add("txt", "notepad.exe"); Console.WriteLine("\nKey Added"); } }
You have to implement the concept of Exception Handling in Java. The final task is to return either the sum or difference of two numbers or the exception caught.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Sub task 1: If n is a factor of x, display the sum of x and n. Otherwise, display the difference between x and n.
Sub task 2: Catch Arithmetic Exception if occurred and display the exception caught.
Sub task 3: Catch Number Format Exception if occurred and display the exception caught.
Sub task 4: Catch any other Exception occurred and display the exception caught.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Sub task 1: Convert the list list1 and list2 into tuples tup and tup1, respectively.
Sub task 2: Display the tuple generated after multiplying the adjacent elements of the tuple tup.
Sub task 3: Create a tuple res storing the element-wise AND of tup and tup1.
Sub task 4: Display the list generated after chunking tuple res into z size.
You have to implement the concept of JSON in JavaScript. You are given an array of objects WordGame of length N. Each array object contains two data fields Tile and Score denoting an alphabet and score of that alphabet respectively. The final task is to return the maximum possible score a player can achieve by adding score of K number of tiles.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Subtask 1 : Parse the JSON object from the given string format and store into Array Scrabble.
Subtask 2 : Maximum possible score a player can achieve by adding K number of Tiles Array Scrabble.
You have to implement the concept of Friend function in C++. The final task is to create two classes Point and Distance. You have been provided with N points, each having (x,y)coordinates.
Class Point contains two integer data fields x and y denoting (x,y) coordinates of a point and a friend function MaxDistance().
Class Distance contains a function Find_Distance() which takes four integer parameters x1, x2, y1 and y2 and returns the distance between (x1,y1) and (x2,y2). Return the maximum distance between any two points from N points.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Subtask 1 : Create a class Point containing two data fields x and y , a constructor Point() and a friend function MaxDistance() .
Subtask 2 : Create a class Distance which contains a function Find_Distance() to find the distance between any two points and a friend function MaxDistance() .
Subtask 3 : Create a friend function MaxDistance() which takes a vector of Points and an object of distance to call Find_Distance() function .
A famous chess grandmaster was analyzing one of his games in his head and… he suddenly forgot the positions of two important pieces.
However, he is sure about some facts:
In other words, he doesn’t remember the exact positions of the pieces, however, for every piece, he is sure about the part of the board where it can be. Part of the board here is just a rectangular submatrix described by 4 coordinates.
Note: obviously, two pieces can’t be in the same location.
Now the grandmaster is wondering, how many placements of this two pieces are possible if he remembers everything correctly?
A server has to serve n customers(labelled 1 through n). The service time required to serve ith customer is t(i) and is known in advance and there is no parallelism. If the customers are served in order, i.e., i1, i2,….in, the waiting time for customer i1 is t(i1), for customer i2 is t(i1)+t(i2), and so on.
What strategy should be used to serve all the customers in a minimum total time?
You are using the following algorithm to implement a queue by reusing two stacks.
A(q, x)
1) Push x to stack1
B(q)
1) If both stacks are empty then error.
2) If stack2 is empty
While stack1 is not empty, X
3) Pop the element from stack2 and return it.
What can be used in place of X to complete the algorithm?
[Assume that the size of stacks is unlimited.]
A non-increasing sub-sequence is a sequence in which each subsequent element is not greater than the previous element.
You are given a number N. Calculate the number of numbers <= N whose decimal representation forms a non-increasing sub-sequence.
Example – 531 has a non-increasing decimal representation while 591 does not have a non-increasing decimal representation because 5<9.
You have been given an array and you have to find the length of the maximum zigzag subsequence. A Zig-Zag subsequence is a subsequence such that the elements are alternatingly increasing and decreasing.
You have been given the following pseudocode for finding the maximum length of zigzag sequence in a given array.
get the input in an array named arr initialise the a 2d array named Z[length of array][2] for base case make all entries as 1 /* Note: Z[i][0] = Length of the longest Zig-Zag subsequence ending at index i and last element is greater than its previous element Z[i][1] = Length of the longest Zig-Zag subsequence ending at index i and last element is smaller than its previous element */ loop 1: for i = 1 to length of array loop 2: for j = 0 to i if (X) Z[i][0] = Z[j][1] + 1 if( arr[j] > arr[i] && Z[i][1] < Z[j][0] + 1) Y find max of all entries and return the value
What can be used in place of X and Y to complete the pseudocode given above?
You have been given an array and a parameter k. You have to output the starting index of the subarray with size k, that has the minimum sum among all subarrays of size k present in the given array.
The pseudocode for doing the same is given below.
find the cumulative sum and store that in an array named carr: for int i = 0 to length of array csum[i] = arr[i] for int i = 1 to length of array X initialise the min_sum as csum[k-1] // first sub array initialise the index as 0 // starting index of first sub array for int i = k to length of array subarray_sum = csum[i] - csum[i-k-1] if( Y ): update min_sum update the index return index
What can be used in place of X and Y to complete the pseudocode?
You have written the following pseudocode to find the symmetric elements in an array.
get the input of array in an array named array initialise another array and store the reverse of previous array in an array name rev_array declare a counter variable now run a loop from i = 0 to end of array X update counter print this element end loop if counter == 0: print no symmetric element found
You need to display any symmetric elements found and display an appropriate message if there are no symmetric elements found. However a part X in the pseudo code is missing. Analyze the snippet and determine the appropriate statement to be placed in X?
[Note: A symmetric element is an element that does not change its position even if the array is reversed]
You are given a 0-indexed array A of length N. You make an array B from A by inserting all the elements of A into a stack and removing the elements one by one in order. Similarly, you make an array C from A by inserting all the elements of A into a queue and removing the items one by one in order. Calculate sum(abs(Ci–Bi)) over all i from 0 to N-1 modulo 10^9+7.
Note, that due to the fixed order of addition and removal from a stack and a queue, B and C are uniquely determined.
You have defined a data structure that allows you to store a collection of elements in non-contiguous locations linearly. This is done by adding a reference to the next element in the current element i.e. The ith element stores the location for the (i+1)th element and so on.
Which of these data structures is being referred to in the given context?
You are given an array A of N elements. You want to sort it in non-decreasing order using merge-sort algorithm. It involves using a recursive function mergeSort(A,l,r):
The initial call made is mergeSort(A,0,N). Find the number of times mergeSort function is called to sort the given array in non-decreasing order.
Consider an unbalanced tree (not necessarily a Binary Tree) of n nodes. You have to update weight of the n1th edge to n2 and print the maximum edge weight on the path from node n1 to node n2.
To achieve the above, you create a tree using an adjacency matrix representation of the tree (tree[][]).
Assume that you have found the sub-tree size, depth and the parent of each node using an appropriate graph algorithm and you could successfully decompose the tree into disjoint chains. What should be your next step towards achieving the above task?
You are using the algorithm given below to create a simple implementation of a Huffman tree.
loop a = EXTRACTMIN(N); if N = ∅ then return a endif; ν = EXTRACTMIN(N); create node κ with children a and b and weight w(k) = w(a) + w(b); add k to N
Analyze the algorithm and predict the worst case running time complexity for the same.
You have to implement the concept of Friend function in C++. The final task is to create two classes Point and Distance. You have been provided with N points, each having (x,y)coordinates.
Class Point contains two integer data fields x and y denoting (x,y) coordinates of a point and a friend function MaxDistance().
Class Distance contains a function Find_Distance() which takes four integer parameters x1, x2, y1 and y2 and returns the distance between (x1,y1) and (x2,y2). Return the maximum distance between any two points from N points.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Subtask 1 : Create a class Point containing two data fields x and y , a constructor Point() and a friend function MaxDistance() .
Subtask 2 : Create a class Distance which contains a function Find_Distance() to find the distance between any two points and a friend function MaxDistance() .
Subtask 3 : Create a friend function MaxDistance() which takes a vector of Points and an object of distance to call Find_Distance() function .
You have to implement the concept of Exception Handling in Java. The final task is to return either the sum or difference of two numbers or the exception caught.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Sub task 1: If n is a factor of x, display the sum of x and n. Otherwise, display the difference between x and n.
Sub task 2: Catch Arithmetic Exception if occurred and display the exception caught.
Sub task 3: Catch Number Format Exception if occurred and display the exception caught.
Sub task 4: Catch any other Exception occurred and display the exception caught.
You have to implement the concept of JSON in JavaScript. You are given an array of objects WordGame of length N. Each array object contains two data fields Tile and Score denoting an alphabet and score of that alphabet respectively. The final task is to return the maximum possible score a player can achieve by adding score of K number of tiles.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Subtask 1 : Parse the JSON object from the given string format and store into Array Scrabble.
Subtask 2 : Maximum possible score a player can achieve by adding K number of Tiles Array Scrabble.
You’ve been provided with a starter code which contains sub-tasks as defined below:
Sub task 1: Convert the list list1 and list2 into tuples tup and tup1, respectively.
Sub task 2: Display the tuple generated after multiplying the adjacent elements of the tuple tup.
Sub task 3: Create a tuple res storing the element-wise AND of tup and tup1.
Sub task 4: Display the list generated after chunking tuple res into z size.
Problem Statement
There exists a function “X” such that it accepts two input parameters A & B and whose output depends on the operation you decide to perform on A & B.
Write a program to display the operation of X using the two string inputs provided by the user.
Suppose you have two classes “B” and “C” which inherits the class “A” using public derivation. Now, you have created a class “D” by inheriting both “B” and “C”. When you tried to access the methods of class “A” using object of “D”, you found an ambiguity problem.
Which of the following will help you solve this problem?
You are tasked to design an encryption system which accepts 2 parameters below:
The values for the locale parameter are as follows:
The encryption techniques followed by each locale is described below:
You are given N messages that need to be encrypted with respect to their locale parameter.
using System; using System.Collections.Generic; public class Example { public static void Main() { IDictionary<string, string> openWith = new Dictionary<string, string>(); openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); openWith.Add("txt", "notepad.exe"); Console.WriteLine("\nKey Added"); } }
Problem Statement
In this problem,you are given a sample of 3 years medical data. It is divided into Cancer, Stroke and Cardio vascular as columns and index respectively. In order to get an insight into this data, you need to find a correlation of each column against other columns in this dataset.
Your final answer would be to find out the maximum correlation of each column against other columns.
Consider a supervised training of a machine learning model where 80% of the training samples are of class C1 and the remaining are of class C2. The training accuracy of this classifier is computed as the ratio of “number of correct prediction” to “total number of predictions made”.
In which of these circumstances could the accuracy of the model be trusted the most?
A dog trainer wants to use reinforcement learning to teach new tricks to a dog at her home. She emulates a situation, and the dog tries to respond in many different ways. If the dog’s response is in the desired way, a treat is given.
Whenever the dog is exposed to the same situation, the dog executes a similar action with even more enthusiasm in expectation of getting more treats. The dog also learns what not do when faced with negative experiences.
In the given scenario, who could be the agent?
The network given below takes state as an input and produces the probability distribution of actions.
What is the relation between the statement given below in this context?
Statement1: The given network is not entirely similar to a Deep Q Network
Statement2: The given network is a classification problem
Problem Statement
You are working as a data analyst for the sports column of a leading News Paper Firm. As the 2016 Olympics has recently concluded, you need to publish the medal tally for each country as a bar graph for tomorrow’s sports column.
In this problem, you are given a data set containing medal tally of 21 countries. You need to analyze the data and plot a bar graph of the medals tally under each country.
Consider the tables advisors and students given below.
CREATE TABLE `advisors` ( `advisor_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(255) NOT NULL, `last_name` varchar(255) NOT NULL, PRIMARY KEY (`advisor_id`) ) CREATE TABLE `students` ( `student_id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(255) NOT NULL, `last_name` varchar(255) NOT NULL, `advisor_id` int(11) DEFAULT NULL, PRIMARY KEY (`student_id`), KEY `advisor_id` (`advisor_id`), CONSTRAINT `students_ibfk_1` FOREIGN KEY (`advisor_id`) REFERENCES `advisors` (`advisor_id`) );
Which of the following query can you use to get the information on students and their advisors, excluding students who are not assigned to an advisor?
You have created an Employee table as follows.
CREATE TABLE Employees ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, TerminationDate DATE, HireDate DATE, Primary Key(ID) );
In the given context, which of these is a correct way to define a constraint that says that the TerminationDate must be after the HireDate?
You are asked to create a data managing system for a package delivery firm in MySQL. It is given that the firm manages salesmen who deliver packages to destination listed by the customer for a particular delivery. You have created the following tables in order to do so.
CREATE TABLE Salesman ( salesman_id INT NOT NULL, name VARCHAR(255) NOT NULL, city VARCHAR(255), comission DOUBLE(255, 2), PRIMARY KEY (salesman_id) ); CREATE TABLE Customer ( customer_id INT NOT NULL, cust_name VARCHAR(255) NOT NULL, city VARCHAR(255), grade INT, salesman_id INT, PRIMARY KEY (customer_id), FOREIGN KEY (salesman_id) REFERENCES Salesman(salesman_id) ); CREATE TABLE Orders ( ord_no INT NOT NULL, purch_amt DOUBLE(255, 2) NOT NULL, ord_date DATE, customer_id INT, PRIMARY KEY (ord_no), FOREIGN KEY (customer_id) REFERENCES Customer(customer_id) FOREIGN KEY (sales_id) REFERENCES Salesman(salesman_id) );
Orders
Customer
Salesman
Create a package as follows
1.Write a function that returns the level of the customer based on the grade(G) as follows:
Level is Silver if 50 <= G <= 150
Level is Gold if 151 <= G <= 300
Level is Diamond if 301 <= G <= 500
2.Write individual stored procedures to do the following
a. List out all the names of all customers with salesman_id equal to 5001, in alphabetical order.
b. Display the details of orders on 5th October 2012.
c. Increase the commission of a salesman by 0.2% if he/she works for a customer in a different city than the one he resides in.
3.Write a function with parameter argument given as sales_id and find the net purchase for the customer whose sales_id is equal to the parameter that is passed to the function.
Perform the above given tasks in your system and upload a doc file containing the solutions for the respective tasks.
You have a text file called demo containing the following lines of text in a Linux system.
1. This is the first line of an experiment.
2. It is a text with experiment.
3. Lots of errors are present.
4. So much errors, all these errors are making me sick.
5. This is a line not containing any errors.
6. This is the last line of my experiment.
Now, you are asked to find all the lines containing the search pattern ‘experiment’ and print the lines matching the pattern in the shell. Which of these shell commands can you use for doing so?
Consider the given code snippet.
class Product { private: string type; Product(string type) { this->type = type; } int getBasePrice() { switch (this->type) { case food: return 10; case drinks: return 7; case books: return 3; default: return 0; } } int getTaxPercent() { switch (this->type) { case food: case drinks: return 24; case books: return 8; default: return 0; } } string getProductCategory() { switch (this->type) { case food: case drinks: return 'Food and Beverages'; case books: return 'Education'; default: return '-'; } } }
You notice that when introducing a new product type in the code, you’ll have to make changes in three different methods of the class. Which of these design smells does the given snippet have?
Which of these functions in the given code snippet depicts a lazy code smell?
#include <iostream> using namespace std; int remainder(int a, int b) //Fun1 { return(a % b); } int add(int a, int b) //Fun2 { return (a + b); } int multiply(int a, int b) //Fun3 { return (a * b); } int main() { int sum; sum = add(100, 78); cout << "100 + 78 = " << sum << endl; mul = multiply(10, 78); cout << "10 * 78 = " << mul << endl; return 0; }
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank5 to quit the whole browser session?
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank4 to replace the value of the header row with an empty string?
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank3 to get all the Columns of table with tag ‘td’?
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank2 to Get all the Rows of table with tag ‘tr’?
You are using the code shown below to handle Dynamic WebTables with Selenium in C#. However, parts of the code are incomplete. Identify and complete the code snippets that are missing and complete the code.
using System; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Collections.Generic; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://website-link"); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); var elemTable = Blank 1 List<IWebElement> lstTrElem = new List<IWebElement>(Blank 2); String strRowData = ""; foreach (var elemTr in lstTrElem) { List<IWebElement> lstTdElem = new List<IWebElement>(Blank 3); if (lstTdElem.Count > 0) { foreach (var elemTd in lstTdElem) { strRowData = strRowData + elemTd.Text + “\t\t"; } } else { Console.WriteLine("This is Header Row"); Console.WriteLine(Blank4(" ", "\t\t")); } Console.WriteLine(strRowData); strRowData = String.Empty; } Console.WriteLine(""); Blank 5 } } }
What should be used at Blank1 to create the object of the first table using the xpath “//div[@id=’mw-content-text’]//table[1]” to locate the table?