instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Explain the advantages and disadvantages of using different sorting algorithms for linked lists, and provide a recommendation based on the specific characteristics of the linked list. | codefeedback |
Create a function that takes in a list of integers and returns a new list containing only the even numbers from the original list. The function should have a time complexity of O(n), where n is the length of the input list. Additionally, the function should not use any built-in functions or libraries to solve the probl... | codefeedback |
Generate a programming workflow for analyzing a large text dataset.
Dataset size: 100 million words | codefeedback |
What is the Global Interpreter Lock (GIL) in Python, what is its purpose, and how does it affect multi-threading in Python? | codefeedback |
Write a code to print out an array of the first ten prime numbers. | codefeedback |
Compute the square root of a number without using the square root function. The number can be a positive integer or a decimal number with up to 2 decimal places. The solution should have a time complexity of O(log n), where n is the given number. The solution should also be accurate up to 4 decimal places.
Example:
In... | codefeedback |
Capitalize the letters A - Z in the given string and reverse the order of the words in the string.
text = "We are learning natural language processing" | codefeedback |
Write a regular expression to match words containing exactly two 'a' characters, with any number of other characters before, between, and after the 'a' characters. | codefeedback |
Construct a for loop to print the integer from 0 to 50, but only print the even numbers. | codefeedback |
Replace all the instances of the string 'x' with the string 'y' in the given list, while maintaining the order of the elements.
list = [1, 2, 'x', 'x', 1, 'x', 'y', 'x'] | codefeedback |
Generate a C++ program to sum up the elements of an array, but with the following additional requirements:
1. The program should use a recursive function to calculate the sum.
2. The program should also calculate the product of the elements in the array using a separate recursive function.
3. The program should allow t... | codefeedback |
Generate a random hex color in Python that starts with the letter 'F' and has exactly 6 characters. | codefeedback |
Given an array of integers in Java, output all distinct items from the array in descending order. If there are duplicate items in the array, consider them as a single item and only include one occurrence of each item in the output. | codefeedback |
Write a function in Python to split a given string into the words in the string.
The function should also handle special cases such as:
1. Handling multiple spaces between words.
2. Ignoring leading and trailing spaces in the input string.
3. Ignoring punctuation marks such as commas, periods, and exclamation marks ... | codefeedback |
Convert this list of strings to a single string without using the "join" method. Additionally, ensure that all the words in the resulting string are capitalized.
str_list = ["i", "am", "a", "list", "of", "strings"] | codefeedback |
Use regular expression to determine the number of words in a string, where a word is defined as a sequence of alphabetic characters separated by at least one space, punctuation mark, or digit. The string may contain special characters and must be case sensitive. This is a sample string with 100 words. | codefeedback |
Design a data structure to model the evolution of a population, taking into account factors such as genetic mutations, environmental changes, and competition for resources. The data structure should be able to track individual organisms, their traits, and their interactions within the population. Additionally, it shoul... | codefeedback |
Create a C++ variable with the name "name" that can store a string value, but the string must be exactly 10 characters long and contain only lowercase letters. | codefeedback |
Convert the given data, which consists of a list of dictionaries containing the names and ages of individuals, into an Excel format. The output should include the names and ages in separate columns, with the names aligned to the left and the ages aligned to the right. The names should be in uppercase, and the ages shou... | codefeedback |
Given a list of numbers, implement a quick sort algorithm that can handle a large input size of n (where n > 10^6) efficiently. The algorithm should have a time complexity of O(nlogn) and should not exceed the space complexity of O(logn). The input list may contain duplicate numbers and the algorithm should be able to ... | codefeedback |
Edit the following code to return a length 5 array of zeros, but without using any built-in array functions or loops.
int[] array = new int[10];
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
array[4] = 0;
array[5] = 0;
array[6] = 0;
array[7] = 0;
array[8] = 0;
array[9] = 0; | codefeedback |
Generate a unique 12 digit alphanumeric ID using Java, where the alphanumeric characters can only be uppercase letters (A-Z) and the numbers (0-9). The ID should have at least 4 distinct letters and at least 4 distinct numbers. | codefeedback |
Write a SQL query to select all the customers who have made at least 5 transactions in the past month and have an account balance of more than $1000. | codefeedback |
Generate an SQL query that will combine two tables, ensuring that only the rows where the id column in table A is greater than 1 are included in the result. Table A has 2 columns (id and name) and 2 rows (1, Tom) and (2, Abigail). Table B has 2 columns (id and address) and 2 rows (1, USA) and (2, Canada). | codefeedback |
Generate a class in Java for a contact record, including name, age, phone number, email, address, and additional social media information such as Facebook profile URL, Twitter handle, and Instagram username.
The class should also include methods to:
1. Validate the email address format.
2. Validate the phone number fo... | codefeedback |
Generate an HTML form in PHP to gather user information such as name, address, email, and phone number. Validate the email address to ensure it is in a correct format (e.g. example@example.com) and validate the phone number to ensure it is in a correct format (e.g. +1-555-123-4567). | codefeedback |
Write a function to output the maximum value possible from a given array, with the constraint that the maximum value must be a prime number. If no prime number is present in the array, return -1.
Example:
Input: [10, 12, 15, 20, 22]
Output: -1
Input: [2, 5, 7, 9, 11]
Output: 11 | codefeedback |
Write a Python program that reads a list of words and prints the most frequently used one. If there are multiple words that have the same highest frequency, print all of them.
['apple', 'banana', 'orange', 'apple']
# Additional Requirements:
1. The program should not be case-sensitive when counting the frequency of ... | codefeedback |
Create a text classifier using supervised learning with a minimum accuracy requirement of 90% on the validation set. | codefeedback |
Generate a numpy array of shape (3,3) with random values between 0 and 10, where all the values in each row are unique and strictly increasing. | codefeedback |
Create a machine learning model that predicts whether an email is spam or not, while also identifying the specific type of spam, such as phishing, malware, or fraudulent emails. | codefeedback |
Write a Python program to check whether a number is Armstrong or not. An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153. The program should prompt the user to enter ... | codefeedback |
Create a HTML form to take user input from a web page. Add client-side validation to ensure that the user enters a valid email address before submitting the form. | codefeedback |
Create a select query to fetch all the customers with a name starting with 'A' and have a phone number that ends with '9'. | codefeedback |
Explain the concept of polymorphism in programming and provide an example of how it can be implemented in a specific programming language of your choice. | codefeedback |
Design a program to select the names of the students who have secured more than 80% marks in a given exam. The program should also calculate and display the average marks of all the students.
students = [("John", 75), ("Mary", 90), ("Simon", 80), ("Rose", 80)]
In addition to finding the students who have secured more... | codefeedback |
Write a SQL query to return the 5 oldest employees from a table named 'employees', who have at least 10 years of work experience and are currently employed in the company. | codefeedback |
Write a shell command to print the system IP address, but restrict the use of any built-in commands or utilities specific to a certain operating system or shell. | codefeedback |
Write a JavaScript function that extracts the domain name from an email address. The function should handle all possible scenarios, including email addresses with different top-level domains (e.g. .com, .org, .net) and email addresses with multiple subdomains. The function should also account for any special characters... | codefeedback |
Write a function in Python that takes four strings as parameters and returns a single string with all strings concatenated together. The function should only use a single line of code and cannot use any built-in string concatenation methods or functions (e.g., +, join()). | codefeedback |
Write a SQL query to select the users from table 'users' who are born after 1985 and have at least 1000 followers.
#Difficulty Increase Reasoning#
By adding an additional condition of having at least 1000 followers, we are increasing the complexity of the query. This requires joining the 'users' table with the 'follow... | codefeedback |
Categorize a given tweet based on sentiment, considering positive, negative, or neutral tones, and also identify the sentiment strength as strong or weak.
"This new software program is supposed to make life so much easier!" | codefeedback |
Create a function 'subStr' that takes a string and a start and end index and returns a substring between the start and end index. The start index should be inclusive, but the end index should be exclusive. The function should have a time complexity of O(n), where n is the length of the string. The function should also ... | codefeedback |
Write a method 'addString' in Java that takes two strings as parameters and returns a single string that concatenates the two strings. The method should also remove any duplicate characters in the resulting string, and the characters should be sorted in ascending order. | codefeedback |
Create a function in Java that takes a string as a parameter and returns the string in lowercase letters. However, you are not allowed to use any built-in string manipulation methods or libraries to convert the string to lowercase. You must implement the conversion logic yourself using only basic string operations and ... | codefeedback |
Select what section of the code must be changed for the following C++ code snippet to compile correctly, ensuring that the output "Hello World!" is displayed.
int main() {
std:cout << "Hello World!";
return 0;
}
New Constraints and Requirements:
1. The code must use only the "iostream" header for input/output ... | codefeedback |
Suggest an additional function needed to complete the following program. The function should reverse a linked list in-place.
class Node:
def __init__(self, data):
self.data = data
self.next = None
def reverse_list(self):
# Implementation of the reverse_list function
# Your code... | codefeedback |
Provide instructions to create a doubly linked list in Java with the following constraints: each node should store both a key and a value, the list should support adding nodes at the head and tail, and the list should have a method to remove a node given its key. | codefeedback |
Suggest an optimized solution to the following problem: Write a program that sorts a list of strings in alphabetical order using a divide-and-conquer approach. The program should handle a large number of strings (up to 10^6) efficiently. Implement your solution in Python. The input list of strings, list_of_strings, may... | codefeedback |
Construct a SQL query to get the names, address, age, and salary of employees who have been with the company for more than 5 years, are in the sales department, and have a salary higher than the average salary of all employees in the company. | codefeedback |
Extract the unique elements from a given list of numbers while maintaining the original order of occurrence.
list_of_nums = [5, 2, 5, 3, 7, 8, 2]
Time Complexity Requirement: O(n)
Space Complexity Requirement: O(n)
You are not allowed to use any built-in functions or libraries that directly solve the problem. | codefeedback |
Define a function to compare two strings using only bitwise operations. | codefeedback |
Explain what is the purpose of the try-except block and provide a code example that demonstrates the use of nested try-except blocks to handle different types of exceptions. | codefeedback |
Implement a function to generate the Fibonacci series upto 'n' terms, where n is a positive integer less than or equal to 50. The function should handle input validation and throw an error if n is not within the specified range. The function should return the Fibonacci series as a list of integers. | codefeedback |
Parse the given markup language to extract out the attributes and their corresponding values, and then calculate the sum of all the numeric values found in the attributes. | codefeedback |
Write a function that takes in a positive integer from the user and returns the sum of all the odd numbers from 1 to that number multiplied by 3. The function should handle inputs greater than 1. | codefeedback |
Explain the purpose of a deadlock in a multithreaded program and describe a situation where a deadlock may occur with at least three threads, each requiring a specific resource, and provide a solution to prevent deadlock. | codefeedback |
Identify the parts of speech in the following sentence: "John said: "Let's go to the zoo." | codefeedback |
Given a byte sequence, identify the sequence that produces the following output: "H e l l o W o r l d !"
#Additional Instructions#
1. The byte sequence should consist of ASCII characters only.
2. The byte sequence should be in the range of 0 to 127.
3. The byte sequence should be in little-endian format.
4. The byte... | codefeedback |
Implement a function that performs matrix addition for two given matrices. The matrices are represented as two-dimensional arrays, where each array represents a row of the matrix. The function should return the result matrix.
The matrices can have varying sizes, but are guaranteed to have the same number of rows and c... | codefeedback |
Read the code and determine all the variables that have been declared or used.
def func(x, y, z):
a = x + y + z
b = x * y * z
c = a / b
d = a % b
e = b ** 2
f = a // b
return c, d, e, f | codefeedback |
Create a function to test if a given integer is a prime palindrome number. A prime palindrome number is a number that is both prime and a palindrome. | codefeedback |
Create a Regular Expression to match URLs, but also capture and extract specific parts of the URL such as the domain name and query parameters. | codefeedback |
We need to find all unique combinations of elements from a given list of items, such that the sum of the combination is equal to a given target value.
[1, 2, 3, 4]
New requirement: The combination should contain at least 2 elements. | codefeedback |
Implement an in-place Merge Sort algorithm in C++, where the input array cannot be modified and the sorting must be done without using any additional data structures. | codefeedback |
Create a set of transformation rules to convert a valid XML document to a valid HTML document, while preserving the nested structure and attributes of the elements. Additionally, ensure that any references to external resources, such as images or stylesheets, are properly translated to the corresponding HTML tags. | codefeedback |
Develop a convolutional neural network (CNN) for image classification using a deep learning framework. The CNN should have at least 5 convolutional layers and 2 fully connected layers. Each convolutional layer should have a different number of filters and kernel sizes. Implement a suitable activation function for each ... | codefeedback |
We need to write a program to generate all permutations of a given string, but with the following additional constraints:
1. The program should not use any built-in libraries or functions for generating permutations.
2. The program should be able to handle strings of length up to 10 characters.
3. The program should ou... | codefeedback |
Write a regex expression that matches sentences with the word "cat" followed by any number of characters except the letter "z" and ends with a period. | codefeedback |
We need to build a function to compute the product of the elements of a given array, but with the following constraints:
1. The function should only consider the elements that are multiples of 3 in the array.
2. The function should ignore any element that is equal to 4 in the array.
3. The function should handle negati... | codefeedback |
Create a function that takes a string and a number n, then return the n characters from the end of the string in reverse order. Additionally, ensure that the function can handle string inputs containing special characters such as punctuation marks and whitespace. | codefeedback |
Write a python program that takes a string as a parameter and prints the character at index 4 if the length of the string is greater than 4. The program should also handle cases where the string contains leading or trailing whitespace characters. Additionally, the program should only consider alphabetical characters in... | codefeedback |
You are given a list of numbers and you need to calculate the standard deviation of the numbers. The input list can contain duplicate numbers.
Write a function `calculate_standard_deviation(nums: List[int]) -> float` that takes in a list of integers `nums` and returns the standard deviation as a float.
The standard d... | codefeedback |
List all the methods available in the axelrod python library, excluding any methods that contain the letter 'e' in their name. | codefeedback |
Create a function that takes two strings, two string lengths, and returns true if the second string is a rotation of the first. A rotation is defined as shifting all the characters of a string by a certain number of positions and wrapping around to the beginning.
Example:
```python
string1 = "Hello World"
string2 = "... | codefeedback |
Compute P(A | B) given that P(B | A) = 0.8, P(A) = 0.4, P(B) = 0.7, and you can only use a constant amount of additional memory (i.e., no data structures can be used to store intermediate results). | codefeedback |
Solve the quadratic equation 3x^2 + 8x + 4 = 0 using the quadratic formula.
#Advanced Test#
Solve the quadratic equation 3x^2 + 8x + 4 = 0 using the quadratic formula, while also calculating and displaying the discriminant value and the nature of the roots. | codefeedback |
Create a python class that stores the name, age, and marks of a student. The class should have methods to calculate the average marks of the student, display the student's information, and determine if the student is eligible for a scholarship.
1. Create a class called Student.
2. Inside the class, define the __init_... | codefeedback |
Implement an algorithm to generate the permutations of a string, but you are not allowed to use any built-in functions or libraries to generate permutations. You must implement the algorithm from scratch using only basic programming concepts and data structures. | codefeedback |
Write a program that sorts a list of positive integers in ascending order based on the sum of their digits, and if the sums are equal, sort them based on the last digit of each element. The program should handle lists with up to 10^5 elements efficiently. | codefeedback |
Create a SQL query to find all employees whose salary is greater than the average salary of their department and whose years of experience is greater than 5. Ensure that the query does not include any employees whose name starts with the letter "A".
Table of Employees:
ID | Name | Department | Salary | YearsOfExperien... | codefeedback |
Write a Python parser to parse the json string to a dictionary, ensuring that all keys in the dictionary are unique and that all values are of type string. The parser should also be able to handle nested json objects and arrays within the string.{"name": "John", "age": 23} | codefeedback |
Write a function that takes in three parameters: a positive integer, the base of the number, and the target base. The function should convert the given number from the given base to the target base and return the converted number as a string.
The function should handle converting numbers up to 10^18. The base and targ... | codefeedback |
Given an array of integers, write a recursive program to merge two sorted subarrays ar1 and ar2.
ar1 = [1, 4, 7, 9]
ar2 = [2, 5, 6, 8]
You are not allowed to use any built-in sorting functions or additional data structures.
Your program should have the following steps:
1. Check if either ar1 or ar2 is empty. If one... | codefeedback |
Develop a GUI application in Java to reverse a string.
User should be able to enter a string in the text field.
The program should only use recursion to reverse the string.
No loops or built-in reverse functions should be used.
The program should also display the number of recursive calls made to reverse the string. | codefeedback |
Create an algorithm in Java that prints the prime numbers between 1 and 100, but the algorithm must not use any built-in functions or libraries to determine whether a number is prime. | codefeedback |
Develop a Swift program that returns the index of the first occurrence of a given element in an array. Given an array of integers and a target element. The array can contain duplicates.
Constraints:
- The length of the array will not exceed 10^5.
- The values in the array can be any integer between -10^9 to 10^9.
- Th... | codefeedback |
Develop a code to perform linear regression in R, where the data contains missing values and outliers, and the code should handle these issues appropriately before fitting the regression model. | codefeedback |
Develop a ReactJS program that displays the sum of two number inputs.
The two numbers that the user will input should be positive prime numbers. | codefeedback |
Compute the sum of two integers without using the "+" operator, in O(log n) time complexity, where n is the maximum number of bits required to represent the given integers.
x = 12345
y = 67890 | codefeedback |
Classify the following sentence as a declaration or an instruction, considering that the sentence may contain multiple clauses and punctuation marks:
"Be careful while crossing the street, especially during rush hour, as there have been numerous accidents reported in this area." | codefeedback |
Given two lists of integers, write a Python code to find the common elements in both the lists and return them as a new list. The common elements should be unique and sorted in ascending order.
list1 = [3, 7, 14, 19, 19, 25]
list2 = [6, 8, 14, 17, 19, 25]
Example:
Input:
list1 = [3, 7, 14, 19, 19, 25]
list2 = [6, 8, ... | codefeedback |
Write a Python code to classify the following sentence: "The quick brown fox jumps over the lazy dog." | codefeedback |
Find the sum of all elements in a matrix using C.
int A[3][3] = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9} }; | codefeedback |
Implement a method in Java that calculates the memory size of a list of integers. The method should take a List<Integer> as input and return the size of the list in bytes. The size should include the memory occupied by the list itself, as well as the memory occupied by each individual integer in the list. | codefeedback |
Implement a recursive function in Python to calculate the factorial of a given number. | codefeedback |
Sort the strings alphabetically using C++. The strings should be sorted in reverse order, starting from the last character of each string. Additionally, the sorting algorithm should be implemented using a recursive function.
string arr[] = {"Geeks", "for", "Geeks"}; | codefeedback |
Debug and optimize the following code, describe the changes and explain their purpose.
You are given a string and you need to reverse it. The initial code already accomplishes this task, but it can be improved.
First, modify the code to handle both uppercase and lowercase letters. The current code only works for lowe... | codefeedback |
Create a JavaScript function for sorting a list of strings alphabetically by their third letter, but without using any built-in sorting functions or methods such as Array.sort(). The function should have a time complexity of O(n^2).
Example input:
["apple","pear","banana","grape"]
Example output:
["banana", "grape... | codefeedback |
Create a CSS class for creating a two-column layout. The two columns should have a fixed width of 300 pixels each and should be aligned side by side. The columns should have a 10 pixel gap between them. Additionally, the first column should have a background color of light blue and the second column should have a backg... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.