Algorithms

3K

Solutions

10

Articles & Videos

4K

Contributors

An algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hey,

I have an audio file, many actually, that are an interview between the interviewer and interviewee.  The same person is asking questions in each file, while the people answering are different.

I need to separate the answers out by generating silence over the interview questions. I'm currently doing this by hand with audacity, but it is extremely time consuming.

Any help would be greatly appreciated.  I am a software developer, but audio is not my area, so code is am option if there isn't a program available.

Thanks
0
Free Tool: SSL Checker
LVL 8
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

If I am comparing my algorithm to another algorithm. My algorithm has a complexity f O(n) whereas the other algorithm is O(n2).

I then measured the running time by implementing the algorithms.

Should the running time of the other algorithm be the square of the running time of my algorithm?

For example of my algorithm running time is 3 ms should the other algorithm running time be 9?
0
I got a requirement from my client that he wishes to encrypt/ password protect some of the documents, before sending over to another user in another regional office.

By not writing the password into the email body.

How can the user in another regional office knows the password to decrypt/ open the protected documents?

What approach should be adopted? Is there any standard/ algorithm I can refer to? But we prefer not to use any 3rd party software/ utility.

Thank you.
0
the array has series of numbers Need to find all pairs in the array using a hash table
integers ...
0
The problem: I want to display a row of rectangles placed shoulder to shoulder, on a grid page (think graph paper). The width of the page where the rectangles appear will be an unknown integer variable (but always greater than 100).  The height of the rectangles will be a constant integer value (e.g., 20 units high). I want to fill a row on this page with as many rectangles as possible where the rectangle width will be equal or greater than the predefined rectangle height and where there will be no gap/margin at the end of the row.

I realize that this is only possible when the page width (e.g. 200)  can be evenly divided by the rectangle height (e.g., 200 / 20).  If the page width is 201, it is impossible to have rectangles all with the same width and at the same time have no gap/margin at the end of the row of rectangles. But if the page width is 210, I can fit 10 rectangles which are 21 units wide. That's fine. I don't mind stretching the rectangles a bit, as long as the rectangle width is never less than the predefined rectangle height constant (in this example, is 20). So, if the page width is 220, that works fine for I can get 10 rectangles of 22 units across the page with no gap/margin at the end of the row. I don't mind the rectangle width growing a bit so as to ensure no right margin/gap results. But there would be a limit to the rectangle width changing from its original desired width (which is equal to the rectangle height constant).  So I would need the …
0
How to disable disable any 96-bit hmac algorithms in centos
0
I have an array that will have approx 3000 elements. Within each element is an array that contains two key:value pairs. I want to sort the elements of the outer array based on the value of the first key:value pairs within each element.

e.g.
array = [{"key1":"group9","key2":["20170222","20170531"]},{"key1":"group3","key2":["20170221"]},{"key1":"group7","key2":["20170321"]}, ..................]

so sorting gives e.g. (the elements are arranged based on sorting the groupX value of key key1 i.e. the first key:value pair)

array = [{"key1":"group3","key2":["20170221"]} ,{"key1":"group7","key2":["20170321"]} ,{"key1":"group9","key2":["20170222","20170531"]},................................]


I've implemented a merge sort and it works fine. But I want to look at what is the most efficient algorithm to use, as my colleagues have suggested bubble sort (I thought this was one of the worst algorithms, but it really depends on how large the dataset is).

Can anyone advise?

I'll (learn to) implement this on a webpage so I'm using Javascript/JQuery/ReactJS
0
I know that a circle has 360 degrees and Pi has a very specific an known value.

The question is, must a circle had 360 degrees? Or was that a decision that was made so each quarter would have 90 degrees?

So, was Pi "backed into"?

If Euclid had wanted a circle to be 400 degrees, could he have simply used a different formula to generate Pi?

Curious.

And what is that formula to generate Pi, if you have it.

Thanks
0
Hello,
I need some help with this code. It works for some Arrays but not for all. Do you see a mistake in the code?

