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
-
0
votes1
answer48
viewsCode does not display result
My code receives as input the value of n, i and j and calculates the n first multiples of i and j. I’ve gone through my loop loop and I can’t find anything wrong, but the compiler just stands still…
-
0
votes1
answer601
viewsConvert number to binary
I’m having trouble with the logic of my code: dec = (10) dup = dec co = 2 exp = 0 res = (tuple) while True: dup = dec dec = int(dec / co) exp += dup * co print(f'dec {dec} dup {dup} exp {exp}') if…
-
0
votes1
answer704
views(C) Make an algorithm that reads a string and removes vowels and whitespace
The code is copying ALL characters from one string to the other and ignoring the copy condition. I know there is an easier way to remove spaces and vowels, which is to bring the next character to…
-
0
votes2
answers62
viewsGreater amount of appearances of an element in an object array - Javascript
Hello, I have a news array(objects) lista: Array<Noticia> = []; From this array I need to find the author who has published the most news. A news has: ID | Title | Tags | Author | Contents. My…
javascript angularjs array algorithm typescriptasked 6 years, 2 months ago Arthur Gabriel Silva Arantes 51 -
0
votes1
answer23
viewsHow can I compare a variable within a list of lists by reading/changing their content in Python?
board=[['1','2','3'], ['4','5','6'], ['7','8','9']] p_move = input('Enter your move: ')) # p_move = '4' for row in board: for column in row: if p_move ==…
-
0
votes2
answers401
viewsFactorial function does not return
I need to use function in C but is not returning the factorial. Problem:"Given an integer n, calculate its factorial n!. The factorial of a number is given by the equation: n! = n(n1)(n2) : : : 1.…
-
0
votes0
answers56
viewsHow to call methods so that they have a delay?
I have a class: public class Robo { public async Task Ligar() { /* * Algo que pode demorar ou nao depende do status do robo * */ } } public class TesteRobo { public void Main() { List < Robo >…
-
0
votes1
answer62
viewsalgorithm to read age years, months, and years and convert the value to age only in days
#include <iostream> using namespace std; int main() { int idade; int anos; int meses; int dias; cin >> anos >> meses >> dias; meses= anos*12; dias= meses*30; cout <<…
-
0
votes3
answers575
viewsConstruct a program to read positive integer n and print all primes in the range [2, n]
I need to create an algorithm that reads a number and tells you if it’s prime, and then print in a list all primes smaller than or equal to the read number. I made an algorithm that says if you’re…
-
0
votes1
answer79
viewsTransforming algorithmism for visualg
I’m starting to study algorithms, and to make it easier I try to bring all the algorithms to visualg. I’m with an example algorithm but I’m not able to turn to the visualg anyone can help? I know…
-
0
votes5
answers312
viewsMake a function that calculates the following sum:
S = 10/1! - 9/2! + 8/3! ... - 1/10! def soma(): fat = 1 somar = 0.0 for i in range(1, 11): fat *= i for k in range(i, 0, -1): somar += k/fat return round(somar, 2) I arrived at this code but the…
-
0
votes2
answers1132
viewsFunctions and procedures in Portugol
About functions and procedures, I have a big doubt in this matter. I know that a function will always return data and that procedure has no return, but every function has to fill in all parameters?…
-
0
votes1
answer71
viewsError Segmentation fault (core dumped) Circular double list
I’ve been trying to make a double circular list for hours. I’ve tried to fix all the bugs but got a 'Segmentation fault (core dumped) error that I have no idea what it is. Can someone please help…
-
0
votes1
answer390
viewsProblem with calculating the mean in C language
I’m doing this exercise: 4 - Write an algorithm that reads a set of 50 chips, each one containing the height and sex of a person (1 = male and 2 = female), and calculates and prints: The biggest and…
-
0
votes0
answers18
viewsC# - How to make the program run something in certain days after execution?
I have a project that to start the . exe requests the registration of a company, but, need to renew the license in order to continue using, in case, how do I perform some action asking the customer…
-
0
votes1
answer48
viewsHow to know how many times the highest value was read (without list)?
I am doing an exercise where I must print the highest value of the numbers typed and how many times this higher value was typed. I tried to put the qnt += 1 but it’s not working. qnt = 0 num_lidos =…
-
0
votes2
answers359
viewsInitialize a function that has a string pointer as argument
I wrote a function that changes the letter of a string by its successor using a pointer of string. #include <stdio.h> #include <stdlib.h> /* 14) Implemente um algoritmo que receba uma…
-
0
votes1
answer37
viewsGenerate key to access document
I need to generate a key that contains letters and numbers Ex: "AJ67G8". I am generating with Random from java.io.Serializable: public static String nomeAleatorio(int nCaracteres) { Random rand =…
-
0
votes0
answers78
viewsProblem with algorithm in C
Good people , is the following , I am developing a project that aims to find a word in a soup of letters , the rules are as follows: The letter can be found at any position ( East, North , South ,…
-
0
votes1
answer30
viewsUp to how many different levels can a classifier predict?
I was recently doing a machine learning model and I was wondering if I should use logistic regression. The documentation says that this classifier can predict binary values (0 or 1). In my case, I…
-
0
votes1
answer133
viewsHow do I show the randomized quicksort step by step?
How do I show the sort process step by step? Either by showing the state of the vector at each change or by showing a tree. I have tried to print each of the three functions and also tried to create…
-
0
votes0
answers45
viewsComplexity of Strand Sort algorithm
I’m using the Strand Sort to do a college job and wanted to know if at level of complexity, in worst case it O(n 2). and I wanted to know under what circumstances it would be better to use this…
-
0
votes0
answers22
viewsC: How to read an indeterminate number of integers on the same line that still recognizes n?
I need to read an indeterminate number of integers on the same line to pass to a chained list, however in case no number is entered(" n"), I still need to recognize it to treat it. there’s some…
-
0
votes1
answer223
viewsGenetic Algorithm Optimization - Node.Js
I’m transcribing a Java genetics algorithm for Javascript (Node.Js), but I’m having memory and optimization problems. Context of the problem: it’s an algorithm that the company I work for is trying…
-
0
votes2
answers113
viewsProblem with C++ code
I was writing a code and I stagnated on some problem along the way. Follow below for more details: Enunciation Afonso is in line to buy tickets to his concert favorite band. Afonso is at the end of…
-
0
votes1
answer180
viewsHow to calculate the MFCC?
Hello, these days I woke up wanting to learn about voice recognition, with a brief research I found on the MFCC, so I decided to study and found this material through a google search: -…
-
0
votes1
answer522
viewsCounters in the Mergesort
I would like to know where I need to insert my variables that count exchanges and comparisons. In this algorithm I am dealing with an array of two positions that by reference modify details[0] that…
-
0
votes1
answer280
viewsCount number of comparisons and exchange in a python sorting algorithm
I need to count the number of comparisons and exchange in the following sorting algorithm: def selecao(lista): c1 = c2 = 0 for i in range(0, (len(lista)-1)): mini = i c1 += 1 for j in range(i+1,…
-
0
votes2
answers106
viewsHow to discover relevant properties of a basis for a Python classification algorithm?
I have a database (excel spreadsheet) about the health of the elderly with about 112 columns and I would like to know the best algorithm to extract some of these columns, maintaining the variability…
-
0
votes1
answer259
viewsLogical error when sorting vector in pair and odd
Well, I was trying to sort a vector in even and odd, that is, half the vector is even and the other odd. It worked "almost" perfectly. The problem is that the last position always ended up being…
-
0
votes2
answers168
viewscalculation of media in programming c
Hello I’m putting together a code for an activity of my course but the media that needs to appear at the end if you enter a negative number only appears zero, I’m a beginner in programming so I’m…
-
0
votes1
answer51
viewsAlgorithm for vector ordering
Good morning. My question is on line 9. The correct one would be: para j de i + 1 até 3 passo 1 faça or para j de i + 1 até 3 faça Follow the complete algorithm: Algoritmo numero_crescente var vet:…
algorithmasked 5 years, 6 months ago Rafael Lopes 9 -
0
votes1
answer61
viewsAlgorithm that sorts decimal numbers
People who can help me I am extremely grateful, I’m trying to build an algorithm that orders 3 real numerical values in ascending order, but not how to deal with decimal numbers in the algorithm...…
-
0
votes1
answer39
viewsHow to associate Integers or Float values with Boleano in ELM via HTML document?
all right ? I came across a simple problem. Write an algorithm that gets a number and tells you if it is odd. The answer has to be in boleanos. If the number is odd True, if it is even False ! So…
-
0
votes3
answers83
viewsAdd value to my contact for each multiples of 200 without having to create individual variables
I am creating a numerical converter. but due to my knowledge limited, I cannot program it so that every time it reaches a multiple of 200 in the counter, 4 is added in the result. I even got a…
-
0
votes1
answer253
viewsBuild a knot tree
I need to build a structure similar to a family tree, but with only one Father element that can have "n" children, and each child can also have "n" children. The structure below illustrates a test…
-
0
votes1
answer148
viewsPair or odd loop does not show the expected result
public class ParImpar { public int totali; public int totalp; public ParImpar(int totali, int totalp) { this.totali = totali; this.totalp = totalp; } public static void main(String[] args) { new…
-
0
votes1
answer850
viewsCalculate average with final exam if I fail standard grades
Read the values of four bimonthly school grades of a student represented by the variables N1,N2,N3,N4. Calculate the arithmetic mean (variable MD1) of that student and display the message "Approved…
-
0
votes3
answers82
viewsI’m not displaying the multiple correctly
I’ve developed an algorithm that should display the largest multiple between num1 <= num2. I used as example 7 and 50 and worked correctly, displaying the value 49, but when sending for…
-
0
votes1
answer1312
viewsSimple Implementation in Dijkstra algorithm
Hello, Guys I have a little doubt. In this implementation is applied the algorithm of Dijkstra, which returns the paths of lower costs. But it is returning all of the lower cost paths, and I would…
-
0
votes2
answers47
viewsFind sequence in integer value
I came to the following algorithm to return true if there is an incremental numeric sequence pattern +1 function sequenceSearch(vector) { let pos = 0; let found = 0; for (pos = 0; pos <=…
-
0
votes1
answer43
viewsHow to use a function to check the requirements imposed on a variable in C++?
I want to make a code to train structs. In this case, since the number of cars is 4, I want the choice variable to be limited in the closed range from 1 to 4 "[1,4]". So the logic is: While this…
-
0
votes0
answers36
viewsSimple program to calculate school averages in C with vector
Hello, I am trying to run a small program that I would like you to read a certain average, store 4 student X grades, calculate the average of those grades and compare with the minimum average grade…
-
0
votes0
answers64
viewsCHALLENGE: MQO curve adjustment or similar with minimization of other types of error measurements
Context The MQO (ordinary least squares) method is known to receive: a function model f parameter x (which can represent several parameters) from a model with coefficients c[1], c[2], ..., c[o],…
algorithm performance mathematics numerical-analysis square-minimaasked 5 years, 3 months ago RHER WOLF 1,529 -
0
votes2
answers165
viewsAlgorithm for summation of doubles
Given a vector V of integers, ordered, and a value s, write a complexity algorithm O(n) to compute how many pairs of numbers have sum s. In this vector there may be repeated numbers. Note that if V…
-
0
votes2
answers887
views -
0
votes2
answers255
viewsIntercalation of two arrays (vectors) in C#
My code has two arrays of 5 elements, a array has odd numbers while the other has even numbers and is needed intersperse, I created a third vector to do this, but the result is not expected. The…
-
0
votes1
answer103
viewsHelp with simple program of function and sum
Gentlemen, I’m trying to solve the following exercise: Exercise 2: Write a Python function, called soma_n, that takes an integer number, n, and computes the sum 1 + 2 + ... + n, if n > 0, or -1 +…
-
0
votes1
answer63
viewsWhy isn’t this program running the commands inside the second function on?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EX7 { class Program { static…
-
0
votes1
answer97
views