Questions tagged as 'algoritmos'

0
answers

Challenge solution of the 8 queens in python

What the challenge is: Hello people, I do not know if you know the challenge of the 8 queens. If you do not know it, I'll explain it to you shortly. We have a chess board like any other and you have to place 8 queens on the board without bein...
asked by 09.06.2018 / 05:13
1
answer

Query with algorithm for a [closed] problem

Good treatment to do the next problem . Here's my solution : #include <stdio.h> #include <bits/stdc++.h> using namespace std; #define MAX 10005 #define Node pair< int , int > #define INF 1<<30 struct cmp { boo...
asked by 15.06.2016 / 21:20
3
answers

Why not use if within a cycle for

Hello, my question is this: for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; Given an example like anybody like this where I have a if within a cycle for , the teacher told me:...
asked by 24.01.2018 / 05:19
1
answer

Is there really more efficiency in the Cocktail Sort than in the Bubble Sort?

I have these two codes the following which represents the bubble sort is the following: lista = [5, 4, 3, 2, 1] def bubble_sort(A): #Se comienza con el primer elemento for i in range(len(A) - 1): for j in range(len(A) - 1):...
asked by 16.07.2017 / 05:21
2
answers

Why does it mark me list index out of range?

Can someone tell me what error I have in my code if it is not too much trouble. def CreaLista(k): L = [] for i in range(k+1): L.append(0) return L def CountingSort(A,k): C=CreaLista(k) B=CreaLista(len(A)-1) for...
asked by 27.02.2017 / 09:01
3
answers

How to show the number of employees by sex?

I have the following code which shows me the data of N number of employees admitted My question is this: How do I show the number of employees by sex? int main(void){ /*Declara las variables para los ciclo for*/ int i = 0, n = 0...
asked by 29.03.2018 / 17:16
2
answers

Problem with backpack problem

I am working with a case of a client in which he applies the algorithm Problem of the backpack . I am using the code that I attached, it works more or less and has errors. The example has 12 packages of different weights (which in their tota...
asked by 27.02.2016 / 04:44
2
answers

java.lang.StackOverflow when using recursion

I'm doing a function that prints the percentage of the process, which ends when the counter reaches the target amount, but always throws me the following error: Exception in thread "main" java.lang.StackOverflowError at pruebas.Bucles.recu...
asked by 02.06.2017 / 00:05
1
answer

Huffman Algorithm - decoder

I'm doing the decoding part of the huffman algorithm, as such my program receives two files per console, one called "diccionariotxt" which contains the letters, the frequency with which they exit and the binary code of each letter and another on...
asked by 25.06.2016 / 04:55
2
answers

Problem with chess exercise in java

The objective of the program is to print a chessboard, with squares B (white) and N (black), ask for a row and a column and establish a bishop there. So far so good, but the problem comes when you have to modify the board with asterisks in th...
asked by 08.11.2016 / 19:48