These are the failures of 13 different tests:
  There were 3 failures:
  1) test3(ads.set2.knapsack.test.EfficientKnapsackTest)
  java.lang.AssertionError: Checking optimal profit:  expected:<3144> but was:<2660>
  ?at ads.set2.knapsack.test.EfficientKnapsackTest.performTests(EfficientKnapsackTest.java:157)
  ?at ads.set2.knapsack.test.EfficientKnapsackTest.test3(EfficientKnapsackTest.java:69)
  2) test4(ads.set2.knapsack.test.EfficientKnapsackTest)
  java.lang.AssertionError: Checking optimal profit:  expected:<76> but was:<72>
  ?at ads.set2.knapsack.test.EfficientKnapsackTest.performTests(EfficientKnapsackTest.java:157)
  ?at ads.set2.knapsack.test.EfficientKnapsackTest.test4(EfficientKnapsackTest.java:74)
  3) test8(ads.set2.knapsack.test.EfficientKnapsackTest)
  org.junit.runners.model.TestTimedOutException: test timed out after 300 milliseconds

  FAILURES!!!
  Tests run: 13,  Failures: 3



public class KnapsackSolver {

	/**
	 * Calculates the maximum profit for the knapsack problem using 
	 * an improved dynamic programming algorithm
	 * 
	 * @param items
	 *            the items available to be packed into the knapsack.
	 * @param capacity
	 *            the maximum weight allowed for the knapsack.
	 * @return the maximum profit possible for the given weight
	 */
	public static int pack(final Item[] items, final int 

Open in new window

0
I have used Python, Natural Language Processing and web scraping technology to do some deep mining of Google's vast warehouses of articles on the web.

Is what I described considered artificial intelligence?

Or, in order to satisfy the requirement of AI must that model also automatically adjust it's algorithms based on the results of the searches? In my case, the adjustments were manual.

Curious.

Thanks.
1
On Demand Webinar: Networking for the Cloud Era
LVL 8
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Here's an interesting coding puzzle:

A trader can perform two buys and two sells in a day of a given stock. An array of positive integers represents the share price of this stock at different times of the day (index i = 0 represents hour 1, i=1 represents hour 2, etc). The trader must always sell any current shares he has before he buys more shares. Write a function that determines the maximum profit the trader can make by buying and selling stock for a given day.

int maximizeProfit(int[] prices) {
   // Your code here
}

ex:
[10, 22, 5, 75, 65, 80]
The maximum profit is 87: buy at 10 sell at 22, buy at 5, sell at 80.

Open in new window


The solution should have time complexity O(n).
2
I have a trading system that is about 40% right. That means 4/10 signals generated by it yield in profit and the remaining 6 result in loss. Can I use neural networks/AI/Deep-learning to improve the chances? Can neural networks be used, in this case, to filter-out the bad trades in advance such that the trading system produces 60% good trades?
0
Merge sort, bitonic sort, radix sort, quick sort for opencl interface
0
Examples of Enumerating Permutations and Combinations
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.

https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt
https://filedb.experts-exchange.com/incoming/2017/03_w12/1152429/Combinations.txt
https://filedb.experts-exchange.com/incoming/2017/03_w12/1152430/Perms-Combs.xlsm

1. I've attached the XLSM Excel spreadsheet I used in the video

Please use the example files I have attached.Permutations.txt
Combinations.txt
Perms-Combs.xlsm
1
If you're interested in block chains (as used in bit coin and now for many other purposes) I found this to be a very good primer.
6
I'm creating an Avl tree to sort information about some countries. I want each node to be a list with 2 parameters being the name of the country the first and the information specific to the country  the second. Is it possible the second parameter of the node to be another avl tree?

Thanks.
0
I've been really interested in recommendation systems lately which has lead my down a few rabbit holes. One of these landed on a similarity measurement called Jaccard similarity which is a fairly straightforward metric for communicating how many elements two sets have in common.

This turns out to be very difficult to compute without some tricks but can be estimated with a certain degree of confidence using minHashing. If this sort of thing interests you I would check out this blog post by Chris McCormick - its one of the best explanations I came across (even though its in the context of document similarity). There is even some python code provided.

I would summarize the technique in one sentence as: by randomly shuffling the union of two sets and looking at the first element in the new, shuffled set, the probability that it is an item belonging to their intersection is equal to the Jaccard Similarity.

http://mccormickml.com/2015/06/12/minhash-tutorial-with-python-code/
5
I have some written material that I need to organize. The material is in separate documents. I would like some (easy, non-complicated) automated method that could parse the documents into some sensible format. Initially, I need a table of contents for a writing project I'm involved in. Can a table of contents be generated from separate documents? Is there a way to cluster/classify the text? Neural Network text analysis seems like overkill. Mind Mapping also seems like a lot of work. Maybe MS Word? I can merge the documents into one document if that would help. Any ideas appreciated and points awarded for workable solutions. Thanks.
0
Here goes the code, and the compiler shows the warning : qmain.c:49:20: error: expected ‘;’, ‘,’ or ‘)’ before ‘.’ token
 void qdelete(int* q.front, int* q.rear)


#include<stdio.h>
#include<stdlib.h>
#define size 50

typedef struct queue
{
int a[size];
int front;
int rear;
}ob;

ob q;

void qdelete(int*, int*); 

void insert ()
{
int ele;

printf("\nEnter the element to be inserted:\t");
scanf("%d", &ele);

if((q.rear+1)%size==q.front)
			// same as this : if((q.front==0)&&(q.rear=size-1)||(q.rear+1==q.front))
{
printf("\nQUEUE IS FULL !!\nNo more elements can be inserted.");
return;
}

else
	{
	if(q.rear==size-1)
		q.rear=0;
	else
		q.rear++;
	}
	q.a[q.rear]= ele;
		
	if(q.front==-1)
		{
		q.front=0;
		printf("%d rear = %d front is the first element of the queue.", q.a[q.rear], q.a[q.front]);
		}
	
	printf("\n%d Inserted",q.a[q.rear]);
}


void qdelete(int* q.front, int* q.rear)
{
if(q.front==-1)
	{
	printf("\nQueue empty");
	return;
	}
	
else
	{
		printf("\nElement output %d", q.a[q.front] );
	
		if(q.front==q.rear)
			{
			q.front=-1;
			q.rear=-1;
			}
		else
		{	
		q.front==(q.front+1)%size;

					/*	same as this: 
					if(q.front==size-1)
							q.front=0;
						else
							q.front++;	*/
		}
		printf("\nDeleted");
	}
}

void display ()
{
int i=q.front, j=q.rear;
printf("\nDISPLAY:\t");

while(i!=j)
{
printf(" %d ", q.a[i++]);
}

printf (" %d", q.a[i]);
printf("\n");
}


void main()
{
int choice;
q.front = -1;
q.rear = -1;

while(1)

	{
	

Open in new window

0
On Demand Webinar - Networking for the Cloud Era
LVL 8
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

I am building a backups application in which I want to know the files that have been Added/modified/Renamed/Deleted.
I am trying out the ReadDirectoryChangesW() Windows API. I created two files TestNewFile.xlsx and TestNewTextFile.txt.

I get so many notifications, How can I get a workable result ?
Is there some Algorithm to manage these ?

I use Delphi with SQL Lite catering to all Windows OS

Results while Creating Excel File

waAdded   TestNewFile.xlsx
waRemoved   TestNewFile.xlsx
waAdded   ~$TestNewFile.xlsx
waModified   ~$TestNewFile.xlsx
waModified   ~$TestNewFile.xlsx
waAdded   90A4C000
waModified   90A4C000
waModified   90A4C000
waModified   90A4C000
waModified   90A4C000
waModified   90A4C000
waModified   90A4C000
waRenamedOld   90A4C000
waRenamedNew   TestNewFile.xlsx
waModified   TestNewFile.xlsx

Open in new window


Results while Creating Notepad File

waAdded   TestNewTextFile.txt
waRemoved   TestNewTextFile.txt
waAdded   TestNewTextFile.txt
waModified   TestNewTextFile.txt
waModified   TestNewTextFile.txt

Open in new window



Other Results that keep coming on their own or while using Windows Explorer.

waModified   Users\SS Smith\ntuser.dat.LOG1
waModified   Users\SS Smith\NTUSER.DAT
waAdded   Windows\Prefetch\TASKMGR.EXE-5F5F473D.pf
waModified   Windows\Prefetch
waModified   Users\SS Smith\AppData\Local\Microsoft\Windows\UsrClass.dat.LOG1
waModified   Users\SS Smith\AppData\Local\Microsoft\Windows\UsrClass.dat
waModified   Windows\Prefetch\DLLHOST.EXE-5E46FA0D.pf
waModified   Windows\System32\wbem\Repository\OBJECTS.DATA
waModified   Windows\System32\wbem\Repository\INDEX.BTR
waModified   Windows\System32\wbem\Repository\MAPPING2.MAP
waModified   Windows\Prefetch\AVWSC.EXE-327FD431.pf

Open in new window

0
Anyone know of a relatively straightforward algorithm for computing the numbers of ones and zeroes in an arbitrary string such that, we could address the function thus

Number_of_Ones=bitcount(arbitrary_string,1)
Number_of_Zeroes=bitcount(arbitrary_string,0)
0
Assuming a given time for sunrise or sunset at sea level, what adjustment have to be made to those times for a given altitude (i.e. 2400 feet).
0
I'm a little lacking in the statistics area - more like a lot.
I have a list of numbers in excel that I think might be related to a stock price trend.
There are about 2000 + representing each day along with the comparative stock price at that same time.
I also record whether the stock went up or not from the previous day.
I want to know if the Number column is related to the trend column.  It cold be related to the current day, the next day or perhaps days in the future using the number column as the base. The end result would be to say that the

Does anyone have an idea on how I could examine this - whether in excel or in some other method (i'm good in vba, very basic python)?
Sample.xlsx
0
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
7
 

Expert Comment

by:fidsplice
Comment Utility
You've identified a problem that has been known for thousands of years. Fundamentally it's arrogance and stupidity. Bright young things think they have the answer! But examination shows the problem is far more complex, far more basic, and difficult to solve. If it were easy it would already have been solved! It's easy to cry wolf (and extremely valuable) but the real contribution is to propose a solution. Where's yours? A plea for inclusion in the decision making process doesn't wash. No one invites outsiders into the inner sanctum.

The solution exists in disciplined method. Information systems academic professionals have a short history (30 to 50 years) of extraordinary science from some brilliant minds. We have a full repertoire of how to properly address systems development. Unfortunately it is not applied well. If you were a structural engineer or an electrical engineer, or whatever, you would be well measured in the work you produce. We don't do this, so we allow crap to be unloaded on our consumers. We have the metrics. We don't apply them. That is the answer to our defective development.
0
 
LVL 110

Expert Comment

by:Ray Paseur
Comment Utility
Gene: This might be worth a read.  
https://www.nytimes.com/2016/12/14/magazine/the-great-ai-awakening.html?_r=0

Calling this "algorithms" is like calling the car a horseless carriage.  It misunderstands the potential, and even as early attempts at the automobile were inept and full of missteps, so too are our early attempts at machine learning and artificial intelligence.  It took Google, with all their computers and brainpower, until 2012 before they could identify a cat in a video.  But the same technology that can learn what a cat "looks like" can formulate a response, can be used to locate tumors in MRI data, or turn the wheel of a self-driving car.  You might be interested in trying out Tensorflow.  "Don't worry, you can't break it."
http://playground.tensorflow.org/

To understand the way machine learning works you need little more than a basic understanding of the first derivative in differential calculus.  Detective and predictive computation is all about minimizing error with gradient descent along multidimensional slopes.  As simple as it seems today, we only got workable AI tools in 2016.  If the world had looked on the 1886 patent 37435 in 1887 and let its shortcomings shape their vision of its future, we would probably still be riding horses.

AI and machine learning are different from human learning, as is illustrated by this image that was created when we tried to turn the cat-detection algorithms around and get them to generate a picture of a cat.  We don't really know how machine learning works in any given instance.  It's unpredictable to the human mind because it's about detecting patterns in large amounts* of data, something we cannot do very well, and something that machine learning, suddenly, has come to grasp.  I am presently experimenting and writing about this field, and I guarantee it is revolutionary, a black swan of the magnitude of the atom bomb, and perhaps the greatest scientific advancement of our lifetimes.
A numerically generated cat* Google analyzed literally millions of cat videos before their algorithms could even find a cat.  And then they drew this monster.  Obviously we're only on the threshold.
0
A "valid" string is a string S such that for all distinct characters in S each such character occurs the same number of times in S. For example, aabb is a valid string because the frequency of both characters a and b is 2, whereas aabbc is not a valid string because the frequency of characters a, b, and c is not the same. Watson gives a string S to Sherlock and asks him to remove some characters from the string such that the new string is a "valid" string. Sherlock wants to know from you if it's possible to be done with less than or equal to one removal..

I tried to solve this specific challenge in Hackerank and I can't pass all the test cases. 2 is the minimum number of removals required to make it a valid string. It can be done in following two ways:

input = aabbcd...

Sample Output must be NO.

Explanation

Remove c and d to get aabb. Or remove a and b to get abcd.


-----------------------------------------------------here is my code----------------------------------------------------
function processData(input) {
    //Enter your code here

var i =0;
  var m = string.match(/string[i]/);
       

if (m && m.length > 2) {
  console.log("yes");
} else {console.log ("NO");}

    console.log(m);
----------------------------------------------------------------------------------------
The thing is that match() returns null.....
Please if you find time answer my question!
Thank you so much
0

Algorithms

3K

Solutions

10

Articles & Videos

4K

Contributors

An algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.