instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
How would you optimize a loop which runs over an array?
codefeedback
Debug the following code and explain why it gave an error. def sum(a, b): try: return a + b except TypeError: return "inputs should be numbers" finally: print("This function has successfully executed") output = sum(1, '2')
codefeedback
Sort the following list by the third element of the sublists in ascending order. [[1,2,3], [0,0,1], [7,8,9], [8,7,2]]
codefeedback
Compute the big-O time complexity for this algorithm. def factorial(n): if n == 0: return 1 else: return n*factorial(n-1)
codefeedback
Analyze the runtime complexity of this algorithm. def factorial2(n): fact = 1 for i in range(1, n + 1): fact *= i return fact
codefeedback
Find the probability of a random variable following a normal distribution with a mean of 10 and a standard deviation of 2. x = 12
codefeedback
Write pseudocode for the merge sort algorithm.
codefeedback
Given an array of integers and an integer target, find all unique combinations of elements from the array that sum up to the target. arr = [1,2,3,4], target = 7
codefeedback
What is a multithreaded application and how does it work?
codefeedback
Write a Python program to get the volume of a sphere with a given radius.
codefeedback
Construct a code to print elements of a given list in reverse order. [1, 2, 3, 4, 5]
codefeedback
Create an HTML page that displays a table with all the prime numbers up to 100.
codefeedback
Write an SQL query to retrieve all records with a salary higher than average salary from a table named “employees”.
codefeedback
What is dependency injection and how can it be implemented with JavaScript?
codefeedback
Write a C program to print out the Fibonacci series upto the nth number.
codefeedback
Suggest an alternate solution to the following JavaScript code. var names = ["Jon", "Bob", "Mike"]; for (var i=0; i<names.length; i++) { console.log(names[i]); }
codefeedback
Write a PHP code for creating a database table with 4 columns to store user information.
codefeedback
Create a function to remove all the characters in a string except a-z, A-Z and 0-9.
codefeedback
Write a function to reverse the elements of a list without creating a new list.
codefeedback
Create an Angular Directive for a text box that alerts when its contents change.
codefeedback
Describe the Heap Sort algorithm.
codefeedback
Write an algorithm to check whether a given word is palindrome or not.
codefeedback
Calculate the number of anagrams present in a given string. string = "listen"
codefeedback
Write code to return a list of prime numbers in the given range. Start: 10. End: 15
codefeedback
Write code to convert a given hexadecimal string to a binary string. Hexadecimal string: 7468
codefeedback
Code a program to display the prime factors of a number. 30
codefeedback
Develop a code to check if a given array is sorted or not. [1, 2, 4, 3]
codefeedback
Find the most frequent word in the following paragraph. The quick brown fox jumps over the lazy dog.
codefeedback
Based on the following list, create a dictionary of each name and their corresponding birth date. names = ["John", "Mary", "James", "Susan"] birth_dates = ["1992-12-24", "1979-05-17", "1995-08-15", "1985-04-10"]
codefeedback
Suggest a way to identify and remove duplicate elements from the list. numbers = [2, 3, 2, 5, 8, 3, 10]
codefeedback
Create a function that sorts a list of dictionaries using the values. animals = [{"name": "Dog", "age": 5}, {"name": "Cat", "age": 3}, {"name": "Fish", "age": 1}, {"name": "Deer", "age": 8}]
codefeedback
Convert this expression in to postfix notation. A + B * C
codefeedback
Generate a class for a Student object in Java.
codefeedback
Calculate the sum of these two numbers in assembly language. x = 27, y = 11
codefeedback
Debug this JavaScript code. function mysteryFunction(x) { let result = 0; for (let i = 1; i <= x; i++) { result = result * i; } return result; }
codefeedback
Develop a program to encode and decode a given string. Input a string s to be encoded.
codefeedback
Create a neural network in Python using the given input and output. Input a set of 3 input values (x1, x2, x3) and two output values (y1, y2).
codefeedback
Design an algorithm in Python to detect anomalies in the given data. Input a dataset containing two columns, temperature and pressure.
codefeedback
Rewrite the following function to optimize its performance. def indexString(listStr, s): output = [] for i in listStr: if s in i: output.append(i) return output
codefeedback
Generate a string array of length 10, containing only alphabets in lower case containing 10 random characters.
codefeedback
Write a factorial program without using the inbuilt factorial function in Python.
codefeedback
Create a software program that encrypts a text message.
codefeedback
Generate an array of length n with random numbers in the range 0 - 100
codefeedback
How would you write a program to determine the greatest common divisor (GCD) of two non-negative integers?
codefeedback
How would you sort an array of integers using Merge Sort algorithm?
codefeedback
Generate a list of 10 random numbers between 0 and 500 in Python.
codefeedback
Write an SQL query to retrieve all customers whose age is between 18 and 35.
codefeedback
Suggest an algorithm to find the number of nodes in a binary tree.
codefeedback
Write a predicate to check for valid email syntax.
codefeedback
Modify the code to create an AI model to classify the given dataset. dataset = { 'x1': ['apple', 'banana'], 'x2': ['red', 'yellow'], 'label': ['fruit', 'fruit'] }
codefeedback
Create a Ruby program to display elements of an array in the reverse order.
codefeedback
Create a Java program which calculates the area of a circle.
codefeedback
What is the difference between an interface and an abstract class?
codefeedback
Create a function that, given a number, reverses the digits and returns them in an array. 12345
codefeedback
Create a command to delete a folder with all its contents. /root/folder
codefeedback
Construct a SQL query that returns all users who did not login in the last 24 hours.
codefeedback
Write a python program to convert a number from base 10 to base 8.
codefeedback
Generate a JavaScript function to perform binary search for a given array.
codefeedback
Create a SQL query to select the name, address and email of customers who placed an order in the last 30 days.
codefeedback
Calculate the surface area of a sphere with radius 6m.
codefeedback
Using PHP, write a program to check if a string contains only alphabets.
codefeedback
Create a Python program to return the longest word in a sentence "The dog likes to run around the yard"
codefeedback
In Java, write a method which takes a two-dimensional array as input and prints it in spiral order. [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
codefeedback
Create a SQL query to find the average salary of all the employees who were hired between 2019 and 2021.
codefeedback
Generate a correct program to sum the even numbers from 0 to n.
codefeedback
Create a program to create a new string where the first and last occurrence of each character is removed. 'Hello World'
codefeedback
Design a program which can take an array of integers and output the index of the maximum element. [10, 4, 15, 6, 20]
codefeedback
Create a function that takes a string of characters and returns the minimal number of division/multiplication operations needed to make all characters within the string the same. acdc
codefeedback
Create a function to convert a given decimal number to its corresponding hexadecimal value.
codefeedback
Create a function that takes a dictionary, a key and a value as parameters and adds the key and value to the given dictionary. my_dict = { 'fruit': 'apple' }
codefeedback
Write a code to generate a random string of length n with lowercase alphabets and numbers.
codefeedback
Write a JavaScript code to print all substrings of a given string.
codefeedback
Implement a vector class in Python that allows for basic vector operations such as vector addition, subtraction and scalar multiplication.
codefeedback
Derive the Hamming distance between two strings using the edit distance algorithm. s1 = 'saturday', s2 = 'sunday'
codefeedback
Write a SQL query to list the top 3 customers with highest total purchases in the last 6 months.
codefeedback
How would you perform a two-way pivot table in Python using Pandas?
codefeedback
Write a Python class that implements a sorted list. No input.
codefeedback
Reorder the items in an array according to their length. Array: ['this', 'is', 'a', 'test']
codefeedback
Create classes to represent a credit card and account holder. No input.
codefeedback
Using the following data, convert the X and Y coordinates into longitude and latitude. X: 83.206226 Y: 42.821810
codefeedback
Create a boolean function called "is_num_even" which takes in a number and returns true if the number is even.
codefeedback
Compute the Fibonacci series up to the following number n.
codefeedback
Create an array of all the prime numbers up to 50.
codefeedback
Write a code to convert the provided string into an array of numbers. string_two = "01,2,3,4,5,6"
codefeedback
Write a code to find the maximum length of the longest consecutive increasing subsequence in the given array. arr = [2, 3, 1, 10, 5, 6, 8, 7]
codefeedback
Make the following code thread-safe by implementing mutex locks. #include <pthread.h> int global_int = 0; void* inc_func(void* arg) { global_int++; return NULL; } int main() { pthread thread_a, thread_b; ... return 0; }
codefeedback
Create a function to evaluate a mathematical expression like "3 + 5 * 4".
codefeedback
Create an efficient matrix multiplication of two given matrices. matrix1 = [[1, 2], [3, 4]] matrix2 = [[5, 6], [7, 8]]
codefeedback
Become an algorithm to check if a linked list is empty.
codefeedback
Design an algorithm to produce a binary tree from given inorder and preorder traversals. inorder: [4,2,5,1,3,6] preorder: [1,2,4,5,3,6]
codefeedback
Create a code to generate a Mulberry Tree of height n levels.
codefeedback
Generate a program to remove duplicates from an unsorted linked list.
codefeedback
Create a Python program to take a float input and output its binary equivalent. 25.68
codefeedback
Using regex, find all the words that have a specific character at the start. the words that start with 'a'
codefeedback
Find the Fibonacci number for a given number using a for loop.
codefeedback
Write the C++ code to print the smallest prime factor of a given number number = 54
codefeedback
Create a program in python that sorts a given list.
codefeedback
Use a loop to find the average of all given numbers. [1, 2, 3, 4, 5]
codefeedback
Create a Java method that takes in an integer array and returns it sorted. [7, -2, 4, 21, 0]
codefeedback
Using the provided data, train a decision tree to predict whether a given house should be classified as a "small" or "large" house. house_size = [1000, 1100, 1250, 1300, 1400, 1500] house_label = ["small", "small", "small", "large", "large", "large"]
codefeedback