Most voted "algorithm" questions
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when the problem is related to the design of an algorithm. Always use specific algorithm tags when the question is more directed to a specific type of algorithm.
Learn more…723 questions
Sort by count of
-
1
votes2
answers374
viewsCreate loop in templates with php
I’m having trouble creating an algorithm to implement the use of loops in a class of template simple. I have my class below, it gets an HTML file, looks for strings specifies that are in this file…
-
1
votes2
answers997
viewsJoin lines from a text file
Given a text file with the layout below: VASCO;JOGADOR_1 VASCO;JOGADOR_2 VASCO;JOGADOR_3 PALMEIRAS;JOGADOR_4 PALMEIRAS;JOGADOR_5 PALMEIRAS;JOGADOR_6 PALMEIRAS;JOGADOR_7 How to create a logic…
-
1
votes3
answers1452
viewsHow to create a category tree in C#
Database I have a database with product and service codes (for public tenders) and wanted to find a way to create a "tree" for these codes. See how I have configured my database in the following…
-
1
votes1
answer1749
viewsHow to make a Java algorithm that can measure the running time of the Heap Sort sort sort algorithm?
I started my algorithm this way so that I can measure its running time, but I’m not sure if it’s right, how to continue with an example: package heapsort; public class Heapsort { public static void…
-
1
votes1
answer548
viewsCheck whether double variable is empty or numeric
How can I check if the variable a, b or c were not informed, and if in case they were not informed return all the code ? How can I also check if the letter "x" for the variable was entered in the…
-
1
votes0
answers52
viewspeople someone help me with this visualg function
i am trying to use the ready functions of visualg, to read a name, tell the 3 letter code as well as show it, but the problem is this giving direct error ("this is the code of the third letter of…
-
1
votes1
answer1412
views(JAVA) Help in Sorting Exercise (Selection Sort and Insertion)
/*EXERCISE: Write a method that puts in ascending order a disordered sequence of n integer. (a) Using sorting by selection (b) Using sorting by insertion*/ I tried to solve the exercise, but I’m…
-
1
votes0
answers875
viewsTraverse Arvore Binaria
I would like to make a function in PHP that goes through the entire binary tree, so I made this code. function getTree($id, $count, $conn) { if ((!isset($count)) || ($count = null)) { $count = 1; }…
-
1
votes0
answers1067
viewsexercise in visualg algorithm
The cost to the consumer of a new car is the sum of the factory cost with the percentage of the distributor and the taxes, both applied to the factory cost. It is known that the percentages are the…
-
1
votes2
answers779
viewsGet first item of each object in a JSON response
I am getting a json through the following URL: http://jsonplaceholder.typicode.com/photos (via get) I’m iterating on the objects, but I wanted to get just the first one item of each object, in which…
-
1
votes2
answers826
viewsC Password Validator
I’m trying to solve the problem 2253 - Password Validator, URI, but is giving 10% wrong answer, but all my tests are working, someone can find the error? #include <stdio.h> #include…
-
1
votes1
answer174
viewsDifference between Divide and Conquer, Decrease and Conquer and Dynamic Programming
What’s the difference between algorithm design techniques Divide and Conquer and Decrease and Conquer? To divide is recursive and the decrease nay? Some example for the decrease? And dynamic…
-
1
votes1
answer860
viewsFibonacci issue in Java
I have a question and her resolution, which needs to be with while or do-while. But I did not understand the resolution, could someone explain to me? I will comment on the specific doubt of each…
-
1
votes1
answer185
viewsCode review: field validations, how to abstract correctly?
In a Java Swing application I have four JTextFields: Weather minimum of handover of an order in minutes Weather maximum of handover of an order in minutes Weather minimum of withdrawal of an order…
-
1
votes2
answers803
viewsError in assigning a value to a variable
I’m doing some algorithms on Visualg and came across the following error: Error in assigning values to variable d: REAL to INTEGER My code is this one: Algoritmo "acertoMiseravi" d: inteiro Inicio…
-
1
votes1
answer32
viewsProgram stops responding when I try to fill the list
This is the code, it simply reads the values and puts it on the list, but in the last loop it stops responding #include<stdio.h> #include<stdlib.h> typedef struct pessoa { int…
-
1
votes1
answer97
viewsFunction that is not running in C
This is a code whose goal is to add all the integers between a and b. Being "a" less than "b". The expected output was a number representing this sum, however, after reading a and b, nothing…
-
1
votes1
answer232
viewsSpecifying students height and sex with a "while"
The exercise asks me to read 20 students and their respective heights and gender, and then show the average height and how many men and women we have. What I did was this: int main() { float altura,…
-
1
votes1
answer47
viewsComplexity of simple algorithm
I’m having difficulty in this exercise of complexity of algorithms, someone can give a light? Prove that if f(n) = -n then f(n) is O(1). One idea I had was that for any positive n, f(n) will be less…
-
1
votes1
answer577
viewsHow to make algorithm to calculate efficient (not exponential) recursive Fibonacci sequence?
I’m studying recursion, and I wanted to find a way to make a recursive algorithm for efficient Fibonacci sequence, where the algorithm is not exponential. How will I save the value of subproblems??…
-
1
votes1
answer900
viewsSort a chained list with Java Selection algorithm
I am working on sorting algorithms. I have implemented sorting with Bubble Sort, however, must be implemented with an example where the algorithm is not stable( Selection ,Quicksort, Heapsort or…
-
1
votes2
answers117
viewsHow do I make "while" repeat 4 times only and break to the next C command?
int numeros, calculo, soma; numeros = 0; calculo = 0; while (calculo > 0) { printf("Digite o número: "); scanf("%d", &numeros); calculo++; } soma = calculo + soma; printf("A soma entre os…
-
1
votes3
answers127
views(Pure js) function that Filtre array so that it returns single arrays with distinct elements
var list =[ [3,4,7,9,4],[3,4,7,9,5],[3,4,7,9,6],[3,4,7,9,7], [3,4,7,9,8],[3,4,7,9,9],[3,4,8,3,3],[3,4,8,3,4], [3,4,8,3,5],[3,4,8,3,6],[3,4,8,3,7],[3,4,8,3,8],…
-
1
votes3
answers424
viewsSort a string array in Swift using a function
I am in need of a help to solve the following programming logic problem on Swift. The task is to arrange the array below downwards using a function. Description: You must implement an algorithm that…
-
1
votes0
answers109
viewsAlgorithm in C to verify that a typed period (start and end date) does not overlap, even partially, with a previously registered period
Galera I am creating a system algorithm and control of hotels in C for a college job , in the reservation module need to make reservations of the rooms between start date end date and when to make…
-
1
votes0
answers146
viewsTraveling Salesman - Exhaustive Algorithm
I need to create an algorithm that: 1. Discover all possible paths that visit all vertices of a graph without going through the same vertices twice. 2. Store all results. 3. Return the path with the…
-
1
votes0
answers113
viewsRecursiveness - Why am I entering a loop?
I’m trying to implement an algorithm called Minimax, but I’m finding problems in effecting its recursion, it goes into a loop that I can’t identify why. The depth of the algorithm should vary…
-
1
votes2
answers257
viewsMystery Square
The integers positioned on an Nxn square such that all lines and main diagonal have the same sum. For example, the square below 2 7 11 9 5 6 4 3 13 is a mysterious square of sum 20, since all lines…
-
1
votes1
answer865
viewsRecursive heapsort in C
I have a heapsort, and would like to implement it recursive. What I need to change in my algorithm? void criarHeap(int v[], int inicio, int final){ int aux = v[inicio];//v[pai]//inicio=pai int filho…
-
1
votes0
answers31
viewsError when displaying int value
Hello, I’m new to the C language and I’d like to know how to fix this code. When executing the code below, I get the following error message in row 22 and column 13: [Error] invalid Conversion from…
-
1
votes2
answers68
viewsHow do I show the wrong input numbers?
In this code I would like that if the student enters some wrong note, the program responds which grades are wrong. But based on what I did only appears the first note. I also wish that when typing…
-
1
votes1
answer14836
viewsHow to calculate the sum of each row of a matrix in C?
I need to create an algorithm that reads the dimensions of a matrix, read the values to be placed in the matrix, with a vector calculate the sum of the values of each row and print the matrix and…
-
1
votes1
answer279
viewsDijkstra Algorithm - How do I change the reading of the txt file in C to be identified in int and not string?
Good night, I’m having a question how to change the reading of the txt file, where the compiler identifies with char but within the file that need read, possessed only numbers, someone could help me…
-
1
votes1
answer880
viewsCompute Principal Diagonal Sum of a Javascript Matrix (Node)
I’m trying to calculate the main diagonal of an array in Js, someone could help ? function calcularDiagonal(matriz) { let soma = 0; for(let i = 0; i < matriz.length; i++) { for(let j = 0; j <…
-
1
votes1
answer111
viewsHow to reverse the order of a sentence?
I tried to make a program that takes a phrase and returns the phrase in reverse order. Example: Input: "Hello, Java!"; Output: "Java! Hello,"; I tried to do it, but it’s not working. import…
-
1
votes0
answers187
viewsProgram does not run both For links within if - C
I have 2 ties for within a if, as shown below: if (grid[j][k] == words[i][0]){ int el = j, col = k; //Metodo direita, baixo for(l=0;l < wordlen(search_word);l++){ if(l%2 != 0 ){ // Procura à…
-
1
votes1
answer155
viewsHow to check if the Sliding puzzle is solvable?
Hello, I am developing a small work where I need to solve a puzzle through algorithm A* more precisely this puzzle: Basically it consists of sliding the pieces to the white space in order to keep…
-
1
votes1
answer39
viewsDegree of complexity
def fRecursivo(n): if(n == 0 ): return 1 if (n%2 ==1): return (n+3*fRecursivo(n-1)) if(n%2 == 0 and n> 0): return (n+n+3*n*fRecursivo(n-1)) How complex is the code for even numbers ? In the case…
-
1
votes1
answer1763
viewsError in Visualg Program "incorrect syntax"
This exercise is college, I’m trying to do VisualG but always give that "error syntax", what I did. I tried other ways but I found this one easier to understand. I don’t want the answer. algoritmo…
-
1
votes2
answers83
viewsFunction that creates list inside list
def add_divisors(list_num): final_list = [] divisors = [] for number in list_num: for x in range(1, number+1): if number % x == 0: divisors.append(x) final_list.extend(divisors.copy())…
-
1
votes1
answer31
viewsAsymptotic complexity of function
When I have a function of two variables like: f(x, y) = log y + 3 * x^4 I can say that the asymptotic domain of function is theta(x^4)? Or I have to consider the two variables and define how Omega(y…
-
1
votes0
answers92
viewsPass input numbers to Python array
I’m doing an exercise on bipartite graphs, in which the input is given in the following form: 6 2 4 5 1 3 2 3 5 1 0 2 2 1 1 1 Being 6 (the number of the first line) the number of lines to be read,…
-
1
votes1
answer123
viewsDifference between algorithms that read numbers until receiving the number 999
What is the difference of these codes? First code: cont = 0 n = 0 total = 0 n = int(input("Digite 999 para parar")) while n != 999: n = int(input("Digite 999 para parar")) cont += 1 total += n…
-
1
votes1
answer109
viewsAbout Analysis of Algorithms
I have a question on two questions regarding the content of algorithmic analysis. Issues In computer science, an algorithm is a finite sequence of executable actions that seek to obtain a solution…
algorithmasked 5 years, 11 months ago Igor Alisson 107 -
1
votes1
answer1146
viewsWhat is video frame interpolation (video frame Interpolation)?
Reading some news I came across this: Transforming Standard Video Into Slow Motion with AI or NVIDIA AI creates slow motion videos without "recording more frames", where Nvidia used an algorithm…
-
1
votes2
answers52
viewsDoubt in the structure of the code
In that code: class ShoppingList extends React.Component { render() { return ( <div className="shopping-list"> <h1>Shopping List for {this.props.name}</h1> <ul>…
-
1
votes1
answer178
viewsRepeat rows from a table using Javascript
My question is the following: I have this code where it feeds a table with 3 fields (portion value, start date, end date). From my numerous attempts I have not had success I am trying by a while to…
-
1
votes0
answers103
viewsnaive Bayes - Warning message: In data.Matrix(newdata) Nas introduced by coercion
I was able to run the algorithm naive Bayes on R, but I’m finding problems to make the result confounding matrix. This is the message I receive after performing the prediction with the command…
-
1
votes0
answers95
viewsImage SVM classifier does not work
Hello, I’m with a program in Python that uses the library Dlib 19.10, the classifier uses an xml file to learn the images and then I run the following code that creates a file. svm for the…
python algorithm opencv image-processing artificial-intelligenceasked 5 years, 5 months ago Marcos Paulo S. Rezende 351 -
1
votes2
answers2002
viewsPython binary search algorithm
Hello, I want to create a function that given a list to and a value m within this list, return the position of the value m. My idea was to start with the extreme values of the ordered list and take…