Category "algorithm"

Simple shape recognition and classification by algorithm

I'd like to classify simple shapes (see the attached "sample resource of shapes") algorithmically (automatically). Does anyone know how to do that? The intended

Algorithms to find shapes among random points

Let's assume we have: A) a large set of random 2D points, and B) a small set of 2D points representing a simple geometric shape of choice, e.g. a triangle (3 x

Which sorting algorithm has the best asymptotic runtime complexity?

It's a choice problem between heap sort, merge sort and insertion sort. However the best case for insertion sort is O(n) and the worst is O(n^2) Which complexit

sum up an array in the special style of reduction | (i * 2)

I am currently sitting on a java problem I've found online. We have an array which has several thousand, if not millions, of entries. the goal is to efficiently

Apply Swap Operation at Most Once to get a Strictly Increasing Sequence

I am doing some of these DS&A questions on various sites online for practice and I ran into this one: Given an array of non-negative integers numbers,

Stack balanced Parentheses build log show :- Process terminated with status -1073741510 (0 minute(s), 2 second(s))

When I try to implement parenthesis problem using stack (array representation) it showing above problem. Here I use dynamic memory allocation in array. When I

Binary Search with results returned as Indices

I'm working on an implementation of Binary Search in Python as part of a course (Algorithmic Toolbox on Coursera). The challenge is to create an implementation

My implementation of Breadth First Search with forEach doesn't work

Here is my code inside a BinarySearchTree class. I don't know if it is because of the behaviour of forEach, or because somewhere in my code is wrong. class Bina

Is my sorting code consider Insertion Sort (Python)?

I'm learning about Sorting Algorithm and now is Insertion Sort. I want to write the code base on my understanding of the algorithm first before copying code on

Why this dynamic programming recurrence relation is correct?

Consider you have a screen. Now we can do two operations on the screen: Copy content on the screen Paste copied content on the screen Suppose at the beginnin

Game of the nim, minimax

There are 3 piles (1 pile - 7 matches, 2 pile - 5 matches, 3 pile - 3 matches) you can take any number of matches, but only from one pile, the one who takes the

E-olymp: Profit. 90% gives, one test wrong answer

Description of my code: For example, take n = 3, and let p [i] be 1 2 3. For beginnings, max = 0. I take in this order the sequences: 1, 1 + 2, 1 + 2 + 3, 2, 2

Game of the nim, minimax, game tree, data structure

There are 3 piles (1 pile - 7 matches, 2 pile - 5 matches, 3 pile - 3 matches) you can take any number of matches, but only from one pile, the

How to get different maximum matchings

I have a large bipartite graph and I can find a maximum matching quickly using Hopcroft-Karp. But what I would really like is a few hundred different maximum ma

How to detect cycle using itarative approach

I am trying to learn how to detect cycle. I see many example of using recursion but I want to implement in iterative way. Here is my code public boolean cycleDe

How to sort vector of structs by given field?

I need to sort vector of structures by a given field. To anyone who faces the same problem: I just made my own sort function and there you can pass in lambda as

The special case for using Tarjan's algorithm to find bridges in directed graphs

I am trying to get better understanding of Tarjan's algorithm for finding SCC, articulation points and bridges. I am considering a special case where the graph

How to check whether all number elements in an array are even numbers with recursion?

I'm currently learning as much as I can about recursion but I'm really stuck on how to use it to check whether all the number elements in an array are even numb

How to get list of palindrome in text? [closed]

I have the following interview question that may require traversing through the entire string. Problem I searched about find Problem and most

Algorithm for determining inside and outside regions of a 3D model (multiple meshes)

I am trying to implement an efficient precomputed culling scheme in my 3D city model viewer program (a user can upload a 3D model of a city from any number of